### Question:
JudgmentContentFileExtractor { public InputStreamWithFilename extractJudgmentContent(File archiveFile, String judgmentSourceId) throws IOException { if (FilenameUtils.getExtension(archiveFile.getName()).equals("zip")) { ZipFile file = null; file = new ZipFile(archiveFile); final Enumeration<? extends ZipEntry> entries = file.entries(); while(entries.hasMoreElements()) { final ZipEntry entry = entries.nextElement(); if (FilenameUtils.getBaseName(entry.getName()).equals(judgmentSourceId)) { return new ZipEntryBasedInputStreamWithFilename(file, entry); } } file.close(); throw new ImportException("Content for judgment with sourceId " + judgmentSourceId + " not found in file " + archiveFile.getName()); } throw new ImportException("File " + archiveFile.getName() + " is of type that is not supported"); }  InputStreamWithFilename extractJudgmentContent(File archiveFile, String judgmentSourceId);  }### Answer:
@Test public void extractJudgmentContent() throws IOException { String archivePath = PathResolver.resolveToAbsolutePath("import/content/judgmentContent.zip"); String judgmentContentPath = PathResolver.resolveToAbsolutePath("import/content/3b42a6299303c65d869c4806fdcdbf7a.doc"); InputStreamWithFilename judgmentContent = judgmentContentFileExtractor.extractJudgmentContent(new File(archivePath), "3b42a6299303c65d869c4806fdcdbf7a"); assertEquals("3b42a6299303c65d869c4806fdcdbf7a.doc", judgmentContent.getFilename()); InputStream expectedFileStream = null; try { expectedFileStream = new FileInputStream(new File(judgmentContentPath)); assertTrue(IOUtils.contentEquals(judgmentContent.getInputStream(), expectedFileStream)); } finally { IOUtils.closeQuietly(judgmentContent); IOUtils.closeQuietly(expectedFileStream); } }
@Test(expected = ImportException.class) public void extractJudgmentContent_NOT_FOUND() throws IOException { String archivePath = PathResolver.resolveToAbsolutePath("import/content/judgmentContent.zip"); judgmentContentFileExtractor.extractJudgmentContent(new File(archivePath), "notExistingSourceId"); }