AccessRightValidatorComparator implements Comparator<AccessRightValidator> { @Override public int compare(AccessRightValidator o1, AccessRightValidator o2) { if (!o1.getGroupId().equals(o2.getGroupId())) { return o1.getGroupId().compareTo(o2.getGroupId()); } if (!o1.getResource().getPath().equals(o2.getResource().getPath())) { return o1.getResource().getPath().compareTo(o2.getResource().getPath()); } return o1.getLabel().compareTo(o2.getLabel()); }  @Override int compare(AccessRightValidator o1, AccessRightValidator o2);  }
@Test public void compare_differentGroupIds() { assertTrue(comp.compare(validator1, validator2) < 0); assertTrue(comp.compare(validator2, validator1) > 0); }
@Test public void compare_sameGroupIdButdifferentPaths() { when(validator2.getGroupId()).thenReturn(GROUP1); assertTrue(comp.compare(validator1, validator2) < 0); assertTrue(comp.compare(validator2, validator1) > 0); }
@Test public void compare_sameGroupIdAndPathButdifferentLabel() { when(validator2.getGroupId()).thenReturn(GROUP1); when(resource2.getPath()).thenReturn(PATH1); assertTrue(comp.compare(validator1, validator2) < 0); assertTrue(comp.compare(validator2, validator1) > 0); }
@Test public void compare_allSame() { when(validator2.getGroupId()).thenReturn(GROUP1); when(resource2.getPath()).thenReturn(PATH1); when(validator2.getLabel()).thenReturn(LABEL1); assertTrue(comp.compare(validator1, validator2) == 0); }