Copilot commented on code in PR #268:
URL: 
https://github.com/apache/maven-source-plugin/pull/268#discussion_r3369862278


##########
src/test/java/org/apache/maven/plugins/source/TestSourceJarMojoTest.java:
##########
@@ -138,18 +147,17 @@ InternalSession createSession() {
         InternalSession session = 
SessionMock.getMockSession("target/local-repo");
         ProjectManager projectManager = mock(ProjectManager.class);
         
when(session.getService(ProjectManager.class)).thenReturn(projectManager);
-        when(projectManager.getCompileSourceRoots(any(), 
eq(ProjectScope.TEST))).thenAnswer(iom -> {
-            Project p = iom.getArgument(0, Project.class);
-            return Collections.singletonList(
-                    
Paths.get(getBasedir()).resolve(p.getModel().getBuild().getTestSourceDirectory()));
-        });
-        when(projectManager.getResources(any(), 
eq(ProjectScope.TEST))).thenAnswer(iom -> {
-            Project p = iom.getArgument(0, Project.class);
-            return p.getBuild().getTestResources().stream()
-                    .map(r -> r.withDirectory(
-                            
Paths.get(getBasedir()).resolve(r.getDirectory()).toString()))
-                    .toList();
-        });
+        when(projectManager.getEnabledSourceRoots(any(), 
eq(ProjectScope.TEST), any()))
+                .thenAnswer(iom -> {
+                    Project p = iom.getArgument(0, Project.class);
+                    DefaultSourceRoot sourceRoot = new DefaultSourceRoot(
+                            ProjectScope.MAIN,
+                            Language.JAVA_FAMILY,

Review Comment:
   The test is stubbing `ProjectManager.getEnabledSourceRoots(..., 
ProjectScope.TEST, ...)`, but the returned `DefaultSourceRoot` is constructed 
with `ProjectScope.MAIN`. This makes the stub internally inconsistent and may 
break if Maven starts validating the returned roots’ scope (or if production 
code relies on the root’s scope).



-- 
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