How can I write a test case for boolean in mockito, spring mvc environment
For example, the following answer
MockHttpServletResponse:
Status = 200
Error message = null
Headers = {Content-Type=[application/json;charset=UTF-8]}
Content type = application/json;charset=UTF-8
Body = {"name":"myName","DOB":"12345"}
Forwarded URL = null
Redirected URL = null
Cookies = []
We will write a test case, for example,
mockMvc.perform(get("/reqMapping/methodName"))
.andExpect(status().isOk())
.andExpect(content().contentType("application/json;charset=UTF-8"))
.andExpect(jsonPath("$.name",comparesEqualTo("myName");
.andExpect(jsonPath("$.DOB",comparesEqualTo("12345");
Correctly? But, when we received the answer, as it should
MockHttpServletResponse:
Status = 200
Error message = null
Headers = {Content-Type=[application/json;charset=UTF-8]}
Content type = application/json;charset=UTF-8
**Body = true**
Forwarded URL = null
Redirected URL = null
Cookies = []
How to write a test case?
mockMvc.perform(get("/reqMapping/methodName"))
.andExpect(status().isOk())
.andExpect(content().contentType("application/json;charset=UTF-8"))
.andExpect(???);
source
share