diff --git a/core-java-collections-2/src/main/java/com/baeldung/copyinghashmap/CopyHashMap.java b/core-java-collections-2/src/main/java/com/baeldung/copyinghashmap/CopyHashMap.java index 11ead4ee38..e673335f62 100644 --- a/core-java-collections-2/src/main/java/com/baeldung/copyinghashmap/CopyHashMap.java +++ b/core-java-collections-2/src/main/java/com/baeldung/copyinghashmap/CopyHashMap.java @@ -43,15 +43,6 @@ public class CopyHashMap { return copyMap; } - public static HashMap copyMapAndDivideValuesBy2(HashMap originalMap) { - Set entries = originalMap.entrySet(); - HashMap copyMap = (HashMap) entries - .stream() - .collect(Collectors.toMap(mapEntry -> mapEntry.getKey(), mapEntry -> (int)mapEntry.getValue()/2)); - - return copyMap; - } - public static HashMap shallowCopy(HashMap originalMap) { return (HashMap) originalMap.clone(); } diff --git a/core-java-collections-2/src/test/java/com/baeldung/copyinghashmap/CopyHashMapUnitTest.java b/core-java-collections-2/src/test/java/com/baeldung/copyinghashmap/CopyHashMapUnitTest.java index ce41e9d810..f0434f9bfe 100644 --- a/core-java-collections-2/src/test/java/com/baeldung/copyinghashmap/CopyHashMapUnitTest.java +++ b/core-java-collections-2/src/test/java/com/baeldung/copyinghashmap/CopyHashMapUnitTest.java @@ -58,21 +58,7 @@ public class CopyHashMapUnitTest { assertThat(deepCopy.get("emp1")).isNotEqualTo(map.get("emp1")); - } - - @Test - public void givenHashMap_whenCopy_thenCopyMapShouldHaveValuesDivideBy2() { - - HashMap heightMap = new HashMap<>(); - heightMap.put("emp1", 160); - heightMap.put("emp2", 165); - heightMap.put("emp3", 163); - HashMap heightMapCopy = CopyHashMap.copyMapAndDivideValuesBy2(heightMap); - - assertThat(heightMap).isNotEqualTo(heightMapCopy); - - assertThat(heightMap.get("emp1")/2).isEqualTo(heightMapCopy.get("emp1")); - } + } @Test public void givenImmutableMap_whenCopyUsingGuava_thenCopyShouldNotChange() {