use of org.sonatype.aether.graph.DependencyNode in project sonatype-aether by sonatype.
the class NearestVersionConflictResolverTest method testUnsolvableRangeConflictBetweenHardConstraints.
@Test(expected = UnsolvableVersionConflictException.class)
public void testUnsolvableRangeConflictBetweenHardConstraints() throws Exception {
// root
// +- b:1
// | \- a:[1]
// \- c:1
// \- a:[2]
DependencyNode a1 = builder.artifactId("a").version("1").range("[1]").build();
DependencyNode a2 = builder.artifactId("a").version("2").range("[2]").build();
DependencyNode b = builder.artifactId("b").version("1").build();
DependencyNode c = builder.artifactId("c").version("1").build();
b.getChildren().add(a1);
c.getChildren().add(a2);
DependencyNode root = builder.artifactId(null).build();
root.getChildren().add(b);
root.getChildren().add(c);
Map<DependencyNode, Object> conflictIds = new IdentityHashMap<DependencyNode, Object>();
conflictIds.put(a1, "a");
conflictIds.put(a2, "a");
conflictIds.put(b, "b");
conflictIds.put(c, "c");
context.put(TransformationContextKeys.CONFLICT_IDS, conflictIds);
NearestVersionConflictResolver transformer = new NearestVersionConflictResolver();
root = transformer.transformGraph(root, context);
}
use of org.sonatype.aether.graph.DependencyNode in project sonatype-aether by sonatype.
the class NearestVersionConflictResolverTest method testSelectedVersionAtDeeperLevelThanOriginallySeen.
@Test
public void testSelectedVersionAtDeeperLevelThanOriginallySeen() throws Exception {
// root
// +- a
// | \- b:1 # will be removed in favor of b:2
// | \- j:1 # nearest version of j in dirty tree
// +- c
// | \- d
// | \- e
// | \- j:1
// \- b:2
DependencyNode j = builder.artifactId("j").build();
DependencyNode b1 = builder.artifactId("b").version("1").build();
b1.getChildren().add(j);
DependencyNode a = builder.artifactId("a").build();
a.getChildren().add(b1);
DependencyNode e = builder.artifactId("e").build();
e.getChildren().add(j);
DependencyNode d = builder.artifactId("d").build();
d.getChildren().add(e);
DependencyNode c = builder.artifactId("c").build();
c.getChildren().add(d);
DependencyNode b2 = builder.artifactId("b").version("2").build();
DependencyNode root = builder.artifactId(null).build();
root.getChildren().add(a);
root.getChildren().add(c);
root.getChildren().add(b2);
Map<DependencyNode, Object> conflictIds = new IdentityHashMap<DependencyNode, Object>();
conflictIds.put(j, "j");
conflictIds.put(a, "a");
conflictIds.put(b1, "b");
conflictIds.put(b2, "b");
conflictIds.put(c, "c");
conflictIds.put(d, "d");
conflictIds.put(e, "e");
context.put(TransformationContextKeys.CONFLICT_IDS, conflictIds);
NearestVersionConflictResolver transformer = new NearestVersionConflictResolver();
root = transformer.transformGraph(root, context);
List<DependencyNode> trail = find(root, "j");
assertEquals(5, trail.size());
}
use of org.sonatype.aether.graph.DependencyNode in project sonatype-aether by sonatype.
the class PatternInclusionsDependencyFilterTest 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(accept(node, ""));
assertFalse(new PatternInclusionsDependencyFilter(new LinkedList<String>()).accept(node, parents));
assertFalse(new PatternInclusionsDependencyFilter((String[]) null).accept(node, parents));
assertFalse(new PatternInclusionsDependencyFilter((VersionScheme) null, "[1,10]").accept(node, parents));
}
use of org.sonatype.aether.graph.DependencyNode in project sonatype-aether by sonatype.
the class FilteringDependencyVisitorTest method testFilterCalledWithProperParentStack.
@Test
public void testFilterCalledWithProperParentStack() throws Exception {
DependencyNode root = parse("parents.txt");
final StringBuilder buffer = new StringBuilder(256);
DependencyFilter filter = new DependencyFilter() {
public boolean accept(DependencyNode node, List<DependencyNode> parents) {
for (DependencyNode parent : parents) {
buffer.append(parent.getDependency().getArtifact().getArtifactId());
}
buffer.append(",");
return false;
}
};
FilteringDependencyVisitor visitor = new FilteringDependencyVisitor(new PreorderNodeListGenerator(), filter);
root.accept(visitor);
assertEquals(",a,ba,cba,a,ea,", buffer.toString());
}
use of org.sonatype.aether.graph.DependencyNode in project sonatype-aether by sonatype.
the class PathRecordingDependencyVisitorTest method testFilterCalledWithProperParentStack.
@Test
public void testFilterCalledWithProperParentStack() throws Exception {
DependencyNode root = parse("parents.txt");
final StringBuilder buffer = new StringBuilder(256);
DependencyFilter filter = new DependencyFilter() {
public boolean accept(DependencyNode node, List<DependencyNode> parents) {
for (DependencyNode parent : parents) {
buffer.append(parent.getDependency().getArtifact().getArtifactId());
}
buffer.append(",");
return false;
}
};
PathRecordingDependencyVisitor visitor = new PathRecordingDependencyVisitor(filter);
root.accept(visitor);
assertEquals(",a,ba,cba,a,ea,", buffer.toString());
}
Aggregations