CompositeBuildResult implements AnalysisBuildResult { public CompositeBuildResult add(final AnalysisBuildResult... additionalResults) { for (AnalysisBuildResult another : additionalResults) { sizesPerOrigin.putAll(another.getSizePerOrigin()); for (Severity severity : Severity.getPredefinedValues()) { sizesPerSeverity.merge(severity, another.getTotalSizeOf(severity), Integer::sum); newSizesPerSeverity.merge(severity, another.getNewSizeOf(severity), Integer::sum); } fixedSize += another.getFixedSize(); } return this; }  CompositeBuildResult add(final AnalysisBuildResult... additionalResults); @Override Map<String, Integer> getSizePerOrigin(); @Override int getFixedSize(); @Override int getTotalSize(); @Override int getTotalSizeOf(final Severity severity); @Override int getNewSize(); @Override int getNewSizeOf(final Severity severity);  }
@Test void shouldMergeNumberOfTotalIssues() { AnalysisBuildResult first = createAnalysisBuildResult(1, 2, 3, 4); AnalysisBuildResult second = createAnalysisBuildResult(5, 6, 7, 8); CompositeBuildResult run = new CompositeBuildResult(); assertThat(run).hasTotalSize(0); assertThat(run.add(first)).hasTotalSize(10); assertThat(run.add(second)).hasTotalSize(36); }
@Test void shouldMergeNumberOfFixedIssues() { AnalysisBuildResult first = createAnalysisBuildResultWithNewAndFixedIssues(0, 2); AnalysisBuildResult second = createAnalysisBuildResultWithNewAndFixedIssues(0, 3); CompositeBuildResult run = new CompositeBuildResult(); assertThat(run).hasFixedSize(0); assertThat(run.add(first)).hasFixedSize(2); assertThat(run.add(second)).hasFixedSize(5); }
@Test void shouldMergeNumberOfNewIssues() { AnalysisBuildResult first = createAnalysisBuildResultWithNew(0, 5, 2, 6); AnalysisBuildResult second = createAnalysisBuildResultWithNew(0, 4, 2, 7); CompositeBuildResult run = new CompositeBuildResult(); assertThat(run).hasNewSize(0); assertThat(run.add(first)).hasNewSize(13); assertThat(run.add(second)).hasNewSize(26); }