Search in sources :

Example 21 with NodeBuilder

use of org.sonatype.aether.test.util.NodeBuilder in project sonatype-aether by sonatype.

the class DependencyFilterUtilsTest method testClasspathFilterTest.

@Test
public void testClasspathFilterTest() {
    NodeBuilder builder = new NodeBuilder().artifactId("aid");
    DependencyFilter filter = DependencyFilterUtils.classpathFilter("test");
    assertTrue(filter.accept(builder.scope("compile").build(), PARENTS));
    assertTrue(filter.accept(builder.scope("system").build(), PARENTS));
    assertTrue(filter.accept(builder.scope("provided").build(), PARENTS));
    assertTrue(filter.accept(builder.scope("runtime").build(), PARENTS));
    assertTrue(filter.accept(builder.scope("test").build(), PARENTS));
}
Also used : DependencyFilter(org.sonatype.aether.graph.DependencyFilter) NodeBuilder(org.sonatype.aether.test.util.NodeBuilder) Test(org.junit.Test)

Example 22 with NodeBuilder

use of org.sonatype.aether.test.util.NodeBuilder in project sonatype-aether by sonatype.

the class DependencyFilterUtilsTest method testClasspathFilterNull.

@Test
public void testClasspathFilterNull() {
    NodeBuilder builder = new NodeBuilder().artifactId("aid");
    DependencyFilter filter = DependencyFilterUtils.classpathFilter((String[]) null);
    assertFalse(filter.accept(builder.scope("compile").build(), PARENTS));
    assertFalse(filter.accept(builder.scope("system").build(), PARENTS));
    assertFalse(filter.accept(builder.scope("provided").build(), PARENTS));
    assertFalse(filter.accept(builder.scope("runtime").build(), PARENTS));
    assertFalse(filter.accept(builder.scope("test").build(), PARENTS));
}
Also used : DependencyFilter(org.sonatype.aether.graph.DependencyFilter) NodeBuilder(org.sonatype.aether.test.util.NodeBuilder) Test(org.junit.Test)

Example 23 with NodeBuilder

use of org.sonatype.aether.test.util.NodeBuilder 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 24 with NodeBuilder

use of org.sonatype.aether.test.util.NodeBuilder in project sonatype-aether by sonatype.

the class DependencyFilterUtilsTest method testClasspathFilterCompilePlusRuntime.

@Test
public void testClasspathFilterCompilePlusRuntime() {
    NodeBuilder builder = new NodeBuilder().artifactId("aid");
    DependencyFilter filter = DependencyFilterUtils.classpathFilter("compile+runtime");
    assertTrue(filter.accept(builder.scope("compile").build(), PARENTS));
    assertTrue(filter.accept(builder.scope("system").build(), PARENTS));
    assertTrue(filter.accept(builder.scope("provided").build(), PARENTS));
    assertTrue(filter.accept(builder.scope("runtime").build(), PARENTS));
    assertFalse(filter.accept(builder.scope("test").build(), PARENTS));
}
Also used : DependencyFilter(org.sonatype.aether.graph.DependencyFilter) NodeBuilder(org.sonatype.aether.test.util.NodeBuilder) Test(org.junit.Test)

Example 25 with NodeBuilder

use of org.sonatype.aether.test.util.NodeBuilder in project sonatype-aether by sonatype.

the class PatternExclusionsDependencyFilterTest method acceptTestMatches.

@Test
public void acceptTestMatches() {
    NodeBuilder builder = new NodeBuilder();
    builder.groupId("com.example.test").artifactId("testArtifact").ext("jar").version("1.0.3");
    DependencyNode node = builder.build();
    // full match
    assertEquals("com.example.test:testArtifact:jar:1.0.3", true, dontAccept(node, "com.example.test:testArtifact:jar:1.0.3"));
    // single wildcard
    assertEquals("*:testArtifact:jar:1.0.3", true, dontAccept(node, "*:testArtifact:jar:1.0.3"));
    assertEquals("com.example.test:*:jar:1.0.3", true, dontAccept(node, "com.example.test:*:jar:1.0.3"));
    assertEquals("com.example.test:testArtifact:*:1.0.3", true, dontAccept(node, "com.example.test:testArtifact:*:1.0.3"));
    assertEquals("com.example.test:testArtifact:*:1.0.3", true, dontAccept(node, "com.example.test:testArtifact:*:1.0.3"));
    // implicit wildcard
    assertEquals(":testArtifact:jar:1.0.3", true, dontAccept(node, ":testArtifact:jar:1.0.3"));
    assertEquals("com.example.test::jar:1.0.3", true, dontAccept(node, "com.example.test::jar:1.0.3"));
    assertEquals("com.example.test:testArtifact::1.0.3", true, dontAccept(node, "com.example.test:testArtifact::1.0.3"));
    assertEquals("com.example.test:testArtifact:jar:", true, dontAccept(node, "com.example.test:testArtifact:jar:"));
    // multi wildcards
    assertEquals("*:*:jar:1.0.3", true, dontAccept(node, "*:*:jar:1.0.3"));
    assertEquals("com.example.test:*:*:1.0.3", true, dontAccept(node, "com.example.test:*:*:1.0.3"));
    assertEquals("com.example.test:testArtifact:*:*", true, dontAccept(node, "com.example.test:testArtifact:*:*"));
    assertEquals("*:testArtifact:jar:*", true, dontAccept(node, "*:testArtifact:jar:*"));
    assertEquals("*:*:jar:*", true, dontAccept(node, "*:*:jar:*"));
    assertEquals(":*:jar:", true, dontAccept(node, ":*:jar:"));
    // partial wildcards
    assertEquals("*.example.test:testArtifact:jar:1.0.3", true, dontAccept(node, "*.example.test:testArtifact:jar:1.0.3"));
    assertEquals("com.example.test:testArtifact:*ar:1.0.*", true, dontAccept(node, "com.example.test:testArtifact:*ar:1.0.*"));
    assertEquals("com.example.test:testArtifact:jar:1.0.*", true, dontAccept(node, "com.example.test:testArtifact:jar:1.0.*"));
    assertEquals("*.example.*:testArtifact:jar:1.0.3", true, dontAccept(node, "*.example.*:testArtifact:jar:1.0.3"));
    // wildcard as empty string
    assertEquals("com.example.test*:testArtifact:jar:1.0.3", true, dontAccept(node, "com.example.test*:testArtifact:jar:1.0.3"));
}
Also used : DependencyNode(org.sonatype.aether.graph.DependencyNode) NodeBuilder(org.sonatype.aether.test.util.NodeBuilder) Test(org.junit.Test)

Aggregations

NodeBuilder (org.sonatype.aether.test.util.NodeBuilder)29 Test (org.junit.Test)28 DependencyNode (org.sonatype.aether.graph.DependencyNode)20 DependencyFilter (org.sonatype.aether.graph.DependencyFilter)10 LinkedList (java.util.LinkedList)6 Map (java.util.Map)4 DependencyGraphTransformationContext (org.sonatype.aether.collection.DependencyGraphTransformationContext)4 ConflictMarker (org.sonatype.aether.util.graph.transformer.ConflictMarker)4 Before (org.junit.Before)1