### Question:
SetObjectTypeFilter implements IndexDocumentFilter { @Override public void filter(DocumentIndexingPackage dip) throws IndexingException { IndexDocumentBean idb = dip.getDocument(); ContentObject contentObj = dip.getContentObject(); List<String> types = contentObj.getTypes(); ResourceType resourceType = ResourceType.getResourceTypeForUris(types); if (resourceType == null) { throw new IndexingException("Object " + dip.getPid() + " could not be indexed, it did not have a valid resource type"); } idb.setResourceType(resourceType.name()); idb.setResourceTypeSort(resourceType.getDisplayOrder()); }  @Override void filter(DocumentIndexingPackage dip);  }### Answer:
@Test public void testWorkResourceType() throws Exception { when(contentObj.getTypes()).thenReturn(Arrays.asList(Cdr.Work.getURI())); filter.filter(dip); verify(idb).setResourceType(eq(ResourceType.Work.name())); verify(idb).setResourceTypeSort(eq(ResourceType.Work.getDisplayOrder())); }
@Test public void testMultipleRdfTypes() throws Exception { when(contentObj.getTypes()).thenReturn(Arrays.asList( Fcrepo4Repository.Resource.getURI(), Fcrepo4Repository.Container.getURI(), Cdr.AdminUnit.getURI())); filter.filter(dip); verify(idb).setResourceType(eq(ResourceType.AdminUnit.name())); verify(idb).setResourceTypeSort(eq(ResourceType.AdminUnit.getDisplayOrder())); }
@Test(expected = IndexingException.class) public void testNoResourceType() throws Exception { when(contentObj.getTypes()).thenReturn(Collections.emptyList()); filter.filter(dip); }
@Test(expected = IndexingException.class) public void testBadResourceType() throws Exception { when(contentObj.getTypes()).thenReturn(Arrays.asList("http: filter.filter(dip); }