Search in sources :

Example 46 with DependencyNode

use of org.eclipse.aether.graph.DependencyNode in project maven-resolver by apache.

the class SimpleOptionalitySelectorTest method testDeriveOptionality.

@Test
public void testDeriveOptionality() throws Exception {
    DependencyNode root = parseResource("derive.txt");
    assertSame(root, transform(root));
    assertEquals(2, root.getChildren().size());
    assertTrue(root.getChildren().get(0).getDependency().isOptional());
    assertTrue(root.getChildren().get(0).getChildren().get(0).getDependency().isOptional());
    assertFalse(root.getChildren().get(1).getDependency().isOptional());
    assertFalse(root.getChildren().get(1).getChildren().get(0).getDependency().isOptional());
}
Also used : DependencyNode(org.eclipse.aether.graph.DependencyNode) Test(org.junit.Test)

Example 47 with DependencyNode

use of org.eclipse.aether.graph.DependencyNode in project maven-resolver by apache.

the class SimpleOptionalitySelectorTest method testResolveOptionalityConflict_NonOptionalWins.

@Test
public void testResolveOptionalityConflict_NonOptionalWins() throws Exception {
    DependencyNode root = parseResource("conflict.txt");
    assertSame(root, transform(root));
    assertEquals(2, root.getChildren().size());
    assertTrue(root.getChildren().get(0).getDependency().isOptional());
    assertFalse(root.getChildren().get(0).getChildren().get(0).getDependency().isOptional());
}
Also used : DependencyNode(org.eclipse.aether.graph.DependencyNode) Test(org.junit.Test)

Example 48 with DependencyNode

use of org.eclipse.aether.graph.DependencyNode in project maven-resolver by apache.

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<>();
    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(null).accept(builder.build(), parents));
}
Also used : ExclusionsDependencyFilter(org.eclipse.aether.util.filter.ExclusionsDependencyFilter) DependencyNode(org.eclipse.aether.graph.DependencyNode) NodeBuilder(org.eclipse.aether.internal.test.util.NodeBuilder) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Example 49 with DependencyNode

use of org.eclipse.aether.graph.DependencyNode in project maven-resolver by apache.

the class OrDependencyFilterTest method acceptTest.

@Test
public void acceptTest() {
    NodeBuilder builder = new NodeBuilder();
    builder.artifactId("test");
    List<DependencyNode> parents = new LinkedList<>();
    // 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<>();
    filters.add(getDenyFilter());
    filters.add(getAcceptFilter());
    assertTrue(new OrDependencyFilter(filters).accept(builder.build(), parents));
    filters = new LinkedList<>();
    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 : OrDependencyFilter(org.eclipse.aether.util.filter.OrDependencyFilter) DependencyNode(org.eclipse.aether.graph.DependencyNode) DependencyFilter(org.eclipse.aether.graph.DependencyFilter) OrDependencyFilter(org.eclipse.aether.util.filter.OrDependencyFilter) AndDependencyFilter(org.eclipse.aether.util.filter.AndDependencyFilter) NodeBuilder(org.eclipse.aether.internal.test.util.NodeBuilder) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Example 50 with DependencyNode

use of org.eclipse.aether.graph.DependencyNode in project maven-resolver by apache.

the class PatternExclusionsDependencyFilterTest 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();
    assertFalse("OTHER.GROUP.ID:testArtifact:jar:1.0.3", dontAccept(node, "OTHER.GROUP.ID:testArtifact:jar:1.0.3"));
    assertFalse("com.example.test:OTHER_ARTIFACT:jar:1.0.3", dontAccept(node, "com.example.test:OTHER_ARTIFACT:jar:1.0.3"));
    assertFalse("com.example.test:OTHER_ARTIFACT:jar:1.0.3", dontAccept(node, "com.example.test:OTHER_ARTIFACT:jar:1.0.3"));
    assertFalse("com.example.test:testArtifact:WAR:1.0.3", dontAccept(node, "com.example.test:testArtifact:WAR:1.0.3"));
    assertFalse("com.example.test:testArtifact:jar:SNAPSHOT", dontAccept(node, "com.example.test:testArtifact:jar:SNAPSHOT"));
    assertFalse("*:*:war:*", dontAccept(node, "*:*:war:*"));
    assertFalse("OTHER.GROUP.ID", dontAccept(node, "OTHER.GROUP.ID"));
}
Also used : DependencyNode(org.eclipse.aether.graph.DependencyNode) NodeBuilder(org.eclipse.aether.internal.test.util.NodeBuilder) Test(org.junit.Test)

Aggregations

DependencyNode (org.eclipse.aether.graph.DependencyNode)258 Test (org.junit.Test)107 Artifact (org.eclipse.aether.artifact.Artifact)63 Dependency (org.eclipse.aether.graph.Dependency)59 DefaultArtifact (org.eclipse.aether.artifact.DefaultArtifact)56 DefaultDependencyNode (org.eclipse.aether.graph.DefaultDependencyNode)53 CollectRequest (org.eclipse.aether.collection.CollectRequest)52 ArrayList (java.util.ArrayList)39 IOException (java.io.IOException)29 List (java.util.List)27 CollectResult (org.eclipse.aether.collection.CollectResult)24 DependencyCollectionException (org.eclipse.aether.collection.DependencyCollectionException)22 DependencyRequest (org.eclipse.aether.resolution.DependencyRequest)22 PreorderNodeListGenerator (org.eclipse.aether.util.graph.visitor.PreorderNodeListGenerator)20 RemoteRepository (org.eclipse.aether.repository.RemoteRepository)19 Path (java.nio.file.Path)18 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)18 File (java.io.File)17 DependencyFilter (org.eclipse.aether.graph.DependencyFilter)17 Map (java.util.Map)16