Skip to content

Commit 5bbadab

Browse files
committed
Add MapUtilsTest.testInvertMapDefault()
1 parent 494d5e9 commit 5bbadab

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

src/test/java/org/apache/commons/collections4/MapUtilsTest.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -628,31 +628,37 @@ void testInvertEmptyMap() {
628628

629629
@Test
630630
void testInvertMap() {
631-
final Map<String, String> in = new HashMap<>(5, 1);
631+
testInvertMap(new HashMap<>(5, 1));
632+
}
633+
634+
private void testInvertMap(final Map<String, String> in) {
635+
// setup
632636
in.put("1", "A");
633637
in.put("2", "B");
634638
in.put("3", "C");
635639
in.put("4", "D");
636640
in.put("5", "E");
637-
638641
final Set<String> inKeySet = new HashSet<>(in.keySet());
639642
final Set<String> inValSet = new HashSet<>(in.values());
640-
643+
// invert
641644
final Map<String, String> out = MapUtils.invertMap(in);
642-
645+
// assert
643646
final Set<String> outKeySet = new HashSet<>(out.keySet());
644647
final Set<String> outValSet = new HashSet<>(out.values());
645-
646648
assertEquals(inKeySet, outValSet);
647649
assertEquals(inValSet, outKeySet);
648-
649650
assertEquals("1", out.get("A"));
650651
assertEquals("2", out.get("B"));
651652
assertEquals("3", out.get("C"));
652653
assertEquals("4", out.get("D"));
653654
assertEquals("5", out.get("E"));
654655
}
655656

657+
@Test
658+
void testInvertMapDefault() {
659+
testInvertMap(new HashMap<>());
660+
}
661+
656662
@Test
657663
void testInvertMapNull() {
658664
final Map<String, String> nullMap = null;

0 commit comments

Comments
 (0)