### Question:
UploadEnrichmentTagOverwriter { public boolean shouldEnrichmentTagsBeOverwritten() { DateTime maxUploadEnrichmentTagCreationDate = uploadEnrichmentTagRepository.findMaxCreationDate(); if (maxUploadEnrichmentTagCreationDate != null) { DateTime maxEnrichmentTagCreationDate = enrichmentTagRepository.findMaxCreationDate(); if (maxEnrichmentTagCreationDate == null || maxUploadEnrichmentTagCreationDate.isAfter(maxEnrichmentTagCreationDate.getMillis())) { return true; } } return false; }  boolean shouldEnrichmentTagsBeOverwritten(); @Transactional void overwriteEnrichmentTags(); @Autowired void setUploadEnrichmentTagRepository(UploadEnrichmentTagRepository uploadEnrichmentTagRepository); @Autowired void setEnrichmentTagRepository(EnrichmentTagRepository enrichmentTagRepository); @Autowired void setUploadEnrichmentTagCopier(UploadEnrichmentTagCopier uploadEnrichmentTagCopier);  }### Answer:
@Test public void shouldEnrichmentTagsBeOverwritten_false_uploadTagMaxDate_isNull() { when(uploadEnrichmentTagRepository.findMaxCreationDate()).thenReturn(null); boolean shouldEnrichmentTagsBeOverwriten = uploadEnrichmentTagOverwriter.shouldEnrichmentTagsBeOverwritten(); assertFalse(shouldEnrichmentTagsBeOverwriten); verify(enrichmentTagRepository, never()).findMaxCreationDate(); }
@Test public void shouldEnrichmentTagsBeOverwritten_true_uploadTagMaxDate_isNotNull_tagMaxDate_isNull() { when(uploadEnrichmentTagRepository.findMaxCreationDate()).thenReturn(new DateTime(2012, 12, 12, 12, 13)); when(enrichmentTagRepository.findMaxCreationDate()).thenReturn(null); boolean shouldEnrichmentTagsBeOverwriten = uploadEnrichmentTagOverwriter.shouldEnrichmentTagsBeOverwritten(); assertTrue(shouldEnrichmentTagsBeOverwriten); }
@Test public void shouldEnrichmentTagsBeOverwritten_true_uploadTagMaxDate_isNotNull_tagMaxDate_isBefore() { when(uploadEnrichmentTagRepository.findMaxCreationDate()).thenReturn(new DateTime(2012, 12, 12, 12, 13)); when(enrichmentTagRepository.findMaxCreationDate()).thenReturn(new DateTime(2012, 12, 12, 12, 11, 23)); boolean shouldEnrichmentTagsBeOverwriten = uploadEnrichmentTagOverwriter.shouldEnrichmentTagsBeOverwritten(); assertTrue(shouldEnrichmentTagsBeOverwriten); }
@Test public void shouldEnrichmentTagsBeOverwritten_true_uploadTagMaxDate_isNotNull_tagMaxDate_isAfter() { when(uploadEnrichmentTagRepository.findMaxCreationDate()).thenReturn(new DateTime(2012, 12, 12, 12, 13)); when(enrichmentTagRepository.findMaxCreationDate()).thenReturn(new DateTime(2012, 12, 13, 12, 11, 23)); boolean shouldEnrichmentTagsBeOverwriten = uploadEnrichmentTagOverwriter.shouldEnrichmentTagsBeOverwritten(); assertFalse(shouldEnrichmentTagsBeOverwriten); }