Search in sources :

Example 81 with DependencyNode

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

the class NearestVersionConflictResolverTest method testCyclicGraph.

@Test
public void testCyclicGraph() throws Exception {
    DependencyNode root = new DependencyGraphParser("transformer/version-resolver/").parse("cycle.txt");
    root = new SimpleConflictMarker().transformGraph(root, context);
    root = new NearestVersionConflictResolver().transformGraph(root, context);
    assertEquals(2, root.getChildren().size());
    assertEquals(1, root.getChildren().get(0).getChildren().size());
    assertEquals(0, root.getChildren().get(0).getChildren().get(0).getChildren().size());
    assertEquals(0, root.getChildren().get(1).getChildren().size());
}
Also used : DependencyGraphParser(org.sonatype.aether.test.util.DependencyGraphParser) DependencyNode(org.sonatype.aether.graph.DependencyNode) Test(org.junit.Test)

Example 82 with DependencyNode

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

the class AndDependencyFilterTest method acceptTest.

@Test
public void acceptTest() {
    NodeBuilder builder = new NodeBuilder();
    builder.artifactId("test");
    List<DependencyNode> parents = new LinkedList<DependencyNode>();
    // Empty AND
    assertTrue(new AndDependencyFilter().accept(builder.build(), parents));
    // Basic Boolean Input
    assertTrue(new AndDependencyFilter(getAcceptFilter()).accept(builder.build(), parents));
    assertFalse(new AndDependencyFilter(getDenyFilter()).accept(builder.build(), parents));
    assertFalse(new AndDependencyFilter(getDenyFilter(), getDenyFilter()).accept(builder.build(), parents));
    assertFalse(new AndDependencyFilter(getDenyFilter(), getAcceptFilter()).accept(builder.build(), parents));
    assertFalse(new AndDependencyFilter(getAcceptFilter(), getDenyFilter()).accept(builder.build(), parents));
    assertTrue(new AndDependencyFilter(getAcceptFilter(), getAcceptFilter()).accept(builder.build(), parents));
    assertFalse(new AndDependencyFilter(getDenyFilter(), getDenyFilter(), getDenyFilter()).accept(builder.build(), parents));
    assertFalse(new AndDependencyFilter(getAcceptFilter(), getDenyFilter(), getDenyFilter()).accept(builder.build(), parents));
    assertFalse(new AndDependencyFilter(getAcceptFilter(), getAcceptFilter(), getDenyFilter()).accept(builder.build(), parents));
    assertTrue(new AndDependencyFilter(getAcceptFilter(), getAcceptFilter(), getAcceptFilter()).accept(builder.build(), parents));
    // User another constructor
    Collection<DependencyFilter> filters = new LinkedList<DependencyFilter>();
    filters.add(getDenyFilter());
    filters.add(getAcceptFilter());
    assertFalse(new AndDependencyFilter(filters).accept(builder.build(), parents));
    filters = new LinkedList<DependencyFilter>();
    filters.add(getDenyFilter());
    filters.add(getDenyFilter());
    assertFalse(new AndDependencyFilter(filters).accept(builder.build(), parents));
    filters = new LinkedList<DependencyFilter>();
    filters.add(getAcceptFilter());
    filters.add(getAcceptFilter());
    assertTrue(new AndDependencyFilter(filters).accept(builder.build(), parents));
    // newInstance
    assertTrue(AndDependencyFilter.newInstance(getAcceptFilter(), getAcceptFilter()).accept(builder.build(), parents));
    assertFalse(AndDependencyFilter.newInstance(getAcceptFilter(), getDenyFilter()).accept(builder.build(), parents));
    assertFalse(AndDependencyFilter.newInstance(getDenyFilter(), null).accept(builder.build(), parents));
    assertTrue(AndDependencyFilter.newInstance(getAcceptFilter(), null).accept(builder.build(), parents));
    assertNull(AndDependencyFilter.newInstance(null, null));
}
Also used : DependencyNode(org.sonatype.aether.graph.DependencyNode) DependencyFilter(org.sonatype.aether.graph.DependencyFilter) NodeBuilder(org.sonatype.aether.test.util.NodeBuilder) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Example 83 with DependencyNode

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

the class ScopeDependencyFilterTest method acceptTest.

@Test
public void acceptTest() {
    NodeBuilder builder = new NodeBuilder();
    builder.scope("compile").artifactId("test");
    List<DependencyNode> parents = new LinkedList<DependencyNode>();
    // null or empty
    assertTrue(new ScopeDependencyFilter(null, null).accept(builder.build(), parents));
    assertTrue(new ScopeDependencyFilter(new LinkedList<String>(), new LinkedList<String>()).accept(builder.build(), parents));
    assertTrue(new ScopeDependencyFilter((String[]) null).accept(builder.build(), parents));
    //only excludes
    assertTrue(new ScopeDependencyFilter("test").accept(builder.build(), parents));
    assertFalse(new ScopeDependencyFilter("compile").accept(builder.build(), parents));
    assertFalse(new ScopeDependencyFilter("compile", "test").accept(builder.build(), parents));
    //Both
    String[] excludes1 = { "provided" };
    String[] includes1 = { "compile", "test" };
    assertTrue(new ScopeDependencyFilter(Arrays.asList(includes1), Arrays.asList(excludes1)).accept(builder.build(), parents));
    assertTrue(new ScopeDependencyFilter(Arrays.asList(includes1), null).accept(builder.build(), parents));
    //exclude wins
    String[] excludes2 = { "compile" };
    String[] includes2 = { "compile" };
    assertFalse(new ScopeDependencyFilter(Arrays.asList(includes2), Arrays.asList(excludes2)).accept(builder.build(), parents));
}
Also used : DependencyNode(org.sonatype.aether.graph.DependencyNode) NodeBuilder(org.sonatype.aether.test.util.NodeBuilder) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Example 84 with DependencyNode

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

the class PathRecordingDependencyVisitorTest method testGetPaths_DoesNotRecordMatchesBeneathMatchedParents.

@Test
public void testGetPaths_DoesNotRecordMatchesBeneathMatchedParents() throws Exception {
    DependencyNode root = parse("nested.txt");
    PathRecordingDependencyVisitor visitor = new PathRecordingDependencyVisitor(new ArtifactMatcher());
    root.accept(visitor);
    List<List<DependencyNode>> paths = visitor.getPaths();
    assertEquals(paths.toString(), 1, paths.size());
    assertPath(paths.get(0), "x");
}
Also used : DependencyNode(org.sonatype.aether.graph.DependencyNode) List(java.util.List) Test(org.junit.Test)

Example 85 with DependencyNode

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

the class PreorderNodeListGeneratorTest method testOrdering.

@Test
public void testOrdering() throws Exception {
    DependencyNode root = parse("simple.txt");
    PreorderNodeListGenerator visitor = new PreorderNodeListGenerator();
    root.accept(visitor);
    assertSequence(visitor.getNodes(), "a", "b", "c", "d", "e");
}
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