gnodet commented on code in PR #11509:
URL: https://github.com/apache/maven/pull/11509#discussion_r3369563647


##########
impl/maven-core/src/test/java/org/apache/maven/plugin/CacheUtilsTest.java:
##########
@@ -0,0 +1,123 @@
+/*
+ * 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.
+ */
+package org.apache.maven.plugin;
+
+import org.apache.maven.model.Dependency;
+import org.apache.maven.model.Plugin;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+class CacheUtilsTest {
+
+    private Plugin pluginOne = new Plugin();
+    private Plugin pluginTwo = new Plugin();
+
+    @Test
+    void testPluginEqualsEmptyPlugins() {
+        assertTrue(CacheUtils.pluginEquals(pluginOne, pluginOne));
+        assertTrue(CacheUtils.pluginEquals(pluginOne, pluginTwo));
+    }
+
+    @Test
+    void testPluginEqualsSetArtifactId() {
+        pluginOne.setArtifactId("myArtifact");
+
+        assertTrue(CacheUtils.pluginEquals(pluginOne, pluginOne));
+        assertFalse(CacheUtils.pluginEquals(pluginOne, pluginTwo));
+
+        pluginTwo.setArtifactId("myArtifact");
+
+        assertTrue(CacheUtils.pluginEquals(pluginOne, pluginOne));
+        assertTrue(CacheUtils.pluginEquals(pluginOne, pluginTwo));
+    }
+
+    @Test
+    void testPluginEqualsSetGroupId() {
+        pluginOne.setGroupId("myGroupId");
+
+        assertTrue(CacheUtils.pluginEquals(pluginOne, pluginOne));
+        assertFalse(CacheUtils.pluginEquals(pluginOne, pluginTwo));
+
+        pluginTwo.setGroupId("myGroupId");
+
+        assertTrue(CacheUtils.pluginEquals(pluginOne, pluginOne));
+        assertTrue(CacheUtils.pluginEquals(pluginOne, pluginTwo));
+    }
+
+    @Test
+    void testPluginEqualsSetVersion() {
+        pluginOne.setVersion("myVersion");
+
+        assertTrue(CacheUtils.pluginEquals(pluginOne, pluginOne));
+        assertFalse(CacheUtils.pluginEquals(pluginOne, pluginTwo));
+
+        pluginTwo.setVersion("myVersion");
+
+        assertTrue(CacheUtils.pluginEquals(pluginOne, pluginOne));
+        assertTrue(CacheUtils.pluginEquals(pluginOne, pluginTwo));
+    }
+
+    @Test
+    void testPluginEqualsSetExtension() {
+        pluginOne.setExtensions("true");
+

Review Comment:
   The test sets `pluginTwo.setExtensions("TRUE")` but never asserts anything 
after it. Since `isExtensions()` delegates to `Boolean.parseBoolean()` which is 
case-insensitive, both plugins should now have `isExtensions() == true` and 
`pluginEquals` should return `true`. Please add the missing assertion:
   
   ```suggestion
           pluginTwo.setExtensions("TRUE");
   
           assertTrue(CacheUtils.pluginEquals(pluginOne, pluginOne));
           assertTrue(CacheUtils.pluginEquals(pluginOne, pluginTwo));
   ```



##########
impl/maven-core/src/test/java/org/apache/maven/plugin/CacheUtilsTest.java:
##########
@@ -0,0 +1,123 @@
+/*
+ * 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.
+ */
+package org.apache.maven.plugin;
+
+import org.apache.maven.model.Dependency;
+import org.apache.maven.model.Plugin;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+class CacheUtilsTest {
+
+    private Plugin pluginOne = new Plugin();
+    private Plugin pluginTwo = new Plugin();
+
+    @Test
+    void testPluginEqualsEmptyPlugins() {
+        assertTrue(CacheUtils.pluginEquals(pluginOne, pluginOne));
+        assertTrue(CacheUtils.pluginEquals(pluginOne, pluginTwo));
+    }
+
+    @Test
+    void testPluginEqualsSetArtifactId() {
+        pluginOne.setArtifactId("myArtifact");
+
+        assertTrue(CacheUtils.pluginEquals(pluginOne, pluginOne));
+        assertFalse(CacheUtils.pluginEquals(pluginOne, pluginTwo));
+
+        pluginTwo.setArtifactId("myArtifact");
+
+        assertTrue(CacheUtils.pluginEquals(pluginOne, pluginOne));
+        assertTrue(CacheUtils.pluginEquals(pluginOne, pluginTwo));
+    }
+
+    @Test
+    void testPluginEqualsSetGroupId() {
+        pluginOne.setGroupId("myGroupId");
+
+        assertTrue(CacheUtils.pluginEquals(pluginOne, pluginOne));
+        assertFalse(CacheUtils.pluginEquals(pluginOne, pluginTwo));
+
+        pluginTwo.setGroupId("myGroupId");
+
+        assertTrue(CacheUtils.pluginEquals(pluginOne, pluginOne));
+        assertTrue(CacheUtils.pluginEquals(pluginOne, pluginTwo));
+    }
+
+    @Test
+    void testPluginEqualsSetVersion() {
+        pluginOne.setVersion("myVersion");
+
+        assertTrue(CacheUtils.pluginEquals(pluginOne, pluginOne));
+        assertFalse(CacheUtils.pluginEquals(pluginOne, pluginTwo));
+
+        pluginTwo.setVersion("myVersion");
+
+        assertTrue(CacheUtils.pluginEquals(pluginOne, pluginOne));
+        assertTrue(CacheUtils.pluginEquals(pluginOne, pluginTwo));
+    }
+
+    @Test
+    void testPluginEqualsSetExtension() {
+        pluginOne.setExtensions("true");
+
+        assertTrue(CacheUtils.pluginEquals(pluginOne, pluginOne));
+        assertFalse(CacheUtils.pluginEquals(pluginOne, pluginTwo));
+
+        pluginTwo.setExtensions("TRUE");
+    }
+
+    @Test
+    void testPluginEqualsSetDependency() {
+        Dependency dependencyOne = new Dependency();
+        pluginOne.addDependency(dependencyOne);
+
+        assertTrue(CacheUtils.pluginEquals(pluginOne, pluginOne));
+        assertFalse(CacheUtils.pluginEquals(pluginOne, pluginTwo));
+
+        Dependency dependencyTwo = new Dependency();
+        pluginTwo.addDependency(dependencyTwo);
+
+        assertTrue(CacheUtils.pluginEquals(pluginOne, pluginOne));
+        assertTrue(CacheUtils.pluginEquals(pluginOne, pluginTwo));
+
+        dependencyTwo.setGroupId("myDependencyGroupId");
+
+        assertTrue(CacheUtils.pluginEquals(pluginOne, pluginOne));
+        assertFalse(CacheUtils.pluginEquals(pluginOne, pluginTwo));
+
+        dependencyOne.setGroupId("myDependencyGroupId");
+        dependencyTwo.setArtifactId("myDependencyArtifactId");
+
+        assertTrue(CacheUtils.pluginEquals(pluginOne, pluginOne));
+        assertFalse(CacheUtils.pluginEquals(pluginOne, pluginTwo));
+
+        dependencyTwo.setVersion("myDependencyVersion");
+
+        assertTrue(CacheUtils.pluginEquals(pluginOne, pluginOne));
+        assertFalse(CacheUtils.pluginEquals(pluginOne, pluginTwo));
+
+        dependencyOne.setArtifactId("myDependencyArtifactId");

Review Comment:
   Line 115 (`dependencyTwo.setVersion("myDependencyVersion")`) is redundant -- 
this was already set on line 110. It looks like the intended line was 
`dependencyOne.setVersion("myDependencyVersion")` to bring both dependencies 
back to equality, followed by a `assertTrue` to verify convergence. As written, 
the test never verifies that two dependencies with identical fields are 
considered equal (after the initial empty-dependency case).
   
   Also consider testing the remaining fields compared by 
`dependenciesEquals()`: `type`, `classifier`, `scope`, and `exclusions`.



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