### Question:
ExtractFile { public boolean generateArchive() { boolean success = true; TarArchiveOutputStream tarArchiveOutputStream = null; MultiOutputStream multiOutputStream = new MultiOutputStream(); try { for(String app : clientKeys.keySet()){ SecurityEvent event = securityEventUtil.createSecurityEvent(this.getClass().getName(), "Writing extract file to the file system", LogLevelType.TYPE_INFO, app, BEMessageCode.BE_SE_CODE_0022, app); event.setTargetEdOrgList(edorg); audit(event); multiOutputStream.addStream(getAppStream(app)); } tarArchiveOutputStream = new TarArchiveOutputStream(multiOutputStream); archiveFile(tarArchiveOutputStream, manifestFile.getFile()); File errors = errorFile.getFile(); if (errors != null) { archiveFile(tarArchiveOutputStream, errors); } for (JsonFileWriter dataFile : dataFiles.values()) { File df = dataFile.getFile(); if (df != null && df.exists()) { archiveFile(tarArchiveOutputStream, df); } } } catch (Exception e) { SecurityEvent event = securityEventUtil.createSecurityEvent(this.getClass().getName(), "Writing extract file to the file system", LogLevelType.TYPE_ERROR, BEMessageCode.BE_SE_CODE_0023); event.setTargetEdOrgList(edorg); audit(event); LOG.error("Error writing to tar file: {}", e.getMessage()); success = false; for(File archiveFile : archiveFiles.values()){ FileUtils.deleteQuietly(archiveFile); } } finally { IOUtils.closeQuietly(tarArchiveOutputStream); FileUtils.deleteQuietly(tempDir); } return success; } ExtractFile(File parentDir, String archiveName, Map<String, PublicKey> clientKeys, SecurityEventUtil securityEventUtil); JsonFileWriter getDataFileEntry(String filePrefix); void closeWriters(); ManifestFile getManifestFile(); ErrorFile getErrorLogger(); boolean generateArchive(); boolean finalizeExtraction(DateTime startTime); String getFileName(String appId); Map<String, File> getArchiveFiles(); Map<String, PublicKey> getClientKeys(); void setClientKeys(Map<String, PublicKey> clientKeys); String getEdorg(); void setEdorg(String edorg);  }### Answer:
@Test public void generateArchiveTest() throws Exception { String fileName = archiveFile.getFileName(testApp); archiveFile.generateArchive(); TarArchiveInputStream tarInputStream = null; List<String> names = new ArrayList<String>(); File decryptedFile = null; try { decryptedFile = decrypt(new File(fileName)); tarInputStream = new TarArchiveInputStream(new FileInputStream(decryptedFile)); TarArchiveEntry entry = null; while((entry = tarInputStream.getNextTarEntry())!= null) { names.add(entry.getName()); } } finally { IOUtils.closeQuietly(tarInputStream); } Assert.assertEquals(2, names.size()); Assert.assertTrue("Student extract file not found", names.get(1).contains("student")); Assert.assertTrue("Metadata file not found", names.get(0).contains("metadata")); FileUtils.deleteQuietly(decryptedFile); }