Java Code Examples for org.eclipse.aether.graph.DefaultDependencyNode#setChildren()
The following examples show how to use
org.eclipse.aether.graph.DefaultDependencyNode#setChildren() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LinkageCheckerRuleTest.java From cloud-opensource-java with Apache License 2.0 | 5 votes |
@Test public void testArtifactTransferError_missingArtifactNotInGraph() throws URISyntaxException, DependencyResolutionException, EnforcerRuleException { // Creating a dummy tree // com.google.foo:project // +- com.google.foo:child1 (provided) // +- com.google.foo:child2 (optional) DefaultDependencyNode child2 = new DefaultDependencyNode( new Dependency( createArtifactWithDummyFile("com.google.foo:child2:1.0.0"), "compile", true)); DefaultDependencyNode child1 = new DefaultDependencyNode( new Dependency(createArtifactWithDummyFile("com.google.foo:child1:1.0.0"), "provided")); child1.setChildren(ImmutableList.of(child2)); DefaultDependencyNode root = new DefaultDependencyNode(createArtifactWithDummyFile("com.google.foo:project:1.0.0")); root.setChildren(ImmutableList.of(child1)); DependencyResolutionResult resolutionResult = mock(DependencyResolutionResult.class); when(resolutionResult.getDependencyGraph()).thenReturn(root); when(resolutionResult.getResolvedDependencies()) .thenReturn(ImmutableList.of(child1.getDependency(), child2.getDependency())); // The exception is caused by this node but this node does not appear in the dependency graph. DefaultDependencyNode missingArtifactNode = new DefaultDependencyNode( new Dependency( createArtifactWithDummyFile("xerces:xerces-impl:jar:2.6.2"), "compile", true)); // xerces-impl does not exist in Maven Central DependencyResolutionException exception = createDummyResolutionException(missingArtifactNode.getArtifact(), resolutionResult); when(mockProjectDependenciesResolver.resolve(any())).thenThrow(exception); rule.execute(mockRuleHelper); verify(mockLog) .warn("xerces:xerces-impl:jar:2.6.2 was not resolved. Dependency path is unknown."); }
Example 2
Source File: UniquePathRecordingDependencyVisitorTest.java From cloud-opensource-java with Apache License 2.0 | 5 votes |
@Test public void testVisitingUniqueNodes_twoPaths() { // This setup creates a dependency graph like below. There are two paths from the root to node // 'x': root-a-x and root-b-x. The two paths do not share intermediate nodes. // // root // / \ // a b // \ / // x DefaultDependencyNode root = new DefaultDependencyNode(new DefaultArtifact("g:r:1")); DefaultDependencyNode a = new DefaultDependencyNode(new DefaultArtifact("g:a:1")); DefaultDependencyNode b = new DefaultDependencyNode(new DefaultArtifact("g:b:1")); DefaultDependencyNode x = new DefaultDependencyNode(new DefaultArtifact("g:x:1")); root.setChildren(ImmutableList.of(a, b)); a.setChildren(ImmutableList.of(x)); b.setChildren(ImmutableList.of(x)); UniquePathRecordingDependencyVisitor visitor = new UniquePathRecordingDependencyVisitor( (DependencyNode node, List<DependencyNode> parents) -> node.getArtifact().getArtifactId().equals("x")); root.accept(visitor); ImmutableList<List<DependencyNode>> paths = visitor.getPaths(); Truth.assertThat(paths).hasSize(2); assertSame(root, paths.get(0).get(0)); assertSame(a, paths.get(0).get(1)); assertSame(x, paths.get(0).get(2)); assertSame(root, paths.get(1).get(0)); assertSame(b, paths.get(1).get(1)); assertSame(x, paths.get(1).get(2)); }
Example 3
Source File: UniquePathRecordingDependencyVisitorTest.java From cloud-opensource-java with Apache License 2.0 | 5 votes |
@Test public void testVisitingUniqueNodes() { // This setup creates a dependency graph like below. There are two paths from the root to node // 'y'. UniquePathRecordingDependencyVisitor does not record paths that have the same // intermediate node. // // root // / \ // a b // \ / // x // | // y DefaultDependencyNode root = new DefaultDependencyNode(new DefaultArtifact("g:r:1")); DefaultDependencyNode a = new DefaultDependencyNode(new DefaultArtifact("g:a:1")); DefaultDependencyNode b = new DefaultDependencyNode(new DefaultArtifact("g:b:1")); DefaultDependencyNode x = new DefaultDependencyNode(new DefaultArtifact("g:x:1")); DefaultDependencyNode y = new DefaultDependencyNode(new DefaultArtifact("g:y:1")); root.setChildren(ImmutableList.of(a, b)); a.setChildren(ImmutableList.of(x)); b.setChildren(ImmutableList.of(x)); x.setChildren(ImmutableList.of(y)); UniquePathRecordingDependencyVisitor visitor = new UniquePathRecordingDependencyVisitor( (DependencyNode node, List<DependencyNode> parents) -> node.getArtifact().getArtifactId().equals("y")); root.accept(visitor); ImmutableList<List<DependencyNode>> paths = visitor.getPaths(); Truth.assertThat(paths).hasSize(1); assertSame(root, paths.get(0).get(0)); assertSame(a, paths.get(0).get(1)); assertSame(x, paths.get(0).get(2)); assertSame(y, paths.get(0).get(3)); }
Example 4
Source File: GraphBuildingVisitorTest.java From depgraph-maven-plugin with Apache License 2.0 | 5 votes |
private static org.eclipse.aether.graph.DependencyNode createMavenDependencyNode(String artifactId, String scope, org.eclipse.aether.graph.DependencyNode... children) { Dependency dependency = new Dependency(createArtifact(artifactId), scope); DefaultDependencyNode node = new DefaultDependencyNode(dependency); node.setChildren(asList(children)); return node; }
Example 5
Source File: LinkageCheckerRuleTest.java From cloud-opensource-java with Apache License 2.0 | 4 votes |
@Test public void testArtifactTransferError_acceptableMissingArtifact() throws URISyntaxException, DependencyResolutionException, EnforcerRuleException { // Creating a dummy tree // com.google.foo:project // +- com.google.foo:child1 (provided) // +- com.google.foo:child2 (optional) // +- xerces:xerces-impl:jar:2.6.2 (optional) DefaultDependencyNode missingArtifactNode = new DefaultDependencyNode( new Dependency( createArtifactWithDummyFile("xerces:xerces-impl:jar:2.6.2"), "compile", true)); DefaultDependencyNode child2 = new DefaultDependencyNode( new Dependency( createArtifactWithDummyFile("com.google.foo:child2:1.0.0"), "compile", true)); child2.setChildren(ImmutableList.of(missingArtifactNode)); DefaultDependencyNode child1 = new DefaultDependencyNode( new Dependency(createArtifactWithDummyFile("com.google.foo:child1:1.0.0"), "provided")); child1.setChildren(ImmutableList.of(child2)); DefaultDependencyNode root = new DefaultDependencyNode(createArtifactWithDummyFile("com.google.foo:project:1.0.0")); root.setChildren(ImmutableList.of(child1)); DependencyResolutionResult resolutionResult = mock(DependencyResolutionResult.class); when(resolutionResult.getDependencyGraph()).thenReturn(root); when(resolutionResult.getResolvedDependencies()) .thenReturn( ImmutableList.of( child1.getDependency(), child2.getDependency(), missingArtifactNode.getDependency())); // xerces-impl does not exist in Maven Central DependencyResolutionException exception = createDummyResolutionException(missingArtifactNode.getArtifact(), resolutionResult); when(mockProjectDependenciesResolver.resolve(any())).thenThrow(exception); // Should not throw DependencyResolutionException, because the missing xerces-impl is under both // provided and optional dependencies. rule.execute(mockRuleHelper); }