aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/utils/MapUtilTest.java
diff options
context:
space:
mode:
authorTal Gitelman <tg851x@intl.att.com>2018-05-31 16:57:17 +0300
committerTal Gitelman <tg851x@intl.att.com>2018-05-31 15:24:39 +0000
commitcdb8d264670ae4b98eb3b40cc58ee06b2c2e70c9 (patch)
treed43609c24140c13f92c6d303b76820b74f8c7634 /catalog-dao/src/test/java/org/openecomp/sdc/be/dao/utils/MapUtilTest.java
parentcc4088f4d26212b8dbeeff01f0ae2e38f2df4d3f (diff)
new unit tests for sdc-dao
Change-Id: Ibf37c20c3d07f3cd2962e324f3e37354adad9870 Issue-ID: SDC-1333 Signed-off-by: Tal Gitelman <tg851x@intl.att.com>
Diffstat (limited to 'catalog-dao/src/test/java/org/openecomp/sdc/be/dao/utils/MapUtilTest.java')
-rw-r--r--catalog-dao/src/test/java/org/openecomp/sdc/be/dao/utils/MapUtilTest.java109
1 files changed, 109 insertions, 0 deletions
diff --git a/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/utils/MapUtilTest.java b/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/utils/MapUtilTest.java
new file mode 100644
index 0000000000..ed2f3134d2
--- /dev/null
+++ b/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/utils/MapUtilTest.java
@@ -0,0 +1,109 @@
+package org.openecomp.sdc.be.dao.utils;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.function.Function;
+
+import org.junit.Test;
+
+public class MapUtilTest {
+
+ @Test
+ public void testGet() throws Exception {
+ Map<String, ? extends Object> map = null;
+ String path = "";
+ Object result;
+
+ // default test
+ result = MapUtil.get(map, path);
+ path = "\\mock\\mock";
+ result = MapUtil.get(map, path);
+ }
+
+ @Test
+ public void testGroupListBy() throws Exception {
+ Collection valuesToMap = new LinkedList<String>();
+ Function<String, String> groupingFunction = new Function<String, String>() {
+
+ @Override
+ public String apply(String t) {
+ return t;
+ }
+ };
+ Map<String, List<String>> result;
+
+ // default test
+ result = MapUtil.groupListBy(valuesToMap, groupingFunction);
+ }
+
+ @Test
+ public void testToMap() throws Exception {
+ Collection<String> valuesToMap = null;
+ Function<String, String> mappingFunction = null;
+ Map<String, String> result;
+
+ // default test
+ result = MapUtil.toMap(valuesToMap, mappingFunction);
+ }
+
+ @Test
+ public void testConvertMapKeys() throws Exception {
+ Map<String, List<String>> map = new HashMap<>();
+ Function<String, String> keyMappingFunction = new Function<String, String>() {
+
+ @Override
+ public String apply(String t) {
+ return t;
+ }
+ };
+ Map<String, List<String>> result;
+
+ // default test
+ result = MapUtil.convertMapKeys(map, keyMappingFunction);
+ }
+
+ @Test
+ public void testNewHashMap() throws Exception {
+ String[] keys = new String[] { "mock" };
+ String[] values = new String[] { "mock" };
+ Map<String, String> result;
+
+ // test 1
+ result = MapUtil.newHashMap(keys, values);
+ //Assert.assertEquals(null, result);
+
+ // test 2
+ keys = new String[] { "mock" };
+ values = null;
+ try {
+ result = MapUtil.newHashMap(keys, values);
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ // test 3
+ values = null;
+ keys = null;
+ try {
+ result = MapUtil.newHashMap(keys, values);
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ //Assert.assertEquals(null, result);
+
+ // test 4
+ values = new String[] { "mock" };
+ keys = null;
+ try {
+ result = MapUtil.newHashMap(keys, values);
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+} \ No newline at end of file