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-collections.git
The following commit(s) were added to refs/heads/master by this push:
new 5bbadab33 Add MapUtilsTest.testInvertMapDefault()
5bbadab33 is described below
commit 5bbadab330e0f645f5c8176a631248906785824c
Author: Gary D. Gregory <[email protected]>
AuthorDate: Thu Oct 16 15:45:46 2025 -0400
Add MapUtilsTest.testInvertMapDefault()
---
.../org/apache/commons/collections4/MapUtilsTest.java | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/src/test/java/org/apache/commons/collections4/MapUtilsTest.java
b/src/test/java/org/apache/commons/collections4/MapUtilsTest.java
index 0dbeed254..51b71a6a2 100644
--- a/src/test/java/org/apache/commons/collections4/MapUtilsTest.java
+++ b/src/test/java/org/apache/commons/collections4/MapUtilsTest.java
@@ -628,24 +628,25 @@ class MapUtilsTest {
@Test
void testInvertMap() {
- final Map<String, String> in = new HashMap<>(5, 1);
+ testInvertMap(new HashMap<>(5, 1));
+ }
+
+ private void testInvertMap(final Map<String, String> in) {
+ // setup
in.put("1", "A");
in.put("2", "B");
in.put("3", "C");
in.put("4", "D");
in.put("5", "E");
-
final Set<String> inKeySet = new HashSet<>(in.keySet());
final Set<String> inValSet = new HashSet<>(in.values());
-
+ // invert
final Map<String, String> out = MapUtils.invertMap(in);
-
+ // assert
final Set<String> outKeySet = new HashSet<>(out.keySet());
final Set<String> outValSet = new HashSet<>(out.values());
-
assertEquals(inKeySet, outValSet);
assertEquals(inValSet, outKeySet);
-
assertEquals("1", out.get("A"));
assertEquals("2", out.get("B"));
assertEquals("3", out.get("C"));
@@ -653,6 +654,11 @@ class MapUtilsTest {
assertEquals("5", out.get("E"));
}
+ @Test
+ void testInvertMapDefault() {
+ testInvertMap(new HashMap<>());
+ }
+
@Test
void testInvertMapNull() {
final Map<String, String> nullMap = null;