private AcceptanceTestReporter getJsonReporter() { JSONTestOutcomeReporter reporter = new JSONTestOutcomeReporter(); reporter.setOutputDirectory(getOutputDirectory()); return reporter; }
@Override public List<TestOutcome> loadReportsFrom(File outputDirectory) { File[] reportFiles = getAllJsonFilesFrom(outputDirectory); List<TestOutcome> testOutcomes = new ArrayList<>(); if (reportFiles != null) { for (File reportFile : reportFiles) { testOutcomes.addAll(loadReportFrom(reportFile).map(Collections::singleton).orElse(Collections.emptySet())); } } return testOutcomes; }
@Override public List<TestOutcome> loadReportsFrom(final Path outputDirectory) { return loadReportsFrom(outputDirectory.toFile()); }
@Override public File generateReportFor(TestOutcome testOutcome, TestOutcomes allTestOutcomes) throws IOException { TestOutcome storedTestOutcome = testOutcome.withQualifier(qualifier); Preconditions.checkNotNull(outputDirectory); String reportFilename = reportFor(storedTestOutcome); File report = new File(getOutputDirectory(), reportFilename); try(OutputStream outputStream = new BufferedOutputStream(new FileOutputStream(report))){ jsonConverter.toJson(storedTestOutcome, outputStream); } return report; }
private TestOutcomeStream(Path sourceDirectory) throws IOException { this.directoryStream = Files.newDirectoryStream(sourceDirectory); this.directoryStreamIterator = Files.newDirectoryStream(sourceDirectory).iterator(); this.loader = new JSONTestOutcomeReporter(); }
@Override public Optional<TestOutcome> loadReportFrom(final Path reportFile) { return loadReportFrom(reportFile.toFile()); }
@Override public File generateReportFor(TestOutcome testOutcome, TestOutcomes allTestOutcomes) throws IOException { TestOutcome storedTestOutcome = testOutcome.withQualifier(qualifier); Preconditions.checkNotNull(outputDirectory); String reportFilename = reportFor(storedTestOutcome); File report = new File(getOutputDirectory(), reportFilename); try(OutputStream outputStream = new BufferedOutputStream(new FileOutputStream(report))){ jsonConverter.toJson(storedTestOutcome, outputStream); } return report; }
public AcceptanceTestLoader getOutcomeReporter() { switch (formatConfiguration.getPreferredFormat()) { case XML: return new XMLTestOutcomeReporter(); case JSON: return new JSONTestOutcomeReporter(); default: throw new IllegalArgumentException("Unsupported report format: " + formatConfiguration.getPreferredFormat()); } } private class SerializedOutcomeFilenameFilter implements FilenameFilter {
@Override public List<TestOutcome> loadReportsFrom(File outputDirectory) { File[] reportFiles = getAllJsonFilesFrom(outputDirectory); List<TestOutcome> testOutcomes = Lists.newArrayList(); if (reportFiles != null) { for (File reportFile : reportFiles) { testOutcomes.addAll(loadReportFrom(reportFile).asSet()); } } return testOutcomes; }
@Override public File generateReportFor(TestOutcome testOutcome) throws IOException { TestOutcome storedTestOutcome = testOutcome.withQualifier(qualifier); Preconditions.checkNotNull(outputDirectory); String reportFilename = reportFor(storedTestOutcome); String unique = UUID.randomUUID().toString(); File temporary = new File(getOutputDirectory(), reportFilename.concat(unique)); File report = new File(getOutputDirectory(), reportFilename); report.createNewFile(); LOGGER.debug("Generating JSON report for {} to file {} (using temp file {})", testOutcome.getTitle(), report.getAbsolutePath(), temporary.getAbsolutePath()); try(OutputStream outputStream = new BufferedOutputStream(new FileOutputStream(temporary))){ jsonConverter.toJson(storedTestOutcome, outputStream); outputStream.flush(); } SafelyMoveFiles.withMaxRetriesOf(3).from(temporary.toPath()).to(report.toPath()); return report; }
private AcceptanceTestReporter getJsonReporter() { JSONTestOutcomeReporter reporter = new JSONTestOutcomeReporter(); reporter.setOutputDirectory(getOutputDirectory()); return reporter; }
public AcceptanceTestLoader getOutcomeReporter() { switch (formatConfiguration.getPreferredFormat()) { case XML: return new XMLTestOutcomeReporter(); case JSON: return new JSONTestOutcomeReporter(); default: throw new IllegalArgumentException("Unsupported report format: " + formatConfiguration.getPreferredFormat()); } } private class SerializedOutcomeFilenameFilter implements FilenameFilter {
@Override public List<TestOutcome> loadReportsFrom(File outputDirectory) { File[] reportFiles = getAllJsonFilesFrom(outputDirectory); List<TestOutcome> testOutcomes = Lists.newArrayList(); if (reportFiles != null) { for (File reportFile : reportFiles) { testOutcomes.addAll(loadReportFrom(reportFile).asSet()); } } return testOutcomes; }
private AcceptanceTestLoader getOutcomeReporter() { switch (formatConfiguration.getPreferredFormat()) { case XML: return new XMLTestOutcomeReporter(); case JSON: return new JSONTestOutcomeReporter(); default: throw new IllegalArgumentException("Unsupported report format: " + formatConfiguration.getPreferredFormat()); } }