From ec041202ae55e467e7074bce97f5dbea95b77d53 Mon Sep 17 00:00:00 2001 From: Pritam Banerjee Date: Tue, 30 May 2017 01:53:54 -0700 Subject: [PATCH] Fixed EJB --- .../baeldung/map/iteration/MapIteration.java | 57 ---------------- .../map/iteration/MapIterationTest.java | 68 ------------------- 2 files changed, 125 deletions(-) delete mode 100644 core-java/src/main/java/com/baeldung/map/iteration/MapIteration.java delete mode 100644 core-java/src/test/java/com/baeldung/map/iteration/MapIterationTest.java diff --git a/core-java/src/main/java/com/baeldung/map/iteration/MapIteration.java b/core-java/src/main/java/com/baeldung/map/iteration/MapIteration.java deleted file mode 100644 index 3b2a213aa0..0000000000 --- a/core-java/src/main/java/com/baeldung/map/iteration/MapIteration.java +++ /dev/null @@ -1,57 +0,0 @@ -package com.baeldung.map.iteration; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.Map; - -public class MapIteration { - - public ArrayList iterateUsingEntrySet(Map map) { - ArrayList mapKeyValueList = new ArrayList(); - for (Map.Entry entry : map.entrySet()) { - mapKeyValueList.add(entry.getKey() + ":" + entry.getValue()); - } - return mapKeyValueList; - } - - public ArrayList iterateUsingLambda(Map map) { - ArrayList mapKeyValueList = new ArrayList(); - map.forEach((k, v) -> mapKeyValueList.add(k + ":" + v)); - return mapKeyValueList; - } - - public ArrayList iterateUsingIteratorAndEntry(Map map) { - ArrayList mapKeyValueList = new ArrayList(); - Iterator> iterator = map.entrySet().iterator(); - - while (iterator.hasNext()) { - Map.Entry pair = iterator.next(); - mapKeyValueList.add(pair.getKey() + ":" + pair.getValue()); - } - - return mapKeyValueList; - } - - public ArrayList iterateUsingKeySetAndForeach(Map map) { - ArrayList mapKeyValueList = new ArrayList(); - for (String key : map.keySet()) { - mapKeyValueList.add(key + ":" + map.get(key)); - } - return mapKeyValueList; - } - - public ArrayList iterateUsingStreamAPI(Map map) { - ArrayList mapKeyValueList = new ArrayList(); - map.entrySet().stream().forEach(e -> mapKeyValueList.add(e.getKey() + ":" + e.getValue())); - return mapKeyValueList; - } - - public ArrayList iterateKeys(Map map) { - ArrayList mapKeyList = new ArrayList(); - for (String key : map.keySet()) { - mapKeyList.add(key); - } - return mapKeyList; - } - -} \ No newline at end of file diff --git a/core-java/src/test/java/com/baeldung/map/iteration/MapIterationTest.java b/core-java/src/test/java/com/baeldung/map/iteration/MapIterationTest.java deleted file mode 100644 index 5953c118fd..0000000000 --- a/core-java/src/test/java/com/baeldung/map/iteration/MapIterationTest.java +++ /dev/null @@ -1,68 +0,0 @@ -package com.baeldung.map.iteration; - -import static org.junit.Assert.assertTrue; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Map; - -import org.junit.BeforeClass; -import org.junit.Test; - -public class MapIterationTest { - - public static Map testMap = new HashMap(); - public static String testString1 = "One:1"; - public static String testString2 = "Two:2"; - public static String testString3 = "Three:3"; - - @BeforeClass - public static void createTestData() { - testMap.put("One", 1); - testMap.put("Three", 3); - testMap.put("Two", 2); - } - - @Test - public void iterateUsingEntrySet_test() { - MapIteration mapIteration = new MapIteration(); - ArrayList list = mapIteration.iterateUsingEntrySet(testMap); - assertTrue((list.contains(testString1)) && (list.contains(testString2)) && (list.contains(testString3))); - } - - @Test - public void iterateUsingLambda_test() { - MapIteration mapIteration = new MapIteration(); - ArrayList list = mapIteration.iterateUsingLambda(testMap); - assertTrue((list.contains(testString1)) && (list.contains(testString2)) && (list.contains(testString3))); - } - - @Test - public void iterateUsingIteratorAndEntry_test() { - MapIteration mapIteration = new MapIteration(); - ArrayList list = mapIteration.iterateUsingIteratorAndEntry(testMap); - assertTrue((list.contains(testString1)) && (list.contains(testString2)) && (list.contains(testString3))); - } - - @Test - public void iterateUsingKeySetAndForeach_test() { - MapIteration mapIteration = new MapIteration(); - ArrayList list = mapIteration.iterateUsingKeySetAndForeach(testMap); - assertTrue((list.contains(testString1)) && (list.contains(testString2)) && (list.contains(testString3))); - } - - @Test - public void iterateUsingStreamAPI_test() { - MapIteration mapIteration = new MapIteration(); - ArrayList list = mapIteration.iterateUsingStreamAPI(testMap); - assertTrue((list.contains(testString1)) && (list.contains(testString2)) && (list.contains(testString3))); - } - - @Test - public void iterateKeys_test() { - MapIteration mapIteration = new MapIteration(); - ArrayList list = mapIteration.iterateKeys(testMap); - assertTrue((list.contains("One")) && (list.contains("Two")) && (list.contains("Three"))); - } - -}