Search in sources :

Example 46 with DependencyNode

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

the class PostorderNodeListGeneratorTest method assertSequence.

private void assertSequence(List<DependencyNode> actual, String... expected) {
    assertEquals(actual.toString(), expected.length, actual.size());
    for (int i = 0; i < expected.length; i++) {
        DependencyNode node = actual.get(i);
        assertEquals(actual.toString(), expected[i], node.getDependency().getArtifact().getArtifactId());
    }
}
Also used : DependencyNode(org.sonatype.aether.graph.DependencyNode)

Example 47 with DependencyNode

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

the class PreorderNodeListGeneratorTest method assertSequence.

private void assertSequence(List<DependencyNode> actual, String... expected) {
    assertEquals(actual.toString(), expected.length, actual.size());
    for (int i = 0; i < expected.length; i++) {
        DependencyNode node = actual.get(i);
        assertEquals(actual.toString(), expected[i], node.getDependency().getArtifact().getArtifactId());
    }
}
Also used : DependencyNode(org.sonatype.aether.graph.DependencyNode)

Example 48 with DependencyNode

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

the class PreorderNodeListGeneratorTest method testDuplicateSuppression.

@Test
public void testDuplicateSuppression() throws Exception {
    DependencyNode root = parse("cycles.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)

Example 49 with DependencyNode

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

the class ExclusionDependencyFilterTest method acceptTest.

@Test
public void acceptTest() {
    NodeBuilder builder = new NodeBuilder();
    builder.groupId("com.example.test").artifactId("testArtifact");
    List<DependencyNode> parents = new LinkedList<DependencyNode>();
    String[] excludes;
    excludes = new String[] { "com.example.test:testArtifact" };
    assertFalse(new ExclusionsDependencyFilter(Arrays.asList(excludes)).accept(builder.build(), parents));
    excludes = new String[] { "com.example.test:testArtifact", "com.foo:otherArtifact" };
    assertFalse(new ExclusionsDependencyFilter(Arrays.asList(excludes)).accept(builder.build(), parents));
    excludes = new String[] { "testArtifact" };
    assertFalse(new ExclusionsDependencyFilter(Arrays.asList(excludes)).accept(builder.build(), parents));
    excludes = new String[] { "otherArtifact" };
    assertTrue(new ExclusionsDependencyFilter(Arrays.asList(excludes)).accept(builder.build(), parents));
    assertTrue(new ExclusionsDependencyFilter((Collection<String>) null).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 50 with DependencyNode

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

the class OrDependencyFilterTest method acceptTest.

@Test
public void acceptTest() {
    NodeBuilder builder = new NodeBuilder();
    builder.artifactId("test");
    List<DependencyNode> parents = new LinkedList<DependencyNode>();
    // Empty OR
    assertFalse(new OrDependencyFilter().accept(builder.build(), parents));
    // Basic Boolean Input
    assertTrue(new OrDependencyFilter(getAcceptFilter()).accept(builder.build(), parents));
    assertFalse(new OrDependencyFilter(getDenyFilter()).accept(builder.build(), parents));
    assertFalse(new OrDependencyFilter(getDenyFilter(), getDenyFilter()).accept(builder.build(), parents));
    assertTrue(new OrDependencyFilter(getDenyFilter(), getAcceptFilter()).accept(builder.build(), parents));
    assertTrue(new OrDependencyFilter(getAcceptFilter(), getDenyFilter()).accept(builder.build(), parents));
    assertTrue(new OrDependencyFilter(getAcceptFilter(), getAcceptFilter()).accept(builder.build(), parents));
    assertFalse(new OrDependencyFilter(getDenyFilter(), getDenyFilter(), getDenyFilter()).accept(builder.build(), parents));
    assertTrue(new OrDependencyFilter(getAcceptFilter(), getDenyFilter(), getDenyFilter()).accept(builder.build(), parents));
    assertTrue(new OrDependencyFilter(getAcceptFilter(), getAcceptFilter(), getDenyFilter()).accept(builder.build(), parents));
    assertTrue(new OrDependencyFilter(getAcceptFilter(), getAcceptFilter(), getAcceptFilter()).accept(builder.build(), parents));
    // User another constructor
    Collection<DependencyFilter> filters = new LinkedList<DependencyFilter>();
    filters.add(getDenyFilter());
    filters.add(getAcceptFilter());
    assertTrue(new OrDependencyFilter(filters).accept(builder.build(), parents));
    filters = new LinkedList<DependencyFilter>();
    filters.add(getDenyFilter());
    filters.add(getDenyFilter());
    assertFalse(new OrDependencyFilter(filters).accept(builder.build(), parents));
    // newInstance
    assertTrue(AndDependencyFilter.newInstance(getAcceptFilter(), getAcceptFilter()).accept(builder.build(), parents));
    assertFalse(AndDependencyFilter.newInstance(getAcceptFilter(), getDenyFilter()).accept(builder.build(), parents));
    assertTrue(AndDependencyFilter.newInstance(getAcceptFilter(), null).accept(builder.build(), parents));
    assertFalse(AndDependencyFilter.newInstance(getDenyFilter(), 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)

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