### Question:
SetRelationsFilter implements IndexDocumentFilter { @Override public void filter(DocumentIndexingPackage dip) throws IndexingException { log.debug("Applying setRelationsFilter"); List<String> relations = new ArrayList<>(); ContentObject contentObj = dip.getContentObject(); if (contentObj instanceof WorkObject) { FileObject primaryObj = ((WorkObject) contentObj).getPrimaryObject(); if (primaryObj != null) { relations.add(Cdr.primaryObject.toString() + "|" + primaryObj.getPid().getId()); } } List<String> invalidTerms = new ArrayList<>(); StmtIterator it = contentObj.getResource().listProperties(Cdr.invalidTerm); while (it.hasNext()) { invalidTerms.add(it.nextStatement().getLiteral().getString()); } String invalidTermPred = Cdr.invalidTerm.toString(); if (invalidTerms != null) { for (String invalidTermTriple : invalidTerms) { relations.add(invalidTermPred + "|" + invalidTermTriple); } } dip.getDocument().setRelations(relations); }  @Override void filter(DocumentIndexingPackage dip);  }### Answer:
@Test public void setPrimaryObjectFromWorkTest() throws Exception { when(dip.getContentObject()).thenReturn(workObj); String primObjPid = "pofromwork"; when(pid.getId()).thenReturn(primObjPid); filter.filter(dip); verify(idb).setRelations(listCaptor.capture()); assertTrue(listCaptor.getValue().contains("http: }
@Test public void setInvalidTermsTest() throws Exception { when(dip.getContentObject()).thenReturn(workObj); filter.filter(dip); verify(idb).setRelations(listCaptor.capture()); assertTrue(listCaptor.getValue().contains("http: }