Search in sources :

Example 16 with NodeBuilder

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

the class AbstractDependencyGraphTransformerTest method setUp.

@Before
public void setUp() {
    builder = new NodeBuilder();
    context = newContext();
}
Also used : NodeBuilder(org.sonatype.aether.test.util.NodeBuilder) Before(org.junit.Before)

Example 17 with NodeBuilder

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

the class ConflictMarkerTest method testRelocation2.

@Test
public void testRelocation2() throws Exception {
    NodeBuilder builder = new NodeBuilder();
    DependencyNode root = builder.build();
    root.getChildren().add(builder.artifactId("a").reloc("reloc").build());
    root.getChildren().add(builder.artifactId("a").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)));
    assertSame(ids.get(root.getChildren().get(0)), ids.get(root.getChildren().get(1)));
}
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)

Example 18 with NodeBuilder

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

the class ConflictMarkerTest method testRelocation1.

@Test
public void testRelocation1() throws Exception {
    NodeBuilder builder = new NodeBuilder();
    DependencyNode root = builder.build();
    root.getChildren().add(builder.artifactId("a").build());
    root.getChildren().add(builder.artifactId("a").reloc("reloc").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)));
    assertSame(ids.get(root.getChildren().get(0)), ids.get(root.getChildren().get(1)));
}
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)

Example 19 with NodeBuilder

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

the class ConflictMarkerTest method testSimple.

@Test
public void testSimple() throws Exception {
    NodeBuilder builder = new NodeBuilder();
    DependencyNode root = builder.build();
    root.getChildren().add(builder.artifactId("a").build());
    root.getChildren().add(builder.artifactId("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)));
    assertNotSame(ids.get(root.getChildren().get(0)), ids.get(root.getChildren().get(1)));
    assertFalse(ids.get(root.getChildren().get(0)).equals(ids.get(root.getChildren().get(1))));
}
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)

Example 20 with NodeBuilder

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

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