@Test public void testCompareWhenGroupAndPersonHaveDifferentDates() { Calendar cal = Calendar.getInstance(); Date newer = cal.getTime(); cal.add(Calendar.HOUR, -1); Date earlier = cal.getTime(); PersonModelView pmv = new PersonModelView(1L, "persona", "Person", "A", "hey now", "", 40, earlier, 7L); DomainGroupModelView gmv = new DomainGroupModelView(1L, "groupb", "Group B", 50L, newer, 8L); Assert.assertTrue(sut.compare(pmv, gmv) > 0); Assert.assertTrue(sut.compare(gmv, pmv) < 0); }
@Override public int compare(final StreamDTO inA, final StreamDTO inB) { if (inA.getDateAdded().compareTo(inB.getDateAdded()) == 0) { if (inA.getEntityType() == EntityType.GROUP && inB.getEntityType() == EntityType.PERSON) { return -1; } if (inA.getEntityType() == EntityType.PERSON && inB.getEntityType() == EntityType.GROUP) { return 1; } return 0; } return inB.getDateAdded().compareTo(inA.getDateAdded()); }
StreamDTODateAddedDescendingComparator implements Comparator<StreamDTO> { @Override public int compare(final StreamDTO inA, final StreamDTO inB) { if (inA.getDateAdded().compareTo(inB.getDateAdded()) == 0) { if (inA.getEntityType() == EntityType.GROUP && inB.getEntityType() == EntityType.PERSON) { return -1; } if (inA.getEntityType() == EntityType.PERSON && inB.getEntityType() == EntityType.GROUP) { return 1; } return 0; } return inB.getDateAdded().compareTo(inA.getDateAdded()); } }
StreamDTODateAddedDescendingComparator implements Comparator<StreamDTO> { @Override public int compare(final StreamDTO inA, final StreamDTO inB) { if (inA.getDateAdded().compareTo(inB.getDateAdded()) == 0) { if (inA.getEntityType() == EntityType.GROUP && inB.getEntityType() == EntityType.PERSON) { return -1; } if (inA.getEntityType() == EntityType.PERSON && inB.getEntityType() == EntityType.GROUP) { return 1; } return 0; } return inB.getDateAdded().compareTo(inA.getDateAdded()); }  }
StreamDTODateAddedDescendingComparator implements Comparator<StreamDTO> { @Override public int compare(final StreamDTO inA, final StreamDTO inB) { if (inA.getDateAdded().compareTo(inB.getDateAdded()) == 0) { if (inA.getEntityType() == EntityType.GROUP && inB.getEntityType() == EntityType.PERSON) { return -1; } if (inA.getEntityType() == EntityType.PERSON && inB.getEntityType() == EntityType.GROUP) { return 1; } return 0; } return inB.getDateAdded().compareTo(inA.getDateAdded()); }  @Override int compare(final StreamDTO inA, final StreamDTO inB); }
StreamDTODateAddedDescendingComparator implements Comparator<StreamDTO> { @Override public int compare(final StreamDTO inA, final StreamDTO inB) { if (inA.getDateAdded().compareTo(inB.getDateAdded()) == 0) { if (inA.getEntityType() == EntityType.GROUP && inB.getEntityType() == EntityType.PERSON) { return -1; } if (inA.getEntityType() == EntityType.PERSON && inB.getEntityType() == EntityType.GROUP) { return 1; } return 0; } return inB.getDateAdded().compareTo(inA.getDateAdded()); }  @Override int compare(final StreamDTO inA, final StreamDTO inB);  }