garydgregory commented on a change in pull request #126:
URL:
https://github.com/apache/commons-collections/pull/126#discussion_r413879724
##########
File path: src/test/java/org/apache/commons/collections4/MapUtilsTest.java
##########
@@ -146,19 +147,36 @@ public void testInvertMap() {
final Set<String> inKeySet = new HashSet<>(in.keySet());
final Set<String> inValSet = new HashSet<>(in.values());
- final Map<String, String> out = MapUtils.invertMap(in);
+ final Map<String, String> out = MapUtils.invertMap(in);
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"));
- assertEquals( "4", out.get("D"));
- assertEquals( "5", out.get("E"));
+ assertEquals("1", out.get("A"));
+ assertEquals("2", out.get("B"));
+ assertEquals("3", out.get("C"));
+ assertEquals("4", out.get("D"));
+ assertEquals("5", out.get("E"));
+ }
+
+ @Test
+ public void testInvertEmptyMap() {
+ Map<String, String> emptyMap = new HashMap<>();
+ Map<String, String> resultMap = MapUtils.invertMap(emptyMap);
+ assertEquals(emptyMap, resultMap);
+ }
+
+ @Test
+ public void testInvertMapNull() {
+ try {
+ MapUtils.invertMap(null);
+ fail("Expecting NullPointerException for null map");
+ } catch (final NullPointerException ex) {
+ // expected
+ }
Review comment:
Now that we depend on JUnit 5, you can/should test exceptions the with
JUnit 5 APIs:
https://junit.org/junit5/docs/current/user-guide/#writing-tests-assertions
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]