I am testing a Spring controller that can return 400 field errors. These field errors are an array of objects containing the path and message fields.
Now I want to check that a particular call returns several errors with a specific path and message.
I can not come closer than below:
.andExpect(jsonPath("$.fieldErrors[*].path", containsInAnyOrder("title", "description")))
.andExpect(jsonPath("$.fieldErrors[*].message", containsInAnyOrder(
"The maximum length of the description is 500 characters.",
"The maximum length of the title is 100 characters.")));
But this allows you to open the option that bad combinations of "path" and "message" are accepted.
Any ideas on improving jsonpath to check this out?
source
share