I have been writing some simple unit testing routines for a simple spring web application. When I add @JsonIgnore annotation on a getter method of a resource, the resulting json
There is a difference between the property that is present, but having null
value, and the property not being present at all.
If the test should fail only when there is a non-null
value, use:
.andExpect(jsonPath("password").doesNotExist())
If the test should fail as soon as the property is present, even with a null
value, use:
.andExpect(jsonPath("password").doesNotHaveJsonPath())