elharo commented on code in PR #1339:
URL: 
https://github.com/apache/maven-assembly-plugin/pull/1339#discussion_r3719919487


##########
src/test/java/org/apache/maven/plugins/assembly/artifact/DefaultDependencyResolverTest.java:
##########
@@ -113,21 +116,56 @@ void getDependencySetResolutionRequirementsTransitive() 
throws Exception {
     @Test
     void getDependencySetResolutionRequirementsNonTransitive() throws 
Exception {
         final DependencySet ds = new DependencySet();
-        ds.setScope(Artifact.SCOPE_SYSTEM);
+        ds.setScope(Artifact.SCOPE_RUNTIME);
         ds.setUseTransitiveDependencies(false);
 
         final MavenProject project = createMavenProject("main-group", 
"main-artifact", "1", null);
 
-        Set<Artifact> dependencyArtifacts = new HashSet<>();
-        dependencyArtifacts.add(newArtifact("g.id", "a-id", "1"));
-        Set<Artifact> artifacts = new HashSet<>(dependencyArtifacts);
-        artifacts.add(newArtifact("g.id", "a-id-2", "2"));
-        project.setArtifacts(artifacts);
-        project.setDependencyArtifacts(dependencyArtifacts);
+        Artifact directArtifact = newArtifact("g.id", "direct", "1");
+        DefaultDependencyNode directNode = new DefaultDependencyNode(new 
Dependency(
+                new 
org.eclipse.aether.artifact.DefaultArtifact("g.id:direct:1").setFile(new 
File(".")), "runtime"));
+        DefaultDependencyNode transitiveNode = new DefaultDependencyNode(new 
Dependency(
+                new 
org.eclipse.aether.artifact.DefaultArtifact("g.id:transitive:1").setFile(new 
File(".")),
+                "runtime"));
+        directNode.setChildren(Collections.singletonList(transitiveNode));
+
+        DependencyResult dependencyResult = new DependencyResult(new 
DependencyRequest());
+        DefaultDependencyNode rootDependencyNode = new 
DefaultDependencyNode((Dependency) null);
+        rootDependencyNode.setChildren(Collections.singletonList(directNode));
+        dependencyResult.setRoot(rootDependencyNode);
+
+        when(repositorySystem.resolveDependencies(eq(systemSession), 
any())).thenReturn(dependencyResult);
 
         final ResolutionManagementInfo info = new ResolutionManagementInfo();
         resolver.updateDependencySetResolutionRequirements(systemSession, ds, 
info, project);
-        assertEquals(dependencyArtifacts, info.getArtifacts());
+        assertEquals(Collections.singleton(directArtifact), 
info.getArtifacts());
+
+        ArgumentCaptor<DependencyRequest> requestCaptor = 
ArgumentCaptor.forClass(DependencyRequest.class);
+        verify(repositorySystem).resolveDependencies(eq(systemSession), 
requestCaptor.capture());
+        DependencyFilter filter = requestCaptor.getValue().getFilter();
+
+        assertTrue(filter.accept(directNode, 
Collections.singletonList(rootDependencyNode)));
+        assertTrue(filter.accept(directNode, Arrays.asList(directNode, 
rootDependencyNode)));
+        assertFalse(filter.accept(transitiveNode, Arrays.asList(directNode, 
rootDependencyNode)));
+        assertFalse(filter.accept(transitiveNode, 
Arrays.asList(transitiveNode, directNode, rootDependencyNode)));
+    }
+
+    @Test
+    void 
getDependencySetResolutionRequirementsNonTransitiveWithoutDependencies() throws 
Exception {
+        final DependencySet ds = new DependencySet();
+        ds.setScope(Artifact.SCOPE_SYSTEM);
+        ds.setUseTransitiveDependencies(false);
+
+        final MavenProject project = createMavenProject("main-group", 
"empty-pom", "1", null);
+        project.setDependencyArtifacts(null);

Review Comment:
   anyway to avoid adding a new call to this deprecated method?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to