This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-lang.git


The following commit(s) were added to refs/heads/master by this push:
     new 2aded9825 Fixed two non-deterministic tests in EnumUtilsTest.java 
(#1131)
2aded9825 is described below

commit 2aded9825f5019933a9b37bf6280d00b8a2b730a
Author: Saiharshith Karuneegar Ramesh 
<[email protected]>
AuthorDate: Tue Nov 21 20:08:58 2023 -0600

    Fixed two non-deterministic tests in EnumUtilsTest.java (#1131)
    
    * Fixed non-deterministic tests
    
    * Made the requested changes
---
 .../org/apache/commons/lang3/EnumUtilsTest.java    | 23 +++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)

diff --git a/src/test/java/org/apache/commons/lang3/EnumUtilsTest.java 
b/src/test/java/org/apache/commons/lang3/EnumUtilsTest.java
index 20cf5ae62..c465072e8 100644
--- a/src/test/java/org/apache/commons/lang3/EnumUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/EnumUtilsTest.java
@@ -27,6 +27,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.EnumSet;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.function.Function;
@@ -340,7 +341,11 @@ public class EnumUtilsTest extends AbstractLangTest {
     @Test
     public void test_getEnumMap() {
         final Map<String, Traffic> test = EnumUtils.getEnumMap(Traffic.class);
-        assertEquals("{RED=RED, AMBER=AMBER, GREEN=GREEN}", test.toString(), 
"getEnumMap not created correctly");
+        final Map<String, Traffic> expected = new HashMap<>();
+        expected.put("RED", Traffic.RED);
+        expected.put("AMBER", Traffic.AMBER);
+        expected.put("GREEN", Traffic.GREEN);
+        assertEquals(expected, test, "getEnumMap not created correctly");
         assertEquals(3, test.size());
         assertTrue(test.containsKey("RED"));
         assertEquals(Traffic.RED, test.get("RED"));
@@ -354,8 +359,20 @@ public class EnumUtilsTest extends AbstractLangTest {
     @Test
     public void test_getEnumMap_keyFunction() {
         final Map<Integer, Month> test = EnumUtils.getEnumMap(Month.class, 
Month::getId);
-        assertEquals("{1=JAN, 2=FEB, 3=MAR, 4=APR, 5=MAY, 6=JUN, 7=JUL, 8=AUG, 
9=SEP, 10=OCT, 11=NOV, 12=DEC}", test.toString(),
-                "getEnumMap not created correctly");
+        final Map<Integer, Month> expected = new HashMap<>();
+        expected.put(1, Month.JAN);
+        expected.put(2, Month.FEB);
+        expected.put(3, Month.MAR);
+        expected.put(4, Month.APR);
+        expected.put(5, Month.MAY);
+        expected.put(6, Month.JUN);
+        expected.put(7, Month.JUL);
+        expected.put(8, Month.AUG);
+        expected.put(9, Month.SEP);
+        expected.put(10, Month.OCT);
+        expected.put(11, Month.NOV);
+        expected.put(12, Month.DEC);
+        assertEquals(expected, test, "getEnumMap not created correctly");
         assertEquals(12, test.size());
         assertFalse(test.containsKey(0));
         assertTrue(test.containsKey(1));

Reply via email to