Skip to content

Commit d5b37fa

Browse files
committed
tests has been added and split
1 parent e82e621 commit d5b37fa

File tree

2 files changed

+15
-16
lines changed

2 files changed

+15
-16
lines changed

java-collections-maps-3/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
This module contains articles about Map data structures in Java.
44

55
### Relevant Articles:
6-
- [Java Map With Case-Insensitive Keys](https://www.baeldung.com/java-map-case-insensitive-keys)
6+
- [Java Map With Case-Insensitive Keys](https://www.baeldung.com/java-map-with-case-insensitive-keys/)
77
- More articles: [[<-- prev>]](/../java-collections-maps)
88
- More articles: [[<-- prev>]](/../java-collections-maps-2)

java-collections-maps-3/src/test/java/com/baeldung/map/caseinsensitivekeys/CaseInsensitiveMapUnitTest.java

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
package com.baeldung.map.caseinsensitivekeys;
22

33
import org.apache.commons.collections4.map.CaseInsensitiveMap;
4-
import org.junit.Assert;
54
import org.junit.Test;
65
import org.springframework.util.LinkedCaseInsensitiveMap;
7-
import static org.junit.Assert.*;
8-
6+
import java.util.Map;
97
import java.util.TreeMap;
8+
import static org.junit.Assert.*;
109

1110
public class CaseInsensitiveMapUnitTest {
1211
@Test
1312
public void givenCaseInsensitiveTreeMap_whenTwoEntriesAdded_thenSizeIsOne(){
14-
TreeMap<String, Integer> treeMap = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
13+
Map<String, Integer> treeMap = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
1514
treeMap.put("abc", 1);
1615
treeMap.put("ABC", 2);
1716

@@ -21,7 +20,7 @@ public void givenCaseInsensitiveTreeMap_whenTwoEntriesAdded_thenSizeIsOne(){
2120

2221
@Test
2322
public void givenCommonsCaseInsensitiveMap_whenTwoEntriesAdded_thenSizeIsOne(){
24-
CaseInsensitiveMap<String, Integer> commonsHashMap = new CaseInsensitiveMap<>();
23+
Map<String, Integer> commonsHashMap = new CaseInsensitiveMap<>();
2524
commonsHashMap.put("abc", 1);
2625
commonsHashMap.put("ABC", 2);
2726

@@ -41,20 +40,20 @@ public void givenLinkedCaseInsensitiveMap_whenTwoEntriesAdded_thenSizeIsOne(){
4140

4241
@Test
4342
public void givenCaseInsensitiveTreeMap_whenSameEntryAdded_thenValueUpdated(){
44-
TreeMap<String, Integer> treeMap = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
43+
Map<String, Integer> treeMap = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
4544
treeMap.put("abc", 1);
4645
treeMap.put("ABC", 2);
4746

48-
Assert.assertEquals((Integer)2, treeMap.get("aBc"));
47+
assertEquals((Integer)2, treeMap.get("aBc"));
4948
}
5049

5150
@Test
5251
public void givenCommonsCaseInsensitiveMap_whenSameEntryAdded_thenValueUpdated(){
53-
CaseInsensitiveMap<String, Integer> commonsHashMap = new CaseInsensitiveMap<>();
52+
Map<String, Integer> commonsHashMap = new CaseInsensitiveMap<>();
5453
commonsHashMap.put("abc", 1);
5554
commonsHashMap.put("ABC", 2);
5655

57-
Assert.assertEquals((Integer)2, commonsHashMap.get("aBc"));
56+
assertEquals((Integer)2, commonsHashMap.get("aBc"));
5857
}
5958

6059
@Test
@@ -63,25 +62,25 @@ public void givenLinkedCaseInsensitiveMap_whenSameEntryAdded_thenValueUpdated(){
6362
linkedHashMap.put("abc", 1);
6463
linkedHashMap.put("ABC", 2);
6564

66-
Assert.assertEquals((Integer)2, linkedHashMap.get("aBc"));
65+
assertEquals((Integer)2, linkedHashMap.get("aBc"));
6766
}
6867

6968
@Test
7069
public void givenCaseInsensitiveTreeMap_whenEntryRemoved_thenSizeIsZero(){
71-
TreeMap<String, Integer> treeMap = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
70+
Map<String, Integer> treeMap = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
7271
treeMap.put("abc", 3);
7372
treeMap.remove("aBC");
7473

75-
Assert.assertEquals(0, treeMap.size());
74+
assertEquals(0, treeMap.size());
7675
}
7776

7877
@Test
7978
public void givenCommonsCaseInsensitiveMap_whenEntryRemoved_thenSizeIsZero(){
80-
CaseInsensitiveMap<String, Integer> commonsHashMap = new CaseInsensitiveMap<>();
79+
Map<String, Integer> commonsHashMap = new CaseInsensitiveMap<>();
8180
commonsHashMap.put("abc", 3);
8281
commonsHashMap.remove("aBC");
8382

84-
Assert.assertEquals(0, commonsHashMap.size());
83+
assertEquals(0, commonsHashMap.size());
8584
}
8685

8786
@Test
@@ -90,6 +89,6 @@ public void givenLinkedCaseInsensitiveMap_whenEntryRemoved_thenSizeIsZero(){
9089
linkedHashMap.put("abc", 3);
9190
linkedHashMap.remove("aBC");
9291

93-
Assert.assertEquals(0, linkedHashMap.size());
92+
assertEquals(0, linkedHashMap.size());
9493
}
9594
}

0 commit comments

Comments
 (0)