### Question:
SetContentStatusFilter implements IndexDocumentFilter { @Override public void filter(DocumentIndexingPackage dip) throws IndexingException { List<String> contentStatus = determineContentStatus(dip); dip.getDocument().setContentStatus(contentStatus); log.debug("Content status for {} set to {}", dip.getPid().toString(), contentStatus); }  @Override void filter(DocumentIndexingPackage dip);  }### Answer:
@Test public void testDescribedWork() throws Exception { when(dip.getContentObject()).thenReturn(workObj); when(workObj.getResource()).thenReturn(resc); when(resc.hasProperty(Cdr.hasMods)).thenReturn(true); filter.filter(dip); verify(idb).setContentStatus(listCaptor.capture()); assertTrue(listCaptor.getValue().contains(FacetConstants.CONTENT_DESCRIBED)); assertFalse(listCaptor.getValue().contains(FacetConstants.CONTENT_NOT_DESCRIBED)); }
@Test public void testNotDescribedWork() throws Exception { when(dip.getContentObject()).thenReturn(workObj); when(workObj.getResource()).thenReturn(resc); filter.filter(dip); verify(idb).setContentStatus(listCaptor.capture()); assertTrue(listCaptor.getValue().contains(FacetConstants.CONTENT_NOT_DESCRIBED)); assertFalse(listCaptor.getValue().contains(FacetConstants.CONTENT_DESCRIBED)); }
@Test public void testWorkNoPrimaryObject() throws Exception { when(dip.getContentObject()).thenReturn(workObj); when(workObj.getResource()).thenReturn(resc); filter.filter(dip); verify(idb).setContentStatus(listCaptor.capture()); assertTrue(listCaptor.getValue().contains(FacetConstants.NO_PRIMARY_OBJECT)); }
@Test public void testFolderNoPrimaryObject() throws Exception { when(dip.getContentObject()).thenReturn(folderObj); when(folderObj.getResource()).thenReturn(resc); filter.filter(dip); verify(idb).setContentStatus(listCaptor.capture()); assertFalse(listCaptor.getValue().contains(FacetConstants.NO_PRIMARY_OBJECT)); }
@Test public void testWorkWithPrimaryObject() throws Exception { when(dip.getContentObject()).thenReturn(workObj); when(workObj.getResource()).thenReturn(resc); when(resc.hasProperty(Cdr.primaryObject)).thenReturn(true); filter.filter(dip); verify(idb).setContentStatus(listCaptor.capture()); assertTrue(listCaptor.getValue().contains(FacetConstants.HAS_PRIMARY_OBJECT)); assertFalse(listCaptor.getValue().contains(FacetConstants.NO_PRIMARY_OBJECT)); }
@Test public void testIsPrimaryObject() throws Exception { when(workObj.getResource()).thenReturn(resc); when(resc.hasProperty(Cdr.primaryObject, fileResc)).thenReturn(true); when(dip.getContentObject()).thenReturn(fileObj); when(fileObj.getResource()).thenReturn(fileResc); filter.filter(dip); verify(idb).setContentStatus(listCaptor.capture()); assertTrue(listCaptor.getValue().contains(FacetConstants.IS_PRIMARY_OBJECT)); }
@Test public void testWorkWithInvalidTerm() throws Exception { when(dip.getContentObject()).thenReturn(workObj); when(workObj.getResource()).thenReturn(resc); when(resc.hasProperty(Cdr.invalidTerm)).thenReturn(true); filter.filter(dip); verify(idb).setContentStatus(listCaptor.capture()); assertTrue(listCaptor.getValue().contains(FacetConstants.INVALID_VOCAB_TERM)); }
@Test public void testUnpublishedFileObject() throws Exception { when(workObj.getResource()).thenReturn(resc); when(dip.getContentObject()).thenReturn(fileObj); when(fileObj.getResource()).thenReturn(fileResc); when(fileResc.hasProperty(Cdr.unpublished)).thenReturn(true); filter.filter(dip); verify(idb).setContentStatus(listCaptor.capture()); }