@Test public void testFormatProblems_2problems() { UnresolvableArtifactProblem problemA_B_C = new UnresolvableArtifactProblem(ImmutableList.of(nodeA, nodeB, nodeC)); UnresolvableArtifactProblem problemB_C = new UnresolvableArtifactProblem(ImmutableList.of(nodeA, nodeB, nodeC)); String actual = ArtifactProblem.formatProblems(ImmutableList.of(problemB_C, problemA_B_C)); assertEquals( "foo:c:jar:1.0.0 was not resolved. " + "Dependency path: foo:a:jar:1.0.0 (compile) > foo:b:jar:1.0.0 (provided) > " + "foo:c:jar:1.0.0 (runtime) and a problem on the same artifact.\n", actual); }
public static String formatProblems(Iterable<ArtifactProblem> problems) { ImmutableListMultimap<Artifact, ArtifactProblem> artifactToProblems = Multimaps.index(problems, ArtifactProblem::getArtifact); StringBuilder output = new StringBuilder(); for (Artifact artifact : artifactToProblems.keySet()) { ImmutableList<ArtifactProblem> artifactProblems = artifactToProblems.get(artifact); int otherCount = artifactProblems.size() - 1; verify(otherCount >= 0, "artifactToProblems should have at least one value for one key"); ArtifactProblem firstProblem = Iterables.getFirst(artifactProblems, null); output.append(firstProblem); if (otherCount == 1) { output.append(" and a problem on the same artifact."); } else if (otherCount > 1) { output.append(" and " + otherCount + " problems on the same artifact."); } output.append("\n"); } return output.toString(); }
ArtifactProblem { public static String formatProblems(Iterable<ArtifactProblem> problems) { ImmutableListMultimap<Artifact, ArtifactProblem> artifactToProblems = Multimaps.index(problems, ArtifactProblem::getArtifact); StringBuilder output = new StringBuilder(); for (Artifact artifact : artifactToProblems.keySet()) { ImmutableList<ArtifactProblem> artifactProblems = artifactToProblems.get(artifact); int otherCount = artifactProblems.size() - 1; verify(otherCount >= 0, "artifactToProblems should have at least one value for one key"); ArtifactProblem firstProblem = Iterables.getFirst(artifactProblems, null); output.append(firstProblem); if (otherCount == 1) { output.append(" and a problem on the same artifact."); } else if (otherCount > 1) { output.append(" and " + otherCount + " problems on the same artifact."); } output.append("\n"); } return output.toString(); } }
ArtifactProblem { public static String formatProblems(Iterable<ArtifactProblem> problems) { ImmutableListMultimap<Artifact, ArtifactProblem> artifactToProblems = Multimaps.index(problems, ArtifactProblem::getArtifact); StringBuilder output = new StringBuilder(); for (Artifact artifact : artifactToProblems.keySet()) { ImmutableList<ArtifactProblem> artifactProblems = artifactToProblems.get(artifact); int otherCount = artifactProblems.size() - 1; verify(otherCount >= 0, "artifactToProblems should have at least one value for one key"); ArtifactProblem firstProblem = Iterables.getFirst(artifactProblems, null); output.append(firstProblem); if (otherCount == 1) { output.append(" and a problem on the same artifact."); } else if (otherCount > 1) { output.append(" and " + otherCount + " problems on the same artifact."); } output.append("\n"); } return output.toString(); } protected  ArtifactProblem(Artifact artifact, List<DependencyNode> dependencyPath); }
ArtifactProblem { public static String formatProblems(Iterable<ArtifactProblem> problems) { ImmutableListMultimap<Artifact, ArtifactProblem> artifactToProblems = Multimaps.index(problems, ArtifactProblem::getArtifact); StringBuilder output = new StringBuilder(); for (Artifact artifact : artifactToProblems.keySet()) { ImmutableList<ArtifactProblem> artifactProblems = artifactToProblems.get(artifact); int otherCount = artifactProblems.size() - 1; verify(otherCount >= 0, "artifactToProblems should have at least one value for one key"); ArtifactProblem firstProblem = Iterables.getFirst(artifactProblems, null); output.append(firstProblem); if (otherCount == 1) { output.append(" and a problem on the same artifact."); } else if (otherCount > 1) { output.append(" and " + otherCount + " problems on the same artifact."); } output.append("\n"); } return output.toString(); } protected  ArtifactProblem(Artifact artifact, List<DependencyNode> dependencyPath); Artifact getArtifact(); static String formatProblems(Iterable<ArtifactProblem> problems); @Override boolean equals(Object other); @Override int hashCode(); }
ArtifactProblem { public static String formatProblems(Iterable<ArtifactProblem> problems) { ImmutableListMultimap<Artifact, ArtifactProblem> artifactToProblems = Multimaps.index(problems, ArtifactProblem::getArtifact); StringBuilder output = new StringBuilder(); for (Artifact artifact : artifactToProblems.keySet()) { ImmutableList<ArtifactProblem> artifactProblems = artifactToProblems.get(artifact); int otherCount = artifactProblems.size() - 1; verify(otherCount >= 0, "artifactToProblems should have at least one value for one key"); ArtifactProblem firstProblem = Iterables.getFirst(artifactProblems, null); output.append(firstProblem); if (otherCount == 1) { output.append(" and a problem on the same artifact."); } else if (otherCount > 1) { output.append(" and " + otherCount + " problems on the same artifact."); } output.append("\n"); } return output.toString(); } protected  ArtifactProblem(Artifact artifact, List<DependencyNode> dependencyPath); Artifact getArtifact(); static String formatProblems(Iterable<ArtifactProblem> problems); @Override boolean equals(Object other); @Override int hashCode();  }