RecentPresentation extends File implements Comparable<File> { @Override public int compareTo(File o) { if (o != null && o instanceof RecentPresentation) { final RecentPresentation other = (RecentPresentation) o; return this.getNormalizedPath().compareTo(other.getNormalizedPath()); } return 1; } RecentPresentation(final String path, final LocalDateTime openedDateTime); LocalDateTime getOpenedDateTime(); void setOpenedDateTime(LocalDateTime openedDateTime); String getId(); String getNormalizedPath(); @Override boolean equals(Object o); @Override int hashCode(); @Override int compareTo(File o);  }
@Test @DisplayName("is greater than a null one") void compareToNull() { final RecentPresentation presentation = new RecentPresentation("presentation1.sfx", null); assertTrue(presentation.compareTo(null) > 0); }
@Test @DisplayName("is greater than another") void compareToGreaterThanAnother() { final RecentPresentation presentation1 = new RecentPresentation("presentation1.sfx", null); final RecentPresentation presentation2 = new RecentPresentation("presentation2.sfx", null); assertTrue(presentation2.compareTo(presentation1) > 0); }
@Test @DisplayName("is greater than another") void compareToLowerThanAnother() { final RecentPresentation presentation1 = new RecentPresentation("presentation1.sfx", null); final RecentPresentation presentation2 = new RecentPresentation("presentation2.sfx", null); assertTrue(presentation1.compareTo(presentation2) < 0); }
@Test @DisplayName("is equal to itself using compareTo") void compareToIsEqual() { final RecentPresentation presentation1 = new RecentPresentation("presentation1.sfx", null); assertEquals(0, presentation1.compareTo(presentation1)); }