### Question:
ArchiveService { public void unzip(MultipartFile file, File destination) throws IOException { if (file.isEmpty()) { log.warn("The given ZIP file is empty !"); } this.unzip(file.getInputStream(), destination); }  void unzip(MultipartFile file, File destination); void unzip(InputStream inputStream, File destination);  }### Answer:
@Test public void unzip_ShouldUnzipTheGivenZip() throws IOException, URISyntaxException { File targetDir = new File(System.getProperty("java.io.tmpdir"), "ara-unzip_ShouldUnzipTheGivenZip_" + String.valueOf(new Date().getTime())); File folderTargetDir = new File(targetDir, "folder"); File subfolderTargetDir = new File(folderTargetDir, "sub-folder"); String zipName = "files-in-folders.zip"; URI zipURI = ClassLoader.getSystemResource("postman/" + zipName).toURI(); byte[] content = Files.readAllBytes(Paths.get(zipURI)); MultipartFile zipFile = new MockMultipartFile("zip", zipName, ZIP_TYPE, content); try { this.cut.unzip(zipFile, targetDir); Assertions.assertThat(targetDir.list()).contains("root-file1.json", "root-file2.json"); Assertions.assertThat(folderTargetDir.list()).contains("sub-file1.json", "sub-file2.json"); Assertions.assertThat(subfolderTargetDir.list()).contains("sub-sub-file1.json", "sub-sub-file2.json"); } finally { FileUtils.deleteQuietly(targetDir); } }
@Test public void unzip_ShouldNotSendIOException_IfZipFileEmpty() throws IOException { File targetDir = new File(System.getProperty("java.io.tmpdir"), "ara-unzip_ShouldSendIOException_IfZipFileEmpty-" + String.valueOf(new Date().getTime())); MultipartFile zipFile = new MockMultipartFile("zip", "not-exisiting.zip", ZIP_TYPE, new byte[0]); try { this.cut.unzip(zipFile, targetDir); } finally { FileUtils.deleteQuietly(targetDir); } }
@Test public void unzip_should_unzip_even_on_empty_file() throws IOException { File targetDir = new File(System.getProperty("java.io.tmpdir"), "ara-unzip-empty-file-" + new Date().getTime()); targetDir.mkdir(); MockMultipartFile zip = new MockMultipartFile("zip", "empty-zip.zip", ZIP_TYPE, new byte[0]); try { this.cut.unzip(zip, targetDir); } finally { FileUtils.deleteQuietly(targetDir); } }