Unzipper { public void unzipAllArchivesInDirectory(File temporaryFolder, File stagingDirectory) throws IOException { for (File file : temporaryFolder.listFiles(new OnlyZips())) { ZipFile zipFile = new ZipFile(file); Enumeration<? extends ZipEntry> entries = zipFile.entries(); while (entries.hasMoreElements()) { ZipEntry entry = entries.nextElement(); InputStream inputStream = zipFile.getInputStream(entry); File contentFile = new File(stagingDirectory, entry.getName()); FileOutputStream outputStream = new FileOutputStream(contentFile); IOUtils.copy(inputStream, outputStream); targetInstallation.addContent(new FileDataInVersion(contentFile)); outputStream.close(); } zipFile.close(); } } Unzipper(Installation targetInstallation); void unzipAllArchivesInDirectory(File temporaryFolder, File stagingDirectory);  }
@Test public void unzipsArchivesAndForwardsEntriesToWrapped() throws Exception { final File content = ZipFileMother.createContentFileForZip(folder.getRoot()); File sourceFolder = folder.newFolder("source"); File targetFolder = folder.newFolder("target"); ZipFileMother.createZipFileInTemporaryFolder(sourceFolder, "iAmA.zip", content); unzipper.unzipAllArchivesInDirectory(sourceFolder, targetFolder); ArgumentCaptor<DataInVersion> captor = ArgumentCaptor.forClass(DataInVersion.class); verify(wrapped).addContent(captor.capture()); DataInVersion installedData = captor.getValue(); File checkoutFolder = folder.newFolder(); installedData.storeIn(checkoutFolder); assertThatFilesAreSimilar(content, checkoutFolder.listFiles()[0]); }