Testing JSON
Using this:
result = mockMvc.perform(get);Print JSON
result.andDo(MockMvcResultHandlers.print());Get JSON
result.andReturn().getResponse().getContentAsString();Check Number of Elements
result.andExpect(MockMvcResultMatchers.jsonPath("$.content", Matchers.hasSize(1)));Check String
result.andExpect(MockMvcResultMatchers.jsonPath("$.content", Matchers.equalTo("text")));result.andExpect(MockMvcResultMatchers.content().string("text"));Last updated
Was this helpful?