Search in sources :

Example 31 with DependencyNode

use of org.sonatype.aether.graph.DependencyNode in project sonatype-aether by sonatype.

the class JavaEffectiveScopeCalculatorTest method testConflictWinningScopeGetsUsedForInheritance.

@Test
public void testConflictWinningScopeGetsUsedForInheritance() throws Exception {
    DependencyNode root = parser.parse("conflict-and-inheritance.txt");
    root = transform(root);
    expectScope("compile", root, 0, 0);
    expectScope("compile", root, 0, 0, 0);
}
Also used : DependencyNode(org.sonatype.aether.graph.DependencyNode) Test(org.junit.Test)

Example 32 with DependencyNode

use of org.sonatype.aether.graph.DependencyNode in project sonatype-aether by sonatype.

the class JavaEffectiveScopeCalculatorTest method testConflictingDirectNodes.

/**
     * obscure case (illegal maven POM). Current behavior: last mentioned wins.
     */
@Test
public void testConflictingDirectNodes() throws RepositoryException, IOException {
    for (Scope scope1 : Scope.values()) {
        for (Scope scope2 : Scope.values()) {
            parser.setSubstitutions(scope1.toString(), scope2.toString());
            DependencyNode root = parser.parse("conflicting-direct-nodes.txt");
            String expected = scope2.toString();
            String msg = String.format("expected '%s' to win\n" + parser.dump(root), expected);
            root = transform(root);
            msg += "\ntransformed:\n" + parser.dump(root);
            expectScope(msg, expected, root, 0);
            expectScope(msg, expected, root, 1);
        }
    }
}
Also used : DependencyNode(org.sonatype.aether.graph.DependencyNode) Test(org.junit.Test)

Example 33 with DependencyNode

use of org.sonatype.aether.graph.DependencyNode in project sonatype-aether by sonatype.

the class JavaEffectiveScopeCalculatorTest method testCycleA.

@Test
public void testCycleA() throws Exception {
    DependencyNode root = parser.parse("cycle-a.txt");
    root = transform(root);
    expectScope("compile", root, 0);
    expectScope("runtime", root, 0, 0);
    expectScope("runtime", root, 1);
    expectScope("compile", root, 1, 0);
}
Also used : DependencyNode(org.sonatype.aether.graph.DependencyNode) Test(org.junit.Test)

Example 34 with DependencyNode

use of org.sonatype.aether.graph.DependencyNode in project sonatype-aether by sonatype.

the class JavaEffectiveScopeCalculatorTest method testCycleC.

@Test
public void testCycleC() throws Exception {
    DependencyNode root = parser.parse("cycle-c.txt");
    root = transform(root);
    expectScope("runtime", root, 0);
    expectScope("runtime", root, 0, 0);
    expectScope("runtime", root, 0, 0, 0);
    expectScope("runtime", root, 1);
    expectScope("runtime", root, 1, 0);
    expectScope("runtime", root, 1, 0, 0);
}
Also used : DependencyNode(org.sonatype.aether.graph.DependencyNode) Test(org.junit.Test)

Example 35 with DependencyNode

use of org.sonatype.aether.graph.DependencyNode in project sonatype-aether by sonatype.

the class NearestVersionConflictResolverTest method testNearestDirtyVersionUnderneathRemovedNode.

@Test
public void testNearestDirtyVersionUnderneathRemovedNode() throws Exception {
    // root
    // +- a
    // |  \- b:1           # will be removed in favor of b:2
    // |     \- j:1        # nearest version of j in dirty tree
    // +- c
    // |  \- d
    // |     \- e
    // |        \- j:2
    // \- b:2
    DependencyNode j1 = builder.artifactId("j").version("1").build();
    DependencyNode j2 = builder.artifactId("j").version("2").build();
    DependencyNode b1 = builder.artifactId("b").version("1").build();
    b1.getChildren().add(j1);
    DependencyNode a = builder.artifactId("a").build();
    a.getChildren().add(b1);
    DependencyNode e = builder.artifactId("e").build();
    e.getChildren().add(j2);
    DependencyNode d = builder.artifactId("d").build();
    d.getChildren().add(e);
    DependencyNode c = builder.artifactId("c").build();
    c.getChildren().add(d);
    DependencyNode b2 = builder.artifactId("b").version("2").build();
    DependencyNode root = builder.artifactId(null).build();
    root.getChildren().add(a);
    root.getChildren().add(c);
    root.getChildren().add(b2);
    Map<DependencyNode, Object> conflictIds = new IdentityHashMap<DependencyNode, Object>();
    conflictIds.put(j1, "j");
    conflictIds.put(j2, "j");
    conflictIds.put(a, "a");
    conflictIds.put(b1, "b");
    conflictIds.put(b2, "b");
    conflictIds.put(c, "c");
    conflictIds.put(d, "d");
    conflictIds.put(e, "e");
    context.put(TransformationContextKeys.CONFLICT_IDS, conflictIds);
    NearestVersionConflictResolver transformer = new NearestVersionConflictResolver();
    root = transformer.transformGraph(root, context);
    List<DependencyNode> trail = find(root, "j");
    assertEquals(5, trail.size());
}
Also used : DependencyNode(org.sonatype.aether.graph.DependencyNode) IdentityHashMap(java.util.IdentityHashMap) Test(org.junit.Test)

Aggregations

DependencyNode (org.sonatype.aether.graph.DependencyNode)114 Test (org.junit.Test)82 NodeBuilder (org.sonatype.aether.test.util.NodeBuilder)20 Dependency (org.sonatype.aether.graph.Dependency)14 IdentityHashMap (java.util.IdentityHashMap)13 CollectRequest (org.sonatype.aether.collection.CollectRequest)12 CollectResult (org.sonatype.aether.collection.CollectResult)11 List (java.util.List)8 Map (java.util.Map)8 LinkedList (java.util.LinkedList)7 Artifact (org.sonatype.aether.artifact.Artifact)6 DependencyFilter (org.sonatype.aether.graph.DependencyFilter)5 ArrayList (java.util.ArrayList)4 DependencyGraphTransformationContext (org.sonatype.aether.collection.DependencyGraphTransformationContext)4 ConflictMarker (org.sonatype.aether.util.graph.transformer.ConflictMarker)4 HashMap (java.util.HashMap)3 ArtifactDescriptorException (org.sonatype.aether.resolution.ArtifactDescriptorException)3 BufferedReader (java.io.BufferedReader)2 HashSet (java.util.HashSet)2 RepositorySystemSession (org.sonatype.aether.RepositorySystemSession)2