gnodet-bot commented on code in PR #2338:
URL: https://github.com/apache/maven-resolver/pull/2338#discussion_r4648191005


##########
maven-resolver-util/src/test/java/org/eclipse/aether/util/DirectoryUtilsTest.java:
##########
@@ -110,10 +111,18 @@ public void notExistsAndIsCreated() throws IOException {
         // hack for surefire: sets the property but directory may not exist
         
Files.createDirectories(Paths.get(System.getProperty("java.io.tmpdir")));
 
-        Path tmpDir = Files.createTempDirectory(testName.getMethodName());
+        Path tmpDir = Files.createTempDirectory(testName);
         Files.createDirectories(tmpDir.resolve("foo"));
         Path result = DirectoryUtils.resolveDirectory("foo", tmpDir, true);
-        assertThat(result, equalTo(tmpDir.resolve("foo")));
-        assertThat(Files.isDirectory(tmpDir.resolve("foo")), equalTo(true));
+        assertEquals(result, tmpDir.resolve("foo"));
+        assertEquals(Files.isDirectory(tmpDir.resolve("foo")), true);

Review Comment:
   **`assertEquals(booleanExpr, true)` → `assertTrue`**
   
   ```java
   // Current:
   assertEquals(Files.isDirectory(tmpDir.resolve("foo")), true);
   
   // Better:
   assertTrue(Files.isDirectory(tmpDir.resolve("foo")));
   ```
   
   Also has the argument-order issue (boolean expression is the actual value). 
`assertTrue` is already imported and communicates intent more clearly.



##########
maven-resolver-util/src/test/java/org/eclipse/aether/util/DirectoryUtilsTest.java:
##########
@@ -19,40 +19,41 @@
 package org.eclipse.aether.util;
 
 import java.io.IOException;
+import java.lang.reflect.Method;
 import java.nio.file.FileSystems;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
+import java.util.Optional;
 
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TestName;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInfo;
 
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.equalTo;
-import static org.hamcrest.Matchers.startsWith;
-import static org.junit.Assume.assumeTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assumptions.assumeTrue;
 
 public class DirectoryUtilsTest {
-    @Rule
-    public TestName testName = new TestName();
+
+    private String testName;
 
     @Test
     public void expectedCasesRelative() throws IOException {
         // hack for surefire: sets the property but directory may not exist
         
Files.createDirectories(Paths.get(System.getProperty("java.io.tmpdir")));
 
-        Path tmpDir = Files.createTempDirectory(testName.getMethodName());
+        Path tmpDir = Files.createTempDirectory(testName);
         Path result;
 
         result = DirectoryUtils.resolveDirectory("foo", tmpDir, false);
-        assertThat(result, equalTo(tmpDir.resolve("foo")));
+        assertEquals(result, tmpDir.resolve("foo"));

Review Comment:
   **`assertEquals` argument order** (JUnit 5 convention)
   
   JUnit 5's `Assertions.assertEquals(expected, actual)` takes **expected 
first, actual second**. All 8 assertions in `DirectoryUtilsTest` have this 
reversed — `result` (the actual computed value) is in the first position:
   
   ```java
   // Current (wrong order):
   assertEquals(result, tmpDir.resolve("foo"));
   
   // Should be:
   assertEquals(tmpDir.resolve("foo"), result);
   ```
   
   Affects lines 50, 53, 56, 75, 78, 81, 92, 117 (all `assertEquals(result, 
...)` calls). The tests still pass because `assertEquals` checks equality 
either way, but the failure message will read "expected: <result> but was: 
<expected>" — the opposite of what you'd want when debugging.



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