lundi 21 août 2017

Cannot resolve .andExpect() method

I am implementing this test class taken from http://ift.tt/2l8cNDz

My IDE (Intellij) is not resolving the .andExpect() method. I've searched the web but cannot find which jar or class this is part of. Can anyone help me out? Thank you.

@RunWith(SpringRunner.class)
public class ClientControllerTest {

    @Autowired
    MockMvc mockMvc;

    @MockBean
    CreateClientService createClientServiceMock;

    @Autowired
    ObjectMapper objectMapper;

    @Test
    public void testCreateClientSuccessfully() throws Exception {
        given(createClientServiceMock.createClient("Foo")).willReturn(new       Client("Foo"));

    mockMvc.perform(post("/clients")
        .contentType(MediaType.APPLICATION_JSON)
        .content(objectMapper.writeValueAsBytes(new     CreateClientRequest("Foo"))))
        .andExpect(status().isCreated())
        .andExpect(jsonPath("$.name", is("Foo")))
        .andExpect(jsonPath("$.number", notNullValue()));
    }
    ...
}

Aucun commentaire:

Enregistrer un commentaire