aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-dao/src/test
diff options
context:
space:
mode:
authorxuegao <xue.gao@intl.att.com>2021-03-25 16:00:32 +0100
committerVasyl Razinkov <vasyl.razinkov@est.tech>2021-03-26 19:16:24 +0000
commite83d137179fa3c532c191f89f9e6cdd53b0778c7 (patch)
treef397a70f4096c068b24b55eb52a93f6789d1523b /catalog-dao/src/test
parent021978494010df2a4258845b2ada19967869afd1 (diff)
Improve test coverage
Add unit tests to improve test coverage. Issue-ID: SDC-3428 Change-Id: Ifd9e6eb25fa3ec9f4f93d283277574120edff835 Signed-off-by: xuegao <xue.gao@intl.att.com>
Diffstat (limited to 'catalog-dao/src/test')
-rw-r--r--catalog-dao/src/test/java/org/openecomp/sdc/be/dao/utils/CollectionUtilsTest.java78
1 files changed, 43 insertions, 35 deletions
diff --git a/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/utils/CollectionUtilsTest.java b/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/utils/CollectionUtilsTest.java
index eaa2538d11..c5a27bc425 100644
--- a/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/utils/CollectionUtilsTest.java
+++ b/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/utils/CollectionUtilsTest.java
@@ -21,59 +21,67 @@
package org.openecomp.sdc.be.dao.utils;
import org.apache.tinkerpop.gremlin.structure.T;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import java.util.*;
+import java.util.List;
+import java.util.LinkedList;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Set;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
public class CollectionUtilsTest {
@Test
public void testMerge() throws Exception {
- Set<T> source = null;
- Set<T> target = null;
- Set<T> result;
-
- // test 1
- target = null;
- result = CollectionUtils.merge(source, target);
- Assert.assertEquals(null, result);
+ Set<T> source = new HashSet<>();
+ Set<T> target = new HashSet<>();
+ assertNull(CollectionUtils.merge(source, target));
- // test 2
- source = null;
- result = CollectionUtils.merge(source, target);
- Assert.assertEquals(null, result);
+ T t = null;
+ source.add(t);
+ assertNotNull(CollectionUtils.merge(source, target));
}
@Test
public void testMerge_1() throws Exception {
Map<String, String> source = new HashMap();
Map<String, String> target = new HashMap();
- boolean override = false;
- Map<String, String> result;
- result = CollectionUtils.merge(source, target, override);
- Assert.assertEquals(null, result);
-
- // test 1
- target = null;
- result = CollectionUtils.merge(source, target, override);
- Assert.assertEquals(null, result);
-
- // test 2
- source = null;
- result = CollectionUtils.merge(source, target, override);
- Assert.assertEquals(null, result);
+ source.put("key", "value");
+ target.put("key", "value2");
+ assertEquals("value2", CollectionUtils.merge(source, target, false).get("key"));
+ assertEquals("value", CollectionUtils.merge(source, target, true).get("key"));
}
@Test
public void testMerge_2() throws Exception {
- List<T> source = new LinkedList<>();
- List<T> target = new LinkedList<>();
- List<T> result;
+ List<String> source = null;
+ List<String> target = null;
+ assertEquals(0, CollectionUtils.merge(source, target).size());
+
+ source = new LinkedList<>();
+ target = new LinkedList<>();
+ assertEquals(0, CollectionUtils.merge(source, target).size());
+
+ source.add("test1");
+ target.add("test2");
+ assertEquals("test2", CollectionUtils.merge(source, target).get(0));
+ assertEquals("test1", CollectionUtils.merge(source, target).get(1));
+ }
+
+ @Test
+ public void testUnion() throws Exception {
+ List<String> source = new LinkedList<>();
+ List<String> target = new LinkedList<>();
- // test 1
- result = CollectionUtils.merge(source, target);
- Assert.assertEquals(target, result);
+ source.add("test1");
+ target.add("test2");
+ assertEquals("test1", CollectionUtils.union(source, target).get(0));
+ assertEquals("test2", CollectionUtils.union(source, target).get(1));
}
}