Search in sources :

Example 11 with DependencyNode

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

the class DependencyGraphParserTest method testOnlyRoot.

@Test
public void testOnlyRoot() throws IOException {
    String def = "gid:aid:jar:1:scope";
    DependencyNode node = parser.parseLiteral(def);
    assertNotNull(node);
    assertEquals(0, node.getChildren().size());
    Dependency dependency = node.getDependency();
    assertNotNull(dependency);
    assertEquals("scope", dependency.getScope());
    Artifact artifact = dependency.getArtifact();
    assertNotNull(artifact);
    assertEquals("gid", artifact.getGroupId());
    assertEquals("aid", artifact.getArtifactId());
    assertEquals("jar", artifact.getExtension());
    assertEquals("1", artifact.getVersion());
}
Also used : DependencyNode(org.sonatype.aether.graph.DependencyNode) Dependency(org.sonatype.aether.graph.Dependency) Artifact(org.sonatype.aether.artifact.Artifact) Test(org.junit.Test)

Example 12 with DependencyNode

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

the class DependencyGraphParserTest method testResourceLoading.

@Test
public void testResourceLoading() throws UnsupportedEncodingException, IOException {
    String prefix = "org/sonatype/aether/test/util/";
    String name = "testResourceLoading.txt";
    DependencyNode node = parser.parse(prefix + name);
    assertEquals(0, node.getChildren().size());
    assertNodeProperties(node, "");
}
Also used : DependencyNode(org.sonatype.aether.graph.DependencyNode) Test(org.junit.Test)

Example 13 with DependencyNode

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

the class DependencyGraphParserTest method testDeepChildren.

@Test
public void testDeepChildren() throws IOException {
    String def = "gid1:aid1:ext1:ver1\n" + "+- gid2:aid2:ext2:ver2:scope2\n" + "|  \\- gid3:aid3:ext3:ver3\n" + "\\- gid4:aid4:ext4:ver4:scope4";
    DependencyNode node = parser.parseLiteral(def);
    assertNodeProperties(node, 1);
    assertEquals(2, node.getChildren().size());
    assertNodeProperties(node.getChildren().get(1), 4);
    DependencyNode lvl1Node = node.getChildren().get(0);
    assertNodeProperties(lvl1Node, 2);
    assertEquals(1, lvl1Node.getChildren().size());
    assertNodeProperties(lvl1Node.getChildren().get(0), 3);
}
Also used : DependencyNode(org.sonatype.aether.graph.DependencyNode) Test(org.junit.Test)

Example 14 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)

Example 15 with DependencyNode

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

the class DefaultDependencyCollectorTest method testCyclicDependencies.

@Test
public void testCyclicDependencies() throws Exception {
    DependencyNode root = parser.parse("cycle.txt");
    CollectRequest request = new CollectRequest(root.getDependency(), Arrays.asList(repository));
    CollectResult result = collector.collectDependencies(session, request);
    assertEqualSubtree(root, result.getRoot());
}
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