ReportMapper { public static JsonArray reportsToJson(final @NotNull Collection<CheckReport> reports) { return reports.stream() .map(CheckReport::toJson) .collect(JsonCollectors.toJsonArray()); } private  ReportMapper(); static JsonKeys keys(); static List<CheckReport> readReports(final @NotNull ReaderSupplier readerSupplier); static List<CheckReport> readReportsFromFile(final @NotNull File jsonFile); static void writeReports(final @NotNull Collection<CheckReport> reports,
                                    final @NotNull WriterSupplier writerSupplier); static void writeReportsToFile(final Collection<CheckReport> reports,
                                          final @NotNull File outputFile); static JsonArray reportsToJson(final @NotNull Collection<CheckReport> reports); static JsonObject reportsToJsonObject(final @NotNull Collection<CheckReport> reports);  }
@Test public void testReportsToJson() throws Exception { final List<CheckReport> originalReports = asList( new SimpleReport("test/first", singletonList( new SimpleViolation(Severity.MINOR, "one", PackageId.fromString("test:first"))) ), new SimpleReport("test/second", asList( new SimpleViolation(Severity.MINOR, "one", PackageId.fromString("test:first")), new SimpleViolation(Severity.MINOR, "two", PackageId.fromString("test:first"), PackageId.fromString("test:second")) ) ) ); final StringWriter writer = new StringWriter(); ReportMapper.writeReports(originalReports, () -> writer); assertEquals("CheckReports should round trip", new ArrayList<>(originalReports), new ArrayList<>(ReportMapper.readReports(() -> new StringReader(writer.toString())))); }