Search in sources :

Example 6 with NodeBuilder

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

Example 7 with NodeBuilder

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

the class PatternExclusionsDependencyFilterTest method acceptTestCornerCases.

@Test
public void acceptTestCornerCases() {
    NodeBuilder builder = new NodeBuilder();
    builder.artifactId("testArtifact");
    DependencyNode node = builder.build();
    List<DependencyNode> parents = new LinkedList<DependencyNode>();
    // Empty String, Empty List
    assertTrue(dontAccept(node, ""));
    assertTrue(new PatternExclusionsDependencyFilter(new LinkedList<String>()).accept(node, parents));
    assertTrue(new PatternExclusionsDependencyFilter((String[]) null).accept(node, parents));
    assertTrue(new PatternExclusionsDependencyFilter((VersionScheme) null, "[1,10]").accept(node, 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 8 with NodeBuilder

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

the class PatternExclusionsDependencyFilterTest method acceptTestLessToken.

@Test
public void acceptTestLessToken() {
    NodeBuilder builder = new NodeBuilder();
    builder.groupId("com.example.test").artifactId("testArtifact").ext("jar").version("1.0.3");
    DependencyNode node = builder.build();
    assertEquals("com.example.test:testArtifact:jar", true, dontAccept(node, "com.example.test:testArtifact:jar"));
    assertEquals("com.example.test:testArtifact", true, dontAccept(node, "com.example.test:testArtifact"));
    assertEquals("com.example.test", true, dontAccept(node, "com.example.test"));
    assertEquals("com.example.foo", false, dontAccept(node, "com.example.foo"));
}
Also used : DependencyNode(org.sonatype.aether.graph.DependencyNode) NodeBuilder(org.sonatype.aether.test.util.NodeBuilder) Test(org.junit.Test)

Example 9 with NodeBuilder

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

the class PatternInclusionsDependencyFilterTest method acceptTestMoreToken.

@Test
public void acceptTestMoreToken() {
    NodeBuilder builder = new NodeBuilder();
    builder.groupId("com.example.test").artifactId("testArtifact").ext("jar").version("1.0.3");
    DependencyNode node = builder.build();
    assertEquals("com.example.test:testArtifact:jar:1.0.3:foo", false, accept(node, "com.example.test:testArtifact:jar:1.0.3:foo"));
}
Also used : DependencyNode(org.sonatype.aether.graph.DependencyNode) NodeBuilder(org.sonatype.aether.test.util.NodeBuilder) Test(org.junit.Test)

Example 10 with NodeBuilder

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

the class PatternInclusionsDependencyFilterTest method acceptTestMissmatch.

@Test
public void acceptTestMissmatch() {
    NodeBuilder builder = new NodeBuilder();
    builder.groupId("com.example.test").artifactId("testArtifact").ext("jar").version("1.0.3");
    DependencyNode node = builder.build();
    assertEquals("OTHER.GROUP.ID:testArtifact:jar:1.0.3", false, accept(node, "OTHER.GROUP.ID:testArtifact:jar:1.0.3"));
    assertEquals("com.example.test:OTHER_ARTIFACT:jar:1.0.3", false, accept(node, "com.example.test:OTHER_ARTIFACT:jar:1.0.3"));
    assertEquals("com.example.test:OTHER_ARTIFACT:jar:1.0.3", false, accept(node, "com.example.test:OTHER_ARTIFACT:jar:1.0.3"));
    assertEquals("com.example.test:testArtifact:WAR:1.0.3", false, accept(node, "com.example.test:testArtifact:WAR:1.0.3"));
    assertEquals("com.example.test:testArtifact:jar:SNAPSHOT", false, accept(node, "com.example.test:testArtifact:jar:SNAPSHOT"));
    assertEquals("*:*:war:*", false, accept(node, "*:*:war:*"));
    assertEquals("OTHER.GROUP.ID", false, accept(node, "OTHER.GROUP.ID"));
}
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