@Test public void testFromJson() { SimpleReport emptyReport = SimpleReport.fromJson(obj().get()); assertEquals("empty report name is empty", "", emptyReport.getCheckName()); assertTrue("empty report violations are empty", emptyReport.getViolations().isEmpty()); SimpleViolation violation = new SimpleViolation(Severity.MINOR, "minor"); SimpleReport moreReport = SimpleReport.fromJson(obj() .key(ReportMapper.keys().checkName(), "more") .key(ReportMapper.keys().violations(), arr().val(violation)) .get()); assertEquals("more report name is more", "more", moreReport.getCheckName()); assertEquals("more report violations are ", Collections.singletonList(violation), moreReport.getViolations()); }
public static SimpleReport fromJson(final @NotNull JsonObject jsonReport) { String vCheckName = jsonReport.getString(CoreConstants.checkReportKeys().checkName(), ""); List<Violation> violations = optArray(jsonReport, CoreConstants.checkReportKeys().violations()) .map(array -> mapArrayOfObjects(array, ReportMapper::violationFromJson)) .orElseGet(Collections::emptyList); return new SimpleReport(vCheckName, violations); }
SimpleReport implements CheckReport { public static SimpleReport fromJson(final @NotNull JsonObject jsonReport) { String vCheckName = jsonReport.getString(CoreConstants.checkReportKeys().checkName(), ""); List<Violation> violations = optArray(jsonReport, CoreConstants.checkReportKeys().violations()) .map(array -> mapArrayOfObjects(array, ReportMapper::violationFromJson)) .orElseGet(Collections::emptyList); return new SimpleReport(vCheckName, violations); } }
SimpleReport implements CheckReport { public static SimpleReport fromJson(final @NotNull JsonObject jsonReport) { String vCheckName = jsonReport.getString(CoreConstants.checkReportKeys().checkName(), ""); List<Violation> violations = optArray(jsonReport, CoreConstants.checkReportKeys().violations()) .map(array -> mapArrayOfObjects(array, ReportMapper::violationFromJson)) .orElseGet(Collections::emptyList); return new SimpleReport(vCheckName, violations); } SimpleReport(final String checkName, final Collection<Violation> violations); }
SimpleReport implements CheckReport { public static SimpleReport fromJson(final @NotNull JsonObject jsonReport) { String vCheckName = jsonReport.getString(CoreConstants.checkReportKeys().checkName(), ""); List<Violation> violations = optArray(jsonReport, CoreConstants.checkReportKeys().violations()) .map(array -> mapArrayOfObjects(array, ReportMapper::violationFromJson)) .orElseGet(Collections::emptyList); return new SimpleReport(vCheckName, violations); } SimpleReport(final String checkName, final Collection<Violation> violations); @Override String getCheckName(); @Override @NotNull Collection<Violation> getViolations(); @Override boolean equals(final Object o); @Override int hashCode(); @Override String toString(); static SimpleReport generateReport(final @NotNull ProgressCheck reporter); static SimpleReport generateReport(final @NotNull ErrorListener reporter); static SimpleReport fromJson(final @NotNull JsonObject jsonReport); }
SimpleReport implements CheckReport { public static SimpleReport fromJson(final @NotNull JsonObject jsonReport) { String vCheckName = jsonReport.getString(CoreConstants.checkReportKeys().checkName(), ""); List<Violation> violations = optArray(jsonReport, CoreConstants.checkReportKeys().violations()) .map(array -> mapArrayOfObjects(array, ReportMapper::violationFromJson)) .orElseGet(Collections::emptyList); return new SimpleReport(vCheckName, violations); } SimpleReport(final String checkName, final Collection<Violation> violations); @Override String getCheckName(); @Override @NotNull Collection<Violation> getViolations(); @Override boolean equals(final Object o); @Override int hashCode(); @Override String toString(); static SimpleReport generateReport(final @NotNull ProgressCheck reporter); static SimpleReport generateReport(final @NotNull ErrorListener reporter); static SimpleReport fromJson(final @NotNull JsonObject jsonReport);  }