I would like to assert json output from rest controller, but I get "Expected: null but: was <[null]>". This is my testing code:
mockMvc.perform(post(TEST_ENDPOINT)
.param("someParam", SOMEPARAM)
.andDo(print())
.andExpect(status().is2xxSuccessful())
.andExpect(jsonPath("*.errorMessage").value(IsNull.nullValue()));
Json:
{
"some_string": {
"errorMessage": null
}
}
I found similar question How to assertThat something is null with Hamcrest?, but neither answers do work. Maybe this is due to jsonPath, cause it return null value in [] brackets? Is it bug of asserting framework?