### Question:
SetRecordDatesFilter implements IndexDocumentFilter { @Override public void filter(DocumentIndexingPackage dip) throws IndexingException { ContentObject obj = dip.getContentObject(); Resource resc = obj.getResource(); String dateAdded = resc.getProperty(Fcrepo4Repository.created).getLiteral().getValue().toString(); String dateUpdated = resc.getProperty(Fcrepo4Repository.lastModified).getLiteral().getValue().toString(); try { dip.getDocument().setDateAdded(dateAdded); dip.getDocument().setDateUpdated(dateUpdated); } catch (IllegalArgumentException | ParseException e) { throw new IndexingException("Failed to parse record dates from " + dip.getPid(), e); } }  @Override void filter(DocumentIndexingPackage dip);  }### Answer:
@Test public void testCreateDate() throws Exception { filter.filter(dip); assertEquals(DATE_ADDED, new SimpleDateFormat("yyyy-MM-dd").format(idb.getDateAdded())); }
@Test public void testUpdateDate() throws Exception { filter.filter(dip); assertEquals(DATE_MODIFIED, new SimpleDateFormat("yyyy-MM-dd").format(idb.getDateUpdated())); }
@Test public void testUnparseableDate() throws Exception { expectedEx.expect((IndexingException.class)); expectedEx.expectMessage("Failed to parse record dates from "); when(object2.toString()).thenReturn(BAD_DATE); filter.filter(dip); }