Advertisement
Guest User

Untitled

a guest
Apr 22nd, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. class User {
  2. private int id;
  3. private String email;
  4.  
  5. User(int id, String email) {
  6. this.id = id
  7. this.email = email
  8. }
  9.  
  10. // equals, hashcode
  11. }
  12.  
  13. @Test
  14. public void assertUsers() {
  15. Set<User> expected = new HashSet<>() {
  16. {
  17. add(new User(1, "1@qwerty.com"));
  18. add(new User(3, "2@qwerty.com"));
  19. add(new User(5, "3@qwerty.com"));
  20. add(new User(7, "4@qwerty.com"));
  21. }
  22. }
  23.  
  24. Set<User> actual = new HashSet<>() {
  25. {
  26. add(new User(2, "1@qwerty.com"));
  27. add(new User(4, "2@qwerty.com"));
  28. add(new User(6, "3@qwerty.com"));
  29. add(new User(8, "4@qwerty.com"));
  30. }
  31. }
  32.  
  33. assertEquals(expected, actual); // should return true
  34.  
  35. }
  36.  
  37. class IdConverter {
  38. // internal id - external id
  39. public static Map<Integer, Integer> getIdRelation() {
  40. Map<Integer, Integer> id_relation = new HashMap<>();
  41. id_relation.put(1, 2);
  42. id_relation.put(3, 4);
  43. id_relation.put(5, 6);
  44. id_relation.put(7, 8);
  45. return id_relation;
  46. }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement