Copilot commented on code in PR #1664:
URL: 
https://github.com/apache/maven-dependency-plugin/pull/1664#discussion_r3605324650


##########
src/test/java/org/apache/maven/plugins/dependency/utils/ResolverUtilTest.java:
##########
@@ -105,4 +120,22 @@ void prepareRepositoryWithNull() {
                 .isExactlyInstanceOf(NullPointerException.class)
                 .hasMessage("repository must be not null");
     }
+
+    @Test
+    void resolveArtifactWithFallbackWhenDescriptorCannotBeRead() throws 
Exception {
+        Artifact artifact = new DefaultArtifact("groupId", "artifactId", null, 
"jar", "1.0");
+        ArtifactDescriptorRequest descriptorRequest = new 
ArtifactDescriptorRequest();
+        ArtifactDescriptorException descriptorException =
+                new ArtifactDescriptorException(new 
ArtifactDescriptorResult(descriptorRequest));
+        ArtifactResult artifactResult = new ArtifactResult(new 
ArtifactRequest()).setArtifact(artifact);
+
+        
when(repositorySystem.readArtifactDescriptor(eq(repositorySystemSession), 
any(ArtifactDescriptorRequest.class)))
+                .thenThrow(descriptorException);
+        when(repositorySystem.resolveArtifact(eq(repositorySystemSession), 
any(ArtifactRequest.class)))
+                .thenReturn(artifactResult);
+
+        assertThat(resolverUtil.resolveArtifactWithFallback(artifact, 
Collections.emptyList(), repositorySystemSession))
+                .isSameAs(artifact);
+        verify(repositorySystem).resolveArtifact(eq(repositorySystemSession), 
any(ArtifactRequest.class));
+    }

Review Comment:
   The new test stubs `readArtifactDescriptor()` to throw, but it never asserts 
that this method was actually invoked. Adding an explicit `verify` makes the 
test fail if the implementation regresses to skipping descriptor resolution 
entirely (which would undermine the stated goal of preserving descriptor-based 
relocation when available).



##########
src/it/projects/copy-broken-parent/pom.xml:
##########
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied.  See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+<project xmlns="http://maven.apache.org/POM/4.0.0";
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
https://maven.apache.org/xsd/maven-4.0.0.xsd";>
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.apache.maven.its.dependency</groupId>
+  <artifactId>copy-broken-parent</artifactId>
+  <version>1.0-SNAPSHOT</version>
+
+  <build>
+    <plugins>
+      <plugin>
+        <artifactId>maven-dependency-plugin</artifactId>
+        <version>@project.version@</version>
+        <executions>
+          <execution>
+            <id>copy</id>
+            <goals>
+              <goal>copy</goal>
+            </goals>
+            <configuration>
+              <artifactItems>
+                <artifactItem>
+                  <groupId>org.apache.maven.its.dependency</groupId>
+                  <artifactId>broken-parent-artifact</artifactId>
+                  <version>1.0</version>
+                  <type>pom</type>
+                </artifactItem>

Review Comment:
   This IT reproducer validates `dependency:copy` for a POM artifact with a 
missing parent, but the reported regression (and the code change) also targets 
`dependency:unpack` and archive artifacts. Consider extending IT coverage with 
an `unpack` execution against a mock JAR/ZIP whose POM references an 
unavailable parent, to ensure the fallback is wired end-to-end for the unpack 
goal as well.



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