### Question:
ImageComparator implements Comparator<Image>, Serializable { @Override public int compare(Image image1, Image image2) { return image1.getCreated() == null || image2.getCreated() == null ? image1.getDate().compareTo(image2.getDate()) : image1.getCreated().compareTo(image2.getCreated()); }  @Override int compare(Image image1, Image image2);  }### Answer:
@Test public void testEqualsWithCreationTime() { Image image1 = createMockImage("2020-06-08", Long.valueOf(1589562459)); Image image2 = createMockImage("2020-06-08", Long.valueOf(1589562459)); assertEquals(0L, underTest.compare(image1, image2)); }
@Test public void testEqualsWithDate() { Image image1 = createMockImage("2020-06-08", null); Image image2 = createMockImage("2020-06-08", null); assertEquals(0L, underTest.compare(image1, image2)); }
@Test public void testGreaterWithCreationTime() { Image image1 = createMockImage("2020-06-08", Long.valueOf(1589562459)); Image image2 = createMockImage("2020-03-12", Long.valueOf(1513861351)); assertEquals(1L, underTest.compare(image1, image2)); }
@Test public void testGreaterWithDate() { Image image1 = createMockImage("2020-06-24", null); Image image2 = createMockImage("2020-06-15", null); assertEquals(1L, underTest.compare(image1, image2)); }
@Test public void testSmallerWithCreationTime() { Image image1 = createMockImage("2020-06-15", Long.valueOf(1913560024)); Image image2 = createMockImage("2020-06-24", Long.valueOf(1934560145)); assertEquals(-1L, underTest.compare(image1, image2)); }
@Test public void testSmallerWithDate() { Image image1 = createMockImage("2020-06-15", null); Image image2 = createMockImage("2020-06-24", null); assertEquals(-1L, underTest.compare(image1, image2)); }