I am currently writing some unit tests for a Spring MVC project. As the returned media type is JSON, I try to use jsonPath to check if the correct values are returned.
Here is what I ended up using:
.andExpect(jsonPath('$.data.roles').value(Matchers.hasSize(size)))
and
.andExpect(jsonPath('$.data.roles').value(Matchers.containsInAnyOrder("role1", "role2", "role3")))