Guest User

Untitled

a guest
Nov 22nd, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. @Test
  2. public void getAll() throws Exception {
  3. String url = "/permissions/all";
  4. int size = 4;
  5. try {
  6. Set<String> permissions = RandomGenerator.randomStrings(size);
  7. initDb(permissions);
  8. mvc.perform(get(url).with(Users.PERMISSIONS_READ))
  9. .andExpect(jsonPath("$[?(@.name)].name", hasSize(size))) //ok
  10. .andExpect(jsonPath("$[?(@.name)].name").value(containsInAnyOrder(permissions))); //exception
  11. } finally {
  12. dropDb();
  13. }
  14. }
  15.  
  16. java.lang.AssertionError: JSON path "$[?(@.name)].name"
  17.  
  18. Expected: iterable over [<[b0ce9e8a-8b62-41f4-91b9-d9cf6ff96675, 7ebe3a4f-7864-4ea5-92b3-a5ad6f44bf42, 7df2fa88-b22f-4d33-91b2-f8b00813522f, 17b61119-c48c-4dff-ac9c-047eb3efcc43]>] in any order
  19. but: Not matched: "7df2fa88-b22f-4d33-91b2-f8b00813522f"
  20.  
  21. [{
  22. "id": 1,
  23. "name": "7df2fa88-b22f-4d33-91b2-f8b00813522f"
  24. }, {
  25. "id": 2,
  26. "name": "b0ce9e8a-8b62-41f4-91b9-d9cf6ff96675"
  27. }, {
  28. "id": 3,
  29. "name": "7ebe3a4f-7864-4ea5-92b3-a5ad6f44bf42"
  30. }, {
  31. "id": 4,
  32. "name": "17b61119-c48c-4dff-ac9c-047eb3efcc43"
  33. }]
  34.  
  35. [
  36. "7df2fa88-b22f-4d33-91b2-f8b00813522f",
  37. "b0ce9e8a-8b62-41f4-91b9-d9cf6ff96675",
  38. "7ebe3a4f-7864-4ea5-92b3-a5ad6f44bf42",
  39. "17b61119-c48c-4dff-ac9c-047eb3efcc43"
  40. ]
Add Comment
Please, Sign In to add comment