Search in sources :

Example 56 with DependencyNode

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

the class PatternInclusionsDependencyFilterTest method acceptTestRange.

@Test
public void acceptTestRange() {
    NodeBuilder builder = new NodeBuilder();
    builder.groupId("com.example.test").artifactId("testArtifact").ext("jar").version("1.0.3");
    DependencyNode node = builder.build();
    String prefix = "com.example.test:testArtifact:jar:";
    assertTrue(prefix + "[1.0.3,1.0.4)", acceptVersionRange(node, prefix + "[1.0.3,1.0.4)"));
    assertTrue(prefix + "[1.0.3,)", acceptVersionRange(node, prefix + "[1.0.3,)"));
    assertTrue(prefix + "[1.0.3,]", acceptVersionRange(node, prefix + "[1.0.3,]"));
    assertTrue(prefix + "(,1.0.3]", acceptVersionRange(node, prefix + "(,1.0.3]"));
    assertTrue(prefix + "[1.0,]", acceptVersionRange(node, prefix + "[1.0,]"));
    assertTrue(prefix + "[1,4]", acceptVersionRange(node, prefix + "[1,4]"));
    assertTrue(prefix + "(1,4)", acceptVersionRange(node, prefix + "(1,4)"));
    assertTrue(prefix + "(1.0.2,1.0.3]", acceptVersionRange(node, prefix + "(1.0.2,1.0.3]", prefix + "(1.1,)"));
    assertFalse(prefix + "(1.0.3,2.0]", acceptVersionRange(node, prefix + "(1.0.3,2.0]"));
    assertFalse(prefix + "(1,1.0.2]", acceptVersionRange(node, prefix + "(1,1.0.2]"));
    assertFalse(prefix + "(1.0.2,1.0.3)", acceptVersionRange(node, prefix + "(1.0.2,1.0.3)", prefix + "(1.0.3,)"));
}
Also used : DependencyNode(org.sonatype.aether.graph.DependencyNode) NodeBuilder(org.sonatype.aether.test.util.NodeBuilder) Test(org.junit.Test)

Example 57 with DependencyNode

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

the class AbstractDependencyGraphTransformerTest method find.

private boolean find(LinkedList<DependencyNode> trail, DependencyNode node, String id) {
    trail.addFirst(node);
    if (isMatch(node, id)) {
        return true;
    }
    for (DependencyNode child : node.getChildren()) {
        if (find(trail, child, id)) {
            return true;
        }
    }
    trail.removeFirst();
    return false;
}
Also used : DependencyNode(org.sonatype.aether.graph.DependencyNode)

Example 58 with DependencyNode

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

the class ConflictMarkerTest method testRelocation3.

@Test
public void testRelocation3() throws Exception {
    NodeBuilder builder = new NodeBuilder();
    DependencyNode root = builder.build();
    root.getChildren().add(builder.artifactId("a").build());
    root.getChildren().add(builder.artifactId("b").build());
    root.getChildren().add(builder.artifactId("c").reloc("a").reloc("b").build());
    DependencyGraphTransformationContext context = newContext();
    assertSame(root, new ConflictMarker().transformGraph(root, context));
    Map<?, ?> ids = (Map<?, ?>) context.get(TransformationContextKeys.CONFLICT_IDS);
    assertNotNull(ids);
    assertNull(ids.get(root));
    assertNotNull(ids.get(root.getChildren().get(0)));
    assertNotNull(ids.get(root.getChildren().get(1)));
    assertNotNull(ids.get(root.getChildren().get(2)));
    assertSame(ids.get(root.getChildren().get(0)), ids.get(root.getChildren().get(1)));
    assertSame(ids.get(root.getChildren().get(1)), ids.get(root.getChildren().get(2)));
}
Also used : DependencyGraphTransformationContext(org.sonatype.aether.collection.DependencyGraphTransformationContext) DependencyNode(org.sonatype.aether.graph.DependencyNode) ConflictMarker(org.sonatype.aether.util.graph.transformer.ConflictMarker) NodeBuilder(org.sonatype.aether.test.util.NodeBuilder) Map(java.util.Map) Test(org.junit.Test)

Example 59 with DependencyNode

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

the class JavaDependencyContextRefinerTest method testDoNotRefineOtherContext.

@Test
public void testDoNotRefineOtherContext() throws IOException, RepositoryException {
    DependencyNode node = parser.parseLiteral("gid:aid:ext:cls:ver");
    node.setRequestContext("otherContext");
    DependencyNode refinedNode = refiner.transformGraph(node, context);
    assertEquals(node, refinedNode);
}
Also used : DependencyNode(org.sonatype.aether.graph.DependencyNode) Test(org.junit.Test)

Example 60 with DependencyNode

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

the class DefaultDependencyCollectorTest method testDependencyManagement.

@Test
public void testDependencyManagement() throws IOException, DependencyCollectionException {
    collector.setArtifactDescriptorReader(new IniArtifactDescriptorReader("artifact-descriptions/managed/"));
    DependencyNode root = parser.parse("expectedSubtreeComparisonResult.txt");
    TestDependencyManager depMgmt = new TestDependencyManager();
    depMgmt.addManagedDependency(dep(root, 0), "managed", null, null);
    depMgmt.addManagedDependency(dep(root, 0, 1), "managed", "managed", null);
    depMgmt.addManagedDependency(dep(root, 1), null, null, "managed");
    session.setDependencyManager(depMgmt);
    // collect result will differ from expectedSubtreeComparisonResult.txt
    // set localPath -> no dependency traversal
    CollectRequest request = new CollectRequest(dep(root), Arrays.asList(repository));
    CollectResult result = collector.collectDependencies(session, request);
    DependencyNode node = result.getRoot();
    assertEquals("managed", dep(node, 0, 1).getArtifact().getVersion());
    assertEquals("managed", dep(node, 0, 1).getScope());
    assertEquals("managed", dep(node, 1).getArtifact().getProperty(ArtifactProperties.LOCAL_PATH, null));
    assertEquals("managed", dep(node, 0, 0).getArtifact().getProperty(ArtifactProperties.LOCAL_PATH, null));
}
Also used : CollectResult(org.sonatype.aether.collection.CollectResult) DependencyNode(org.sonatype.aether.graph.DependencyNode) CollectRequest(org.sonatype.aether.collection.CollectRequest) 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