### Question:
DuplicateDetector { protected boolean testForDuplicateAge(SearchResultItem result1, SearchResultItem result2, float duplicateAgeThreshold) { Instant date1 = result1.getBestDate(); Instant date2 = result2.getBestDate(); if (date1 == null || date2 == null) { logger.debug(LoggingMarkers.DUPLICATES, "At least one result has no usenet date and no pub date"); return false; } boolean isSameAge = Math.abs(date1.getEpochSecond() - date2.getEpochSecond()) / (60 * 60) <= duplicateAgeThreshold; logger.debug(LoggingMarkers.DUPLICATES, "Same age: {}", isSameAge); return isSameAge; }  DuplicateDetectionResult detectDuplicates(Set<SearchResultItem> results);  }### Answer:
@Test public void shouldUseUsenetDateForComparison() throws Exception { SearchResultItem item1 = new SearchResultItem(); setValues(item1, "1", "poster1", "group", Instant.now()); item1.setPubDate(Instant.now().minus(100, ChronoUnit.DAYS)); SearchResultItem item2 = new SearchResultItem(); setValues(item2, "2", "poster1", "group", Instant.now()); item2.setPubDate(Instant.now().minus(300, ChronoUnit.DAYS)); item1.setUsenetDate(Instant.now()); item2.setUsenetDate(Instant.now()); assertThat(testee.testForDuplicateAge(item1, item2, 1F)).isTrue(); item2.setUsenetDate(null); assertThat(testee.testForDuplicateAge(item1, item2, 1F)).isFalse(); }