@Override public void aggregate(final Configuration configuration, final List<LaunchResults> launchesResults, final Path outputDirectory) throws IOException { final Path attachmentsFolder = Files.createDirectories( outputDirectory.resolve(Constants.DATA_DIR).resolve("attachments") ); for (LaunchResults launch : launchesResults) { for (Map.Entry<Path, Attachment> entry : launch.getAttachments().entrySet()) { final Path file = attachmentsFolder.resolve(entry.getValue().getSource()); Files.copy(entry.getKey(), file, StandardCopyOption.REPLACE_EXISTING); } } } }
@Test public void shouldReadAttachments() throws Exception { final LaunchResults launchResults = process( "allure1/suite-with-attachments.xml", generateTestSuiteXmlName(), "allure1/sample-attachment.txt", "sample-attachment.txt" ); final Map<Path, Attachment> attachmentMap = launchResults.getAttachments(); final Set<TestResult> results = launchResults.getResults(); assertThat(attachmentMap) .hasSize(1); final Attachment storedAttachment = attachmentMap.values().iterator().next(); List<Attachment> attachments = results.stream() .flatMap(this::extractAttachments) .collect(Collectors.toList()); assertThat(attachments) .hasSize(1) .extracting(Attachment::getSource) .containsExactly(storedAttachment.getSource()); }
@Override public void aggregate(final Configuration configuration, final List<LaunchResults> launchesResults, final Path outputDirectory) throws IOException { final Path attachmentsFolder = Files.createDirectories( outputDirectory.resolve(Constants.DATA_DIR).resolve("attachments") ); for (LaunchResults launch : launchesResults) { for (Map.Entry<Path, Attachment> entry : launch.getAttachments().entrySet()) { final Path file = attachmentsFolder.resolve(entry.getValue().getSource()); Files.copy(entry.getKey(), file, StandardCopyOption.REPLACE_EXISTING); } } } }