ModifiedDateComparator implements Comparator<BaseEntity> { @Override public int compare(BaseEntity o1, BaseEntity o2) { if (order == SortOrder.ASCENDING) { return o1.getModified().compareTo(o2.getModified()); } else { return o2.getModified().compareTo(o1.getModified()); } } ModifiedDateComparator();  ModifiedDateComparator(SortOrder order); @Override int compare(BaseEntity o1, BaseEntity o2);  }
@Test @Tag(TestGroups.FUNCTIONAL) public void testClass() { BaseEntityImpl base1 = new BaseEntityImpl(); BaseEntityImpl base2 = new BaseEntityImpl(); base1.setModified(new Date()); base2.setModified(new Date(new Date().getTime() + 200)); ModifiedDateComparator cmptr = new ModifiedDateComparator(); assertTrue(cmptr.compare(base1, base2) < 0); ModifiedDateComparator cmptr2 = new ModifiedDateComparator(ModifiedDateComparator.SortOrder.DESCENDING); assertTrue(cmptr2.compare(base1, base2) > 0); }