  @Test
  public void testAnnotate_dependencyInSpringRepository() throws IOException {

    DependencyGraphBuilder dependencyGraphBuilder =
        new DependencyGraphBuilder(
            ImmutableList.of(
                "https://repo.spring.io/milestone", RepositoryUtility.CENTRAL.getUrl()));

    ClassPathBuilder classPathBuilderWithSpring = new ClassPathBuilder(dependencyGraphBuilder);

    // io.projectreactor:reactor-core:3.4.0-M2 is in the Spring Milestones repository.
    ClassPathResult classPathResult =
        classPathBuilderWithSpring.resolve(
            ImmutableList.of(
                new DefaultArtifact("io.projectreactor:reactor-core:3.4.0-M2"),
                new DefaultArtifact("org.reactivestreams:reactive-streams:0.4.0")),
            false);

    ClassPathEntry reactorCore = classPathResult.getClassPath().get(0);

    // A hypothetical problem where org.reactivestreams.Subscriber class is missing because the
    // org.reactivestreams:reactive-streams, which contains the class, has a different version.
    LinkageProblem problem =
        new ClassNotFoundProblem(
            new ClassFile(reactorCore, "reactor.util.Metrics"),
            new ClassSymbol("org.reactivestreams.Subscriber"));

    // This should not throw exception in resolving dependency graph
    LinkageProblemCauseAnnotator.annotate(
        classPathBuilderWithSpring, classPathResult, ImmutableSet.of(problem));

    LinkageProblemCause cause = problem.getCause();
    assertEquals(DependencyConflict.class, cause.getClass());
    DependencyConflict conflict = (DependencyConflict) cause;

    assertEquals(
        "org.reactivestreams:reactive-streams:0.4.0",
        Artifacts.toCoordinates(conflict.getPathToSelectedArtifact().getLeaf()));

    // io.projectreactor:reactor-core depends on reactive-streams 1.0.3
    assertEquals(
        "org.reactivestreams:reactive-streams:1.0.3",
        Artifacts.toCoordinates(conflict.getPathToArtifactThruSource().getLeaf()));
  }