### Question:
DocumentIndexingPackageDataLoader { public Element loadMods(DocumentIndexingPackage dip) throws IndexingException { ContentObject contentObj = getContentObject(dip); BinaryObject modsBinary = contentObj.getDescription(); if (modsBinary == null) { return null; } try (InputStream modsStream = modsBinary.getBinaryStream()) { Document dsDoc = createSAXBuilder().build(modsStream); return dsDoc.detachRootElement(); } catch (JDOMException | IOException e) { throw new IndexingException("Failed to parse MODS stream for object " + dip.getPid(), e); } }  Element loadMods(DocumentIndexingPackage dip); ContentObject getContentObject(DocumentIndexingPackage dip); long getCacheTimeToLive(); void setCacheTimeToLive(long cacheTimeToLive); long getCacheMaxSize(); void setCacheMaxSize(long cacheMaxSize); void setRepositoryObjectLoader(RepositoryObjectLoader repoObjLoader);  }### Answer:
@Test public void testLoadMods() throws Exception { InputStream modsStream = new FileInputStream(new File( "src/test/resources/datastream/inventoryMods.xml")); when(repoObjLoader.getRepositoryObject(eq(pid))).thenReturn(contentObj); when(contentObj.getDescription()).thenReturn(modsBinary); when(modsBinary.getBinaryStream()).thenReturn(modsStream); Element modsElement = dataLoader.loadMods(dip); assertNotNull(modsElement); assertEquals("mods", modsElement.getName()); verify(repoObjLoader).getRepositoryObject(any(PID.class)); }
@Test public void testLoadNoMods() throws Exception { when(repoObjLoader.getRepositoryObject(eq(pid))).thenReturn(contentObj); when(contentObj.getDescription()).thenReturn(null); Element modsElement = dataLoader.loadMods(dip); assertNull(modsElement); verify(repoObjLoader).getRepositoryObject(any(PID.class)); }
@Test(expected = IndexingException.class) public void testLoadBadMods() throws Exception { InputStream badModsStream = new ByteArrayInputStream("<mods:mod".getBytes()); when(repoObjLoader.getRepositoryObject(eq(pid))).thenReturn(contentObj); when(contentObj.getDescription()).thenReturn(modsBinary); when(modsBinary.getBinaryStream()).thenReturn(badModsStream); dataLoader.loadMods(dip); }