I'm using Spring Data Rest with a custom controller.
The custom controller overrides only the PATCH/PUT and POST verbs.
@ExtendWith(SpringExtension.class)
@WebMvcTest(UserController.class)
public class UserControllerTests {
@Autowired
MockMvc mockMvc;
@Test
public void updateTest() throws Exception {
RequestBuilder request = MockMvcRequestBuilders
.patch("/api/v1/users/1")
.contentType(MediaType.APPLICATION_JSON)
.content(updateString);
MvcResult result = mockMvc.perform(request)
.andExpect(status().isAccepted())
.andExpect(content().json(updateString))
.andReturn();
}
}
For some reason mockMvc.perform
always return a 404 but I expect a 204. How to fix this?