SpringMVC/ mockMVC/ jsonpath compare list of strings

1) Instead of .andExpect(jsonPath(“$.data.roles.length”).value(correctRoles.size())); try .andExpect(jsonPath(“$.data.roles.length()”).value(correctRoles.size())); or .andExpect((jsonPath(“$.data.roles”, Matchers.hasSize(size)))); 2) Instead of for (AuthorityRole role : correctRoles) // doesn’t work actions.andExpect(jsonPath(“$.data.roles[?(@==’%s’)]”, role.toString()).exists()); try actions.andExpect((jsonPath(“$.data.roles”, Matchers.containsInAnyOrder(“role1”, “role2”, “role3”)))); Keep in mind that you have to add hamcrest-library.

How to use MockMvcResultMatchers.jsonPath

I think you need to pass the Matcher to the jsonPath method. For example. .andExpect(jsonPath(“$.version”, is(“0.1”))) References: http://docs.spring.io/spring/docs/3.2.x/javadoc-api/org/springframework/test/web/servlet/result/MockMvcResultMatchers.html#jsonPath(java.lang.String,%20org.hamcrest.Matcher) https://www.petrikainulainen.net/programming/spring-framework/integration-testing-of-spring-mvc-applications-write-clean-assertions-with-jsonpath/ SpringMVC/ mockMVC/ jsonpath compare list of strings

How to filter by string in JSONPath?

Your query looks fine, and your data and query work for me using this JsonPath parser. Also see the example queries on that page for more predicate examples. The testing tool that you’re using seems faulty. Even the examples from the JsonPath site are returning incorrect results: e.g., given: { “store”: { “book”: [ { … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)