use of org.sonatype.aether.graph.DependencyNode in project sonatype-aether by sonatype.
the class JavaEffectiveScopeCalculatorTest method expectScope.
private void expectScope(String msg, String expected, DependencyNode root, int... coords) {
if (msg == null) {
msg = "";
}
try {
DependencyNode node = root;
node = path(node, coords);
assertEquals(msg + "\nculprit: " + node.toString() + "\n", expected, node.getDependency().getScope());
} catch (IndexOutOfBoundsException e) {
throw new IllegalArgumentException("Illegal coordinates for child", e);
} catch (NullPointerException e) {
throw new IllegalArgumentException("Illegal coordinates for child", e);
}
}
use of org.sonatype.aether.graph.DependencyNode in project sonatype-aether by sonatype.
the class JavaEffectiveScopeCalculatorTest method testConflictScopeOrdering.
@Test
public void testConflictScopeOrdering() throws RepositoryException, IOException {
for (Scope scope1 : Scope.values()) {
for (Scope scope2 : Scope.values()) {
parser.setSubstitutions(scope1.toString(), scope2.toString());
DependencyNode root = parser.parse("dueling-scopes.txt");
String expected = scope1.compareTo(scope2) >= 0 ? scope1.toString() : scope2.toString();
String msg = String.format("expected '%s' to win\n" + parser.dump(root), expected);
root = transform(root);
msg += "\ntransformed:\n" + parser.dump(root);
expectScope(msg, expected, root, 0, 0);
expectScope(msg, expected, root, 1, 0);
}
}
}
use of org.sonatype.aether.graph.DependencyNode in project sonatype-aether by sonatype.
the class JavaEffectiveScopeCalculatorTest method testCycleD.
@Test
public void testCycleD() throws Exception {
DependencyNode root = parser.parse("cycle-d.txt");
root = transform(root);
expectScope("compile", root, 0);
expectScope("compile", root, 0, 0);
expectScope("compile", root, 0, 0, 0);
}
use of org.sonatype.aether.graph.DependencyNode in project sonatype-aether by sonatype.
the class JavaEffectiveScopeCalculatorTest method testCycleB.
@Test
public void testCycleB() throws Exception {
DependencyNode root = parser.parse("cycle-b.txt");
root = transform(root);
expectScope("runtime", root, 0);
expectScope("compile", root, 0, 0);
expectScope("compile", root, 1);
expectScope("runtime", root, 1, 0);
}
use of org.sonatype.aether.graph.DependencyNode in project sonatype-aether by sonatype.
the class NearestVersionConflictResolverTest method testSelectHighestVersionFromMultipleVersionsAtSameLevel.
@Test
public void testSelectHighestVersionFromMultipleVersionsAtSameLevel() throws Exception {
// root
// +- a:1
// +- a:3
// \- a:2
DependencyNode a1 = builder.artifactId("a").version("1").build();
DependencyNode a2 = builder.artifactId("a").version("2").build();
DependencyNode a3 = builder.artifactId("a").version("3").build();
DependencyNode root = builder.artifactId(null).build();
root.getChildren().add(a1);
root.getChildren().add(a3);
root.getChildren().add(a2);
Map<DependencyNode, Object> conflictIds = new IdentityHashMap<DependencyNode, Object>();
conflictIds.put(a1, "a");
conflictIds.put(a2, "a");
conflictIds.put(a3, "a");
context.put(TransformationContextKeys.CONFLICT_IDS, conflictIds);
NearestVersionConflictResolver transformer = new NearestVersionConflictResolver();
root = transformer.transformGraph(root, context);
assertEquals(1, root.getChildren().size());
assertSame(a3, root.getChildren().iterator().next());
}
Aggregations