Source:
public void testMultipleBinaryContents() throws Exception { String id = "e30e340fb8dd64bb7f32cda3c3625968"; BinaryContent binaryContent1 = mock(BinaryContent.class); BinaryContent binaryContent2 = mock(BinaryContent.class); when(binaryContent1.getInputStream()) .thenReturn(new ByteArrayInputStream("<xml>1</xml>".getBytes())); when(binaryContent2.getInputStream()) .thenReturn(new ByteArrayInputStream("<xml>2</xml>".getBytes())); List<Result> resultList = getResultList(id); Transform transform = mock(Transform.class); when(transform.isMetacardTransformerIdValid(any())).thenReturn(true); when(transform.transform(any(List.class), any(), any())) .thenReturn(Arrays.asList(binaryContent1, binaryContent2)); TestDumpCommand dumpCommand = new TestDumpCommand(transform); dumpCommand.catalogFramework = givenCatalogFramework(resultList); dumpCommand.filterBuilder = new GeotoolsFilterBuilder(); File outputDirectory = testFolder.newFolder(TEST_FOLDER); dumpCommand.dirPath = outputDirectory.getAbsolutePath(); dumpCommand.transformerId = "someOtherTransformer"; dumpCommand.dirLevel = 3; dumpCommand.executeWithSubject(); File targetZipFile = new File( testFolder.getRoot().getAbsolutePath() + File.separator + TEST_FOLDER + File.separator + "e3" + File.separator + "0e" + File.separator + "34" + File.separator + id + ".zip"); assertThat(consoleOutput.getOutput(), containsString(" 1 file(s) dumped in ")); assertThat(targetZipFile.exists(), is(true)); ZipFile zipFile = new ZipFile(targetZipFile); List fileHeaders = zipFile.getFileHeaders(); assertThat(fileHeaders.size(), is(2)); assertThat(((FileHeader) fileHeaders.get(0)).getFileName(), is("1")); assertThat(((FileHeader) fileHeaders.get(1)).getFileName(), is("2")); }

Target:
public void testMultipleBinaryContents() throws Exception { String id = "e30e340fb8dd64bb7f32cda3c3625968"; BinaryContent binaryContent1 = mock(BinaryContent.class); BinaryContent binaryContent2 = mock(BinaryContent.class); when(binaryContent1.getInputStream()) .thenReturn(new ByteArrayInputStream("<xml>1</xml>".getBytes())); when(binaryContent2.getInputStream()) .thenReturn(new ByteArrayInputStream("<xml>2</xml>".getBytes())); List<Result> resultList = getResultList(id); Transform transform = mock(Transform.class); when(transform.isMetacardTransformerIdValid(any())).thenReturn(true); when(transform.transform(any(List.class), any(), any())) .thenReturn(Arrays.asList(binaryContent1, binaryContent2)); TestDumpCommand dumpCommand = new TestDumpCommand(transform); dumpCommand.catalogFramework = givenCatalogFramework(resultList); dumpCommand.filterBuilder = new GeotoolsFilterBuilder(); File outputDirectory = testFolder.newFolder(TEST_FOLDER); dumpCommand.dirPath = outputDirectory.getAbsolutePath(); dumpCommand.transformerId = "someOtherTransformer"; dumpCommand.dirLevel = 3; dumpCommand.executeWithSubject(); File targetZipFile = new File( testFolder.getRoot().getAbsolutePath() + File.separator + TEST_FOLDER + File.separator + "e3" + File.separator + "0e" + File.separator + "34" + File.separator + id + ".zip"); assertThat(targetZipFile.exists(), is(true)); ZipFile zipFile = new ZipFile(targetZipFile); List fileHeaders = zipFile.getFileHeaders(); assertThat(fileHeaders.size(), is(2)); assertThat(((FileHeader) fileHeaders.get(0)).getFileName(), is("1")); assertThat(((FileHeader) fileHeaders.get(1)).getFileName(), is("2")); }