This is my method inside my controller which is annotated by @Controller
@RequestMapping(value = \"/getServerAlertFilters/{serverName}/\", produ
I use TestNG for my unit testing. But in Spring Test Framework they both looks similar. So I believe your test be like below
@Test
public void testAlertFilterView() throws Exception {
this.mockMvc.perform(get("/getServerAlertFilters/v2v2v2/").
.andExpect(status().isOk())
.andExpect(content().json("{'data':[{'useRegEx':'false','hosts':'v2v2v2'}]}"));
}
If you want check check json Key and value you can use jsonpath
.andExpect(jsonPath("$.yourKeyValue", is("WhatYouExpect")));
You might find thatcontent().json()
are not solveble please add
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;