Search in sources :

Example 11 with NodeBuilder

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

the class PatternInclusionsDependencyFilterTest 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, accept(node, "com.example.test:testArtifact:jar"));
    assertEquals("com.example.test:testArtifact", true, accept(node, "com.example.test:testArtifact"));
    assertEquals("com.example.test", true, accept(node, "com.example.test"));
    assertEquals("com.example.foo", false, accept(node, "com.example.foo"));
}
Also used : DependencyNode(org.sonatype.aether.graph.DependencyNode) NodeBuilder(org.sonatype.aether.test.util.NodeBuilder) Test(org.junit.Test)

Example 12 with NodeBuilder

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

the class PatternInclusionsDependencyFilterTest method acceptTestRange.

@Test
public void acceptTestRange() {
    NodeBuilder builder = new NodeBuilder();
    builder.groupId("com.example.test").artifactId("testArtifact").ext("jar").version("1.0.3");
    DependencyNode node = builder.build();
    String prefix = "com.example.test:testArtifact:jar:";
    assertTrue(prefix + "[1.0.3,1.0.4)", acceptVersionRange(node, prefix + "[1.0.3,1.0.4)"));
    assertTrue(prefix + "[1.0.3,)", acceptVersionRange(node, prefix + "[1.0.3,)"));
    assertTrue(prefix + "[1.0.3,]", acceptVersionRange(node, prefix + "[1.0.3,]"));
    assertTrue(prefix + "(,1.0.3]", acceptVersionRange(node, prefix + "(,1.0.3]"));
    assertTrue(prefix + "[1.0,]", acceptVersionRange(node, prefix + "[1.0,]"));
    assertTrue(prefix + "[1,4]", acceptVersionRange(node, prefix + "[1,4]"));
    assertTrue(prefix + "(1,4)", acceptVersionRange(node, prefix + "(1,4)"));
    assertTrue(prefix + "(1.0.2,1.0.3]", acceptVersionRange(node, prefix + "(1.0.2,1.0.3]", prefix + "(1.1,)"));
    assertFalse(prefix + "(1.0.3,2.0]", acceptVersionRange(node, prefix + "(1.0.3,2.0]"));
    assertFalse(prefix + "(1,1.0.2]", acceptVersionRange(node, prefix + "(1,1.0.2]"));
    assertFalse(prefix + "(1.0.2,1.0.3)", acceptVersionRange(node, prefix + "(1.0.2,1.0.3)", prefix + "(1.0.3,)"));
}
Also used : DependencyNode(org.sonatype.aether.graph.DependencyNode) NodeBuilder(org.sonatype.aether.test.util.NodeBuilder) Test(org.junit.Test)

Example 13 with NodeBuilder

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

the class DependencyFilterUtilsTest method testClasspathFilterUnknownScope.

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

Example 14 with NodeBuilder

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

the class DependencyFilterUtilsTest method testClasspathFilterRuntimeCommaSystem.

@Test
public void testClasspathFilterRuntimeCommaSystem() {
    NodeBuilder builder = new NodeBuilder().artifactId("aid");
    DependencyFilter filter = DependencyFilterUtils.classpathFilter("runtime,system");
    assertTrue(filter.accept(builder.scope("compile").build(), PARENTS));
    assertTrue(filter.accept(builder.scope("system").build(), PARENTS));
    assertFalse(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 15 with NodeBuilder

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

the class ConflictMarkerTest method testRelocation3.

@Test
public void testRelocation3() throws Exception {
    NodeBuilder builder = new NodeBuilder();
    DependencyNode root = builder.build();
    root.getChildren().add(builder.artifactId("a").build());
    root.getChildren().add(builder.artifactId("b").build());
    root.getChildren().add(builder.artifactId("c").reloc("a").reloc("b").build());
    DependencyGraphTransformationContext context = newContext();
    assertSame(root, new ConflictMarker().transformGraph(root, context));
    Map<?, ?> ids = (Map<?, ?>) context.get(TransformationContextKeys.CONFLICT_IDS);
    assertNotNull(ids);
    assertNull(ids.get(root));
    assertNotNull(ids.get(root.getChildren().get(0)));
    assertNotNull(ids.get(root.getChildren().get(1)));
    assertNotNull(ids.get(root.getChildren().get(2)));
    assertSame(ids.get(root.getChildren().get(0)), ids.get(root.getChildren().get(1)));
    assertSame(ids.get(root.getChildren().get(1)), ids.get(root.getChildren().get(2)));
}
Also used : DependencyGraphTransformationContext(org.sonatype.aether.collection.DependencyGraphTransformationContext) DependencyNode(org.sonatype.aether.graph.DependencyNode) ConflictMarker(org.sonatype.aether.util.graph.transformer.ConflictMarker) NodeBuilder(org.sonatype.aether.test.util.NodeBuilder) Map(java.util.Map) 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