FileZipper { public void createZipWithFiles(final List<List<String>> filePaths, final OutputStream result) { ZipOutputStream zipStream = zipOutputStreamFactory.createZipOutputStream(result); zipFiles(filePaths, zipStream); closeZipStream(zipStream); }  void createZipWithFiles(final List<List<String>> filePaths, final OutputStream result);  }
@Test public void testCreateZipWithFilesWhenFilePathsIsNotEmptyList() throws IOException { List<String> pair = new ArrayList<String>(); pair.add("src/test/resources/first_testreq.txt"); pair.add("src/test/resources/first_testresp.txt"); filePaths.add(pair); underTest.createZipWithFiles(filePaths, outputStream); verify(entryFactory).createZipEntry("first_testreq.txt"); verify(entryFactory).createZipEntry("first_testresp.txt"); verify(zipOutputStream, times(2)).putNextEntry(zipEntry); verify(zipOutputStream).close(); }
@Test public void testCreateZipWithFilesWhenFilePathContainsBackSlashes() throws IOException { List<String> pair = new ArrayList<String>(); pair.add(FilenameUtils.separatorsToSystem("src\\test\\resources\\first_testreq.txt")); filePaths.add(pair); underTest.createZipWithFiles(filePaths, outputStream); verify(entryFactory).createZipEntry("first_testreq.txt"); verify(zipOutputStream).putNextEntry(zipEntry); verify(zipOutputStream).close(); }
@Test public void testCreateZipWithFilesWhenFileNotExists() throws IOException { List<String> pair = new ArrayList<String>(); pair.add("src\\test\\resources\\testreq.txt"); filePaths.add(pair); underTest.createZipWithFiles(filePaths, outputStream); verify(entryFactory, times(0)).createZipEntry("first_testreq.txt"); verify(zipOutputStream, times(0)).putNextEntry(zipEntry); verify(zipOutputStream).close(); }