As part of my JHipster-generated Spring Boot app, I'm trying to adapt an integration test to ensure that the return JSON object contains null for a particular property:
import static org.springframework.test.web.servlet.ResultActions.*;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
.andExpect(jsonPath("$.selectedChannels[0].channelValue")
.doesNotExist())
This doesn't seem to work. For the response:
{
"selectedChannels": [{
"name": "test channel",
"channelValue": null
}]
}
I would get a response:
java.lang.AssertionError: Expected no value at JSON path "$.selectedChannels[0].channelValue" but found: [null]
I suppose the "doesNotExist" call is trying to make sure that the key does not exist. I tried using "value" as well with a null value but this just throws a NPE. How do I perform this assertion successfully?