@Test public void testAggregateDuplicateWarnings() { Warnings f1Warnings = new Warnings(); f1Warnings .getRedFlagWarnings() .addAll( ImmutableList.of( new Warning("dup warning", null), new Warning("unique warning", null))); Warnings f2Warnings = new Warnings(); f2Warnings.getRedFlagWarnings().addAll(ImmutableList.of(new Warning("dup warning", null))); Map<String, Warnings> fileWarnings = ImmutableMap.of("f1", f1Warnings, "f2", f2Warnings); assertThat( aggregateDuplicateWarnings(fileWarnings, Warnings::getRedFlagWarnings), equalTo( ImmutableMap.of( new Warning("dup warning", null), ImmutableSortedSet.of("f1", "f2"), new Warning("unique warning", null), ImmutableSortedSet.of("f1")))); }
@Nonnull @VisibleForTesting static Map<Warning, SortedSet<String>> aggregateDuplicateWarnings( Map<String, Warnings> nodeToWarnings, Function<Warnings, List<Warning>> warningFunc) { Map<Warning, SortedSet<String>> map = new HashMap<>(); nodeToWarnings.forEach( (node, warnings) -> { for (Warning warning : warningFunc.apply(warnings)) { map.computeIfAbsent(warning, w -> new TreeSet<>()).add(node); } }); return map; }
IssueAggregation { @Nonnull @VisibleForTesting static Map<Warning, SortedSet<String>> aggregateDuplicateWarnings( Map<String, Warnings> nodeToWarnings, Function<Warnings, List<Warning>> warningFunc) { Map<Warning, SortedSet<String>> map = new HashMap<>(); nodeToWarnings.forEach( (node, warnings) -> { for (Warning warning : warningFunc.apply(warnings)) { map.computeIfAbsent(warning, w -> new TreeSet<>()).add(node); } }); return map; } }
IssueAggregation { @Nonnull @VisibleForTesting static Map<Warning, SortedSet<String>> aggregateDuplicateWarnings( Map<String, Warnings> nodeToWarnings, Function<Warnings, List<Warning>> warningFunc) { Map<Warning, SortedSet<String>> map = new HashMap<>(); nodeToWarnings.forEach( (node, warnings) -> { for (Warning warning : warningFunc.apply(warnings)) { map.computeIfAbsent(warning, w -> new TreeSet<>()).add(node); } }); return map; }  }
IssueAggregation { @Nonnull @VisibleForTesting static Map<Warning, SortedSet<String>> aggregateDuplicateWarnings( Map<String, Warnings> nodeToWarnings, Function<Warnings, List<Warning>> warningFunc) { Map<Warning, SortedSet<String>> map = new HashMap<>(); nodeToWarnings.forEach( (node, warnings) -> { for (Warning warning : warningFunc.apply(warnings)) { map.computeIfAbsent(warning, w -> new TreeSet<>()).add(node); } }); return map; }   }
IssueAggregation { @Nonnull @VisibleForTesting static Map<Warning, SortedSet<String>> aggregateDuplicateWarnings( Map<String, Warnings> nodeToWarnings, Function<Warnings, List<Warning>> warningFunc) { Map<Warning, SortedSet<String>> map = new HashMap<>(); nodeToWarnings.forEach( (node, warnings) -> { for (Warning warning : warningFunc.apply(warnings)) { map.computeIfAbsent(warning, w -> new TreeSet<>()).add(node); } }); return map; }    }