Tests with MockMvc

0

Someone knows how to pass a "null" value in the content method of a put request.

Follow the example:

@Autowired
private MockMvc mvc;

@Autowired
private ObjectMapper objectMapper;

@Test
public void testUpdateDtoNull() throws Exception {
    Long id = subUnidadeExercicioDao.findAll().stream().findFirst().get().getId();
    mvc.perform(put("/api/test/" + id)
            .contentType(MediaType.APPLICATION_JSON)
            .content(null)
    )

            .andExpect(status().isOk())
            .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON_UTF8))
            .andExpect(jsonPath("$.status", is(400)))
            .andExpect(jsonPath("$.warns", is("Nenhum registro encontrado")))
            .andReturn();

}
    
asked by anonymous 07.02.2018 / 16:00

0 answers