BAEL-4686: fixed review comments
This commit is contained in:
parent
2f42035fb5
commit
a07e23dddd
@ -13,7 +13,7 @@ import org.junit.Test;
|
|||||||
public class NullAllowInMapUnitTest {
|
public class NullAllowInMapUnitTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void allowNullKey_In_HashMapBackedSynchronizedMap() {
|
public void givenHashMapBackedSynchronizedMap_whenNullAsKey_thenNoError() {
|
||||||
Map<String, Integer> map = Collections
|
Map<String, Integer> map = Collections
|
||||||
.synchronizedMap(new HashMap<String, Integer>());
|
.synchronizedMap(new HashMap<String, Integer>());
|
||||||
map.put(null, 1);
|
map.put(null, 1);
|
||||||
@ -22,14 +22,14 @@ public class NullAllowInMapUnitTest {
|
|||||||
|
|
||||||
|
|
||||||
@Test(expected = NullPointerException.class)
|
@Test(expected = NullPointerException.class)
|
||||||
public void allowNullKey_In_TreeMapBackedSynchronizedMap() {
|
public void givenTreeMapBackedSynchronizedMap_whenNullAsKey_thenException() {
|
||||||
Map<String, Integer> map = Collections.synchronizedMap(new TreeMap<String, Integer>());
|
Map<String, Integer> map = Collections.synchronizedMap(new TreeMap<String, Integer>());
|
||||||
map.put(null, 1);
|
map.put(null, 1);
|
||||||
Assert.assertTrue(map.get(null).equals(1));
|
Assert.assertTrue(map.get(null).equals(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void allowNullKey_In_LinkedHashMapBackedSynchronizedMap() {
|
public void givenLinkedHashMapBackedSynchronizedMap_whenNullAsKey_thenNoError() {
|
||||||
Map<String, Integer> map = Collections
|
Map<String, Integer> map = Collections
|
||||||
.synchronizedMap(new LinkedHashMap<String, Integer>());
|
.synchronizedMap(new LinkedHashMap<String, Integer>());
|
||||||
map.put(null, 1);
|
map.put(null, 1);
|
||||||
@ -37,27 +37,27 @@ public class NullAllowInMapUnitTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = NullPointerException.class)
|
@Test(expected = NullPointerException.class)
|
||||||
public void allowNullKey_In_ConcurrentHasMap() {
|
public void givenConcurrentHasMap_whenNullAsKey_thenException() {
|
||||||
Map<String, Integer> map = new ConcurrentHashMap<>();
|
Map<String, Integer> map = new ConcurrentHashMap<>();
|
||||||
map.put(null, 1);
|
map.put(null, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void allowNullValue_In_HashMapBackedSynchronizedMap() {
|
public void givenHashMapBackedSynchronizedMap_whenNullAsValue_thenNoError() {
|
||||||
Map<String, Integer> map = Collections.synchronizedMap(new HashMap<String, Integer>());
|
Map<String, Integer> map = Collections.synchronizedMap(new HashMap<String, Integer>());
|
||||||
map.put("1", null);
|
map.put("1", null);
|
||||||
Assert.assertNull(map.get("1"));
|
Assert.assertNull(map.get("1"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void allowNullValue_In_TreeMapBackedSynchronizedMap() {
|
public void givenTreeMapBackedSynchronizedMap_whenNullAsValue_thenNoError() {
|
||||||
Map<String, Integer> map = Collections.synchronizedMap(new TreeMap<String, Integer>());
|
Map<String, Integer> map = Collections.synchronizedMap(new TreeMap<String, Integer>());
|
||||||
map.put("1", null);
|
map.put("1", null);
|
||||||
Assert.assertNull(map.get("1"));
|
Assert.assertNull(map.get("1"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void allowNullValue_In_LinkedHashSynchronizedMap() {
|
public void givenLinkedHashMapBackedSynchronizedMap_whenNullAsValue_thenNoError() {
|
||||||
Map<String, Integer> map = Collections
|
Map<String, Integer> map = Collections
|
||||||
.synchronizedMap(new LinkedHashMap<String, Integer>());
|
.synchronizedMap(new LinkedHashMap<String, Integer>());
|
||||||
map.put("1", null);
|
map.put("1", null);
|
||||||
@ -65,7 +65,7 @@ public class NullAllowInMapUnitTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = NullPointerException.class)
|
@Test(expected = NullPointerException.class)
|
||||||
public void allowNullValue_In_ConcurrentHasMap() {
|
public void givenConcurrentHasMap_whenNullAsValue_thenException() {
|
||||||
Map<String, Integer> map = new ConcurrentHashMap<>();
|
Map<String, Integer> map = new ConcurrentHashMap<>();
|
||||||
map.put("1", null);
|
map.put("1", null);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user