@Override public List<TestOutcome> loadReportsFrom(final Path outputDirectory) { return loadReportsFrom(outputDirectory.toFile()); }
@Override public Optional<TestOutcome> loadReportFrom(final Path reportFile) { return loadReportFrom(reportFile.toFile()); }
private File[] getAllJsonFilesFrom(final File reportsDirectory) { return reportsDirectory.listFiles(new JsonFilenameFilter()); }
@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; }
@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 AcceptanceTestReporter getJsonReporter() { JSONTestOutcomeReporter reporter = new JSONTestOutcomeReporter(); reporter.setOutputDirectory(getOutputDirectory()); return reporter; }
private TestOutcomeStream(Path sourceDirectory) throws IOException { this.directoryStream = Files.newDirectoryStream(sourceDirectory); this.directoryStreamIterator = Files.newDirectoryStream(sourceDirectory).iterator(); this.loader = new JSONTestOutcomeReporter(); }
public String toJson() { JSONConverter jsonConverter = Injectors.getInjector().getInstance(JSONConverter.class); try(ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) { jsonConverter.toJson(this, outputStream); return outputStream.toString(); } catch (IOException e) { return ""; } }
private TestOutcome addQualifierIfPresent(JsonObject outcomeJsonObject, TestOutcome testOutcome) { JsonElement qualifierField = outcomeJsonObject.get(QUALIFIER_FIELD); if (qualifierField != null) { testOutcome = testOutcome.withQualifier(unescape(qualifierField.getAsString())); } return testOutcome; }
private void checkForRequiredFieldsIn(TestOutcome testOutcome) { if (isEmpty(testOutcome.getName())) { throw new AScenarioHasNoNameException(testOutcome.getId()); } }
@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; }
@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 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 {
private File[] getAllJsonFilesFrom(final File reportsDirectory) { return reportsDirectory.listFiles(new JsonFilenameFilter()); }
public String toJson() { JSONConverter jsonConverter = Injectors.getInjector().getInstance(JSONConverter.class); try(ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) { jsonConverter.toJson(this, outputStream); return outputStream.toString(); } catch (IOException e) { return ""; } }
@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; }
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 {
private File[] getAllJsonFilesFrom(final File reportsDirectory) { return reportsDirectory.listFiles(new JsonFilenameFilter()); }
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()); } }