I'm trying to make a simple test using spring boot.
mockMvc.perform(post("/user")
.contentType(MediaType.APPLICATION_JSON)
.content(objectMapper.writeValueAsString(userJohn)))
.andExpect(jsonPath("$[0].username", is("bob")));
Using this import for the jsonPath:
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
I get:
andExpect (org.springframework.test.web.servlet.ResultMatcher) in ResultActions cannot be applied to (org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath)
If i try to cast it to (ResultMatcher) i get:
java.lang.ClassCastException: org.springframework.test.web.servlet.result.JsonPathResultMatchers cannot be cast to org.springframework.test.web.servlet.ResultMatcher
I'm using the version 2.0.4 of Spring boot. Any ideas of what can be the problem?
Thanks