Advertisement
nimchimpsky

jsonpath verification expecting a common dto

Aug 10th, 2013
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.74 KB | None | 0 0
  1. import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
  2. import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
  3.  
  4. private void expectDto(MockHttpServletRequestBuilder mockHttpServletRequestBuilder,
  5.                                             MyDto myDto) throws Exception {
  6.         MvcResult mvcResult = this.mockMvc.perform(mockHttpServletRequestBuilder)
  7. //              .andDo(print())
  8.                 .andExpect(status().isOk())
  9.                 .andExpect(jsonPath("$.id").value(myDto.getId()))
  10.                 .andExpect(jsonPath("$.name").value(myDto.getName()))
  11.                 .andExpect(jsonPath("$.finished").value(myDto.getFinished()))
  12.                 .andReturn();
  13.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement