use of org.sonatype.aether.graph.DependencyNode in project sonatype-aether by sonatype.
the class NearestVersionConflictResolverTest method testCyclicGraph.
@Test
public void testCyclicGraph() throws Exception {
DependencyNode root = new DependencyGraphParser("transformer/version-resolver/").parse("cycle.txt");
root = new SimpleConflictMarker().transformGraph(root, context);
root = new NearestVersionConflictResolver().transformGraph(root, context);
assertEquals(2, root.getChildren().size());
assertEquals(1, root.getChildren().get(0).getChildren().size());
assertEquals(0, root.getChildren().get(0).getChildren().get(0).getChildren().size());
assertEquals(0, root.getChildren().get(1).getChildren().size());
}
use of org.sonatype.aether.graph.DependencyNode 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));
}
use of org.sonatype.aether.graph.DependencyNode 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));
}
use of org.sonatype.aether.graph.DependencyNode in project sonatype-aether by sonatype.
the class PathRecordingDependencyVisitorTest method testGetPaths_DoesNotRecordMatchesBeneathMatchedParents.
@Test
public void testGetPaths_DoesNotRecordMatchesBeneathMatchedParents() throws Exception {
DependencyNode root = parse("nested.txt");
PathRecordingDependencyVisitor visitor = new PathRecordingDependencyVisitor(new ArtifactMatcher());
root.accept(visitor);
List<List<DependencyNode>> paths = visitor.getPaths();
assertEquals(paths.toString(), 1, paths.size());
assertPath(paths.get(0), "x");
}
use of org.sonatype.aether.graph.DependencyNode in project sonatype-aether by sonatype.
the class PreorderNodeListGeneratorTest method testOrdering.
@Test
public void testOrdering() throws Exception {
DependencyNode root = parse("simple.txt");
PreorderNodeListGenerator visitor = new PreorderNodeListGenerator();
root.accept(visitor);
assertSequence(visitor.getNodes(), "a", "b", "c", "d", "e");
}
Aggregations