Search in sources :

Example 71 with DependencyNode

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

the class ConflictMarkerTest method testRelocation2.

@Test
public void testRelocation2() throws Exception {
    NodeBuilder builder = new NodeBuilder();
    DependencyNode root = builder.build();
    root.getChildren().add(builder.artifactId("a").reloc("reloc").build());
    root.getChildren().add(builder.artifactId("a").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)));
    assertSame(ids.get(root.getChildren().get(0)), ids.get(root.getChildren().get(1)));
}
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 72 with DependencyNode

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

the class ConflictMarkerTest method testRelocation1.

@Test
public void testRelocation1() throws Exception {
    NodeBuilder builder = new NodeBuilder();
    DependencyNode root = builder.build();
    root.getChildren().add(builder.artifactId("a").build());
    root.getChildren().add(builder.artifactId("a").reloc("reloc").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)));
    assertSame(ids.get(root.getChildren().get(0)), ids.get(root.getChildren().get(1)));
}
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 73 with DependencyNode

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

the class ConflictMarkerTest method testSimple.

@Test
public void testSimple() throws Exception {
    NodeBuilder builder = new NodeBuilder();
    DependencyNode root = builder.build();
    root.getChildren().add(builder.artifactId("a").build());
    root.getChildren().add(builder.artifactId("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)));
    assertNotSame(ids.get(root.getChildren().get(0)), ids.get(root.getChildren().get(1)));
    assertFalse(ids.get(root.getChildren().get(0)).equals(ids.get(root.getChildren().get(1))));
}
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 74 with DependencyNode

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

the class JavaDependencyContextRefinerTest method testRefineToCompile.

@Test
public void testRefineToCompile() throws IOException, RepositoryException {
    String expected = "project/compile";
    DependencyNode node = parser.parseLiteral("gid:aid:ext:ver:compile");
    node.setRequestContext("project");
    DependencyNode refinedNode = refiner.transformGraph(node, context);
    assertEquals(expected, refinedNode.getRequestContext());
    node = parser.parseLiteral("gid:aid:ext:ver:system");
    node.setRequestContext("project");
    refinedNode = refiner.transformGraph(node, context);
    assertEquals(expected, refinedNode.getRequestContext());
    node = parser.parseLiteral("gid:aid:ext:ver:provided");
    node.setRequestContext("project");
    refinedNode = refiner.transformGraph(node, context);
    assertEquals(expected, refinedNode.getRequestContext());
}
Also used : DependencyNode(org.sonatype.aether.graph.DependencyNode) Test(org.junit.Test)

Example 75 with DependencyNode

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

the class JavaDependencyContextRefinerTest method testRefineToRuntime.

@Test
public void testRefineToRuntime() throws IOException, RepositoryException {
    String expected = "project/runtime";
    DependencyNode node = parser.parseLiteral("gid:aid:ext:ver:runtime");
    node.setRequestContext("project");
    DependencyNode refinedNode = refiner.transformGraph(node, context);
    assertEquals(expected, refinedNode.getRequestContext());
}
Also used : DependencyNode(org.sonatype.aether.graph.DependencyNode) 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