Search in sources :

Example 76 with DependencyNode

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

the class JavaEffectiveScopeCalculatorTest method expectScope.

private void expectScope(String msg, String expected, DependencyNode root, int... coords) {
    if (msg == null) {
        msg = "";
    }
    try {
        DependencyNode node = root;
        node = path(node, coords);
        assertEquals(msg + "\nculprit: " + node.toString() + "\n", expected, node.getDependency().getScope());
    } catch (IndexOutOfBoundsException e) {
        throw new IllegalArgumentException("Illegal coordinates for child", e);
    } catch (NullPointerException e) {
        throw new IllegalArgumentException("Illegal coordinates for child", e);
    }
}
Also used : DependencyNode(org.sonatype.aether.graph.DependencyNode)

Example 77 with DependencyNode

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

the class JavaEffectiveScopeCalculatorTest method testConflictScopeOrdering.

@Test
public void testConflictScopeOrdering() throws RepositoryException, IOException {
    for (Scope scope1 : Scope.values()) {
        for (Scope scope2 : Scope.values()) {
            parser.setSubstitutions(scope1.toString(), scope2.toString());
            DependencyNode root = parser.parse("dueling-scopes.txt");
            String expected = scope1.compareTo(scope2) >= 0 ? scope1.toString() : 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, 0);
            expectScope(msg, expected, root, 1, 0);
        }
    }
}
Also used : DependencyNode(org.sonatype.aether.graph.DependencyNode) Test(org.junit.Test)

Example 78 with DependencyNode

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

the class JavaEffectiveScopeCalculatorTest method testCycleD.

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

Example 79 with DependencyNode

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

the class JavaEffectiveScopeCalculatorTest method testCycleB.

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

Example 80 with DependencyNode

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

the class NearestVersionConflictResolverTest method testSelectHighestVersionFromMultipleVersionsAtSameLevel.

@Test
public void testSelectHighestVersionFromMultipleVersionsAtSameLevel() throws Exception {
    // root
    // +- a:1
    // +- a:3
    // \- a:2
    DependencyNode a1 = builder.artifactId("a").version("1").build();
    DependencyNode a2 = builder.artifactId("a").version("2").build();
    DependencyNode a3 = builder.artifactId("a").version("3").build();
    DependencyNode root = builder.artifactId(null).build();
    root.getChildren().add(a1);
    root.getChildren().add(a3);
    root.getChildren().add(a2);
    Map<DependencyNode, Object> conflictIds = new IdentityHashMap<DependencyNode, Object>();
    conflictIds.put(a1, "a");
    conflictIds.put(a2, "a");
    conflictIds.put(a3, "a");
    context.put(TransformationContextKeys.CONFLICT_IDS, conflictIds);
    NearestVersionConflictResolver transformer = new NearestVersionConflictResolver();
    root = transformer.transformGraph(root, context);
    assertEquals(1, root.getChildren().size());
    assertSame(a3, root.getChildren().iterator().next());
}
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