From a07e23dddd90d529a0719f24c6f6217694834c15 Mon Sep 17 00:00:00 2001 From: Amitabh Tiwari Date: Mon, 21 Dec 2020 02:06:26 +0530 Subject: [PATCH] BAEL-4686: fixed review comments --- .../NullAllowInMapUnitTest.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/concurrenthashmap/NullAllowInMapUnitTest.java b/core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/concurrenthashmap/NullAllowInMapUnitTest.java index c5fc57d8ce..594e8ec3b4 100644 --- a/core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/concurrenthashmap/NullAllowInMapUnitTest.java +++ b/core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/concurrenthashmap/NullAllowInMapUnitTest.java @@ -13,7 +13,7 @@ import org.junit.Test; public class NullAllowInMapUnitTest { @Test - public void allowNullKey_In_HashMapBackedSynchronizedMap() { + public void givenHashMapBackedSynchronizedMap_whenNullAsKey_thenNoError() { Map map = Collections .synchronizedMap(new HashMap()); map.put(null, 1); @@ -22,14 +22,14 @@ public class NullAllowInMapUnitTest { @Test(expected = NullPointerException.class) - public void allowNullKey_In_TreeMapBackedSynchronizedMap() { + public void givenTreeMapBackedSynchronizedMap_whenNullAsKey_thenException() { Map map = Collections.synchronizedMap(new TreeMap()); map.put(null, 1); Assert.assertTrue(map.get(null).equals(1)); } @Test - public void allowNullKey_In_LinkedHashMapBackedSynchronizedMap() { + public void givenLinkedHashMapBackedSynchronizedMap_whenNullAsKey_thenNoError() { Map map = Collections .synchronizedMap(new LinkedHashMap()); map.put(null, 1); @@ -37,27 +37,27 @@ public class NullAllowInMapUnitTest { } @Test(expected = NullPointerException.class) - public void allowNullKey_In_ConcurrentHasMap() { + public void givenConcurrentHasMap_whenNullAsKey_thenException() { Map map = new ConcurrentHashMap<>(); map.put(null, 1); } @Test - public void allowNullValue_In_HashMapBackedSynchronizedMap() { + public void givenHashMapBackedSynchronizedMap_whenNullAsValue_thenNoError() { Map map = Collections.synchronizedMap(new HashMap()); map.put("1", null); Assert.assertNull(map.get("1")); } @Test - public void allowNullValue_In_TreeMapBackedSynchronizedMap() { + public void givenTreeMapBackedSynchronizedMap_whenNullAsValue_thenNoError() { Map map = Collections.synchronizedMap(new TreeMap()); map.put("1", null); Assert.assertNull(map.get("1")); } @Test - public void allowNullValue_In_LinkedHashSynchronizedMap() { + public void givenLinkedHashMapBackedSynchronizedMap_whenNullAsValue_thenNoError() { Map map = Collections .synchronizedMap(new LinkedHashMap()); map.put("1", null); @@ -65,7 +65,7 @@ public class NullAllowInMapUnitTest { } @Test(expected = NullPointerException.class) - public void allowNullValue_In_ConcurrentHasMap() { + public void givenConcurrentHasMap_whenNullAsValue_thenException() { Map map = new ConcurrentHashMap<>(); map.put("1", null); }