summaryrefslogtreecommitdiffstats
path: root/catalog-dao/src/test/java
diff options
context:
space:
mode:
Diffstat (limited to 'catalog-dao/src/test/java')
-rw-r--r--catalog-dao/src/test/java/org/openecomp/sdc/be/dao/utils/MapUtilTest.java56
-rw-r--r--catalog-dao/src/test/java/org/openecomp/sdc/be/resources/JsonParserUtilsTests.java17
-rw-r--r--catalog-dao/src/test/java/org/openecomp/sdc/be/resources/data/TagDataTest.java9
-rw-r--r--catalog-dao/src/test/java/org/openecomp/sdc/be/resources/data/auditing/AuditingGenericEventTest.java24
4 files changed, 96 insertions, 10 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
index 0cb045aaad..ea562b1f3e 100644
--- 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
@@ -21,13 +21,17 @@
package org.openecomp.sdc.be.dao.utils;
import com.google.common.collect.ImmutableMap;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+
import java.util.*;
import java.util.function.Function;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.openecomp.sdc.be.dao.utils.MapUtil.mergeMaps;
public class MapUtilTest {
@@ -64,14 +68,54 @@ public class MapUtilTest {
}
@Test
public void testGet() throws Exception {
- Map<String, ? extends Object> map = null;
+ Map<String, ? extends Object> mapWildcard = null;
String path = "";
Object result;
- // default test
- result = MapUtil.get(map, path);
- path = "\\mock\\mock";
- result = MapUtil.get(map, path);
+ result = MapUtil.get(mapWildcard, path);
+ assertNull(result);
+
+ path = "mock1.mock2";
+
+ Map<String, Object> map = new HashMap<>();
+ map.put("mock1", "test");
+ mapWildcard = map;
+ result = MapUtil.get(mapWildcard, path);
+ assertNull(result);
+
+ Map<String, Integer> subMap = new HashMap<>();
+ subMap.put("mock2", 1);
+ Map<String, ? extends Object> subMapWildcard = subMap;
+ map.put("mock1", subMapWildcard);
+ mapWildcard = map;
+ result = MapUtil.get(mapWildcard, path);
+ assertEquals(1, result);
+ }
+
+ @Test
+ public void testFlattenMapValues() throws Exception {
+ assertNotNull(MapUtil.flattenMapValues(null));
+
+ Map<String, List<String>> map = new HashMap<>();
+ List<String> list1 = new LinkedList<>();
+ list1.add("test1");
+ List<String> list2 = new LinkedList<>();
+ list2.add("test2");
+ map.put("key1", list1);
+ map.put("key2", list2);
+ List<String> result = MapUtil.flattenMapValues(map);
+ assertEquals(2, result.size());
+ assertEquals("test1", result.get(0));
+ assertEquals("test2", result.get(1));
+ }
+
+ @Test
+ public void testStreamOfNullable() throws Exception {
+ assertEquals(0, MapUtil.streamOfNullable(null).count());
+
+ Collection collectionTest = new LinkedList<String>();
+ collectionTest.add("test");
+ assertEquals(1, MapUtil.streamOfNullable(collectionTest).count());
}
@Test
diff --git a/catalog-dao/src/test/java/org/openecomp/sdc/be/resources/JsonParserUtilsTests.java b/catalog-dao/src/test/java/org/openecomp/sdc/be/resources/JsonParserUtilsTests.java
index 21a728053c..09e751580f 100644
--- a/catalog-dao/src/test/java/org/openecomp/sdc/be/resources/JsonParserUtilsTests.java
+++ b/catalog-dao/src/test/java/org/openecomp/sdc/be/resources/JsonParserUtilsTests.java
@@ -37,12 +37,16 @@ import java.util.Map;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatCode;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertNull;
import static org.openecomp.sdc.be.utils.FixtureHelpers.fixture;
import static org.openecomp.sdc.be.utils.JsonTester.testJsonMap;
public class JsonParserUtilsTests {
private static final String FIXTURE_PATH = "fixtures/ListCapabilityDataDefinition.json";
+ private static final String FIXTURE_PATH2 = "fixtures/ListCapabilityDataDefinition2.json";
@Test
public void testToMap() {
@@ -54,6 +58,19 @@ public class JsonParserUtilsTests {
}
@Test
+ public void testToList() {
+ assertNull(JsonParserUtils.toList(null, ListCapabilityDataDefinition.class));
+ String json = fixture(FIXTURE_PATH2);
+ List<ListCapabilityDataDefinition> actual = JsonParserUtils.toList(json,
+ ListCapabilityDataDefinition.class);
+ assertEquals(1, actual.size());
+ CapabilityDataDefinition expectedDef = buildListCapabilityDataDefinition().getListToscaDataDefinition().get(0);
+ CapabilityDataDefinition actualDef = actual.get(0).getListToscaDataDefinition().get(0);
+ assertEquals(1, actual.get(0).getListToscaDataDefinition().size());
+ assertEquals(expectedDef, actualDef);
+ }
+
+ @Test
public void testJacksonFasterXml() {
ObjectMapper mapper = new ObjectMapper().disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)
.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);
diff --git a/catalog-dao/src/test/java/org/openecomp/sdc/be/resources/data/TagDataTest.java b/catalog-dao/src/test/java/org/openecomp/sdc/be/resources/data/TagDataTest.java
index c1729d0f3d..919b7c7663 100644
--- a/catalog-dao/src/test/java/org/openecomp/sdc/be/resources/data/TagDataTest.java
+++ b/catalog-dao/src/test/java/org/openecomp/sdc/be/resources/data/TagDataTest.java
@@ -20,13 +20,15 @@
package org.openecomp.sdc.be.resources.data;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
import java.util.HashMap;
import java.util.Map;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+
public class TagDataTest {
private TagData createTestSubject() {
@@ -90,6 +92,7 @@ public class TagDataTest {
result = testSubject.hashCode();
}
+
@Test
public void testEquals() throws Exception {
TagData testSubject;
@@ -100,7 +103,7 @@ public class TagDataTest {
testSubject = createTestSubject();
obj = null;
result = testSubject.equals(obj);
- Assert.assertEquals(false, result);
+ assertEquals(false, result);
}
@Test
diff --git a/catalog-dao/src/test/java/org/openecomp/sdc/be/resources/data/auditing/AuditingGenericEventTest.java b/catalog-dao/src/test/java/org/openecomp/sdc/be/resources/data/auditing/AuditingGenericEventTest.java
index f0557aaee5..7a94b4da27 100644
--- a/catalog-dao/src/test/java/org/openecomp/sdc/be/resources/data/auditing/AuditingGenericEventTest.java
+++ b/catalog-dao/src/test/java/org/openecomp/sdc/be/resources/data/auditing/AuditingGenericEventTest.java
@@ -20,7 +20,14 @@
package org.openecomp.sdc.be.resources.data.auditing;
-import org.junit.Test;
+
+import org.junit.jupiter.api.Test;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
public class AuditingGenericEventTest {
@@ -29,6 +36,21 @@ public class AuditingGenericEventTest {
}
@Test
+ public void testTimestamp() throws Exception {
+ AuditingGenericEvent testSubject = createTestSubject();
+ testSubject.setTimestamp("timestamp");
+ assertEquals("timestamp", testSubject.getTimestamp());
+ }
+
+ @Test
+ public void testFields() throws Exception {
+ AuditingGenericEvent testSubject = createTestSubject();
+ Map<String, Object> map = new HashMap<>();
+ testSubject.setFields(map);
+ assertNotNull(testSubject.getFields());
+ }
+
+ @Test
public void testGetRequestId() throws Exception {
AuditingGenericEvent testSubject;
String result;