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.