### Question:
SetFullTextFilter implements IndexDocumentFilter { @Override public void filter(DocumentIndexingPackage dip) throws IndexingException { ContentObject contentObj = dip.getContentObject(); if (!(contentObj instanceof WorkObject) && !(contentObj instanceof FileObject)) { return; } FileObject fileObj = getFileObject(dip); if (fileObj == null) { return; } BinaryObject binObj; binObj = fileObj.getOriginalFile(); if (!binObj.getMimetype().contains("text")) { return; } try { String fullText = IOUtils.toString(binObj.getBinaryStream(), "UTF-8"); dip.getDocument().setFullText(fullText); } catch (FedoraException | IOException e) { throw new IndexingException("Failed to retrieve full text datastream for {}" + dip.getPid(), e); } }  @Override void filter(DocumentIndexingPackage dip);  }### Answer:
@Test public void testFullTextWithWorkObject() throws Exception { when(dip.getContentObject()).thenReturn(workObj); when(workObj.getPrimaryObject()).thenReturn(fileObj); filter.filter(dip); verify(idb).setFullText(stringCaptor.capture()); assertEquals(fullText, stringCaptor.getValue()); }
@Test public void testFullTextWithFileObject() throws Exception { when(dip.getContentObject()).thenReturn(fileObj); filter.filter(dip); verify(idb).setFullText(stringCaptor.capture()); assertEquals(fullText, stringCaptor.getValue()); }
@Test public void testNoFullText() throws Exception { when(dip.getContentObject()).thenReturn(fileObj); when(binObj.getMimetype()).thenReturn("application/json"); filter.filter(dip); verify(idb, never()).setFullText(anyString()); }
@Test (expected = IndexingException.class) public void testBadInputStream() throws Exception { when(dip.getContentObject()).thenReturn(fileObj); doThrow(new FedoraException("Mocking error getting binary stream")).when(binObj).getBinaryStream(); filter.filter(dip); }