summaryrefslogtreecommitdiffstats
path: root/catalog-model/src/test
diff options
context:
space:
mode:
authorJvD_Ericsson <jeff.van.dam@est.tech>2023-02-14 11:53:07 +0000
committerMichael Morris <michael.morris@est.tech>2023-02-17 09:51:09 +0000
commit89d7125d6ae8a3f172ce7d6dc9546443d9477f5b (patch)
tree4c2080d8e90ce604fcd9907f86553f3132e0358c /catalog-model/src/test
parent589afc753f2cadd9688715b4e5fe54075600060b (diff)
Support for copy/paste tosca functions into operation inputs
Issue-ID: SDC-4394 Signed-off-by: JvD_Ericsson <jeff.van.dam@est.tech> Change-Id: I4aedb641e950419677d2509f4944fcf778c2efd8
Diffstat (limited to 'catalog-model/src/test')
-rw-r--r--catalog-model/src/test/java/org/openecomp/sdc/be/model/tosca/converters/ToscaValueBaseConverterTest.java60
1 files changed, 60 insertions, 0 deletions
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/tosca/converters/ToscaValueBaseConverterTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/tosca/converters/ToscaValueBaseConverterTest.java
index 5387b46dd6..13b2be5ce5 100644
--- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/tosca/converters/ToscaValueBaseConverterTest.java
+++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/tosca/converters/ToscaValueBaseConverterTest.java
@@ -26,6 +26,8 @@ import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import com.google.gson.JsonArray;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonNull;
import com.google.gson.JsonObject;
import com.google.gson.JsonPrimitive;
import java.util.HashMap;
@@ -145,4 +147,62 @@ class ToscaValueBaseConverterTest {
assertEquals(innerObject.get("float").getAsDouble(), objectPropertyAsMap.get("float"));
assertNull(objectPropertyAsMap.get("null"));
}
+
+ @Test
+ void testParseToJson() {
+ final JsonElement result1 = converter.parseToJson("");
+ assertTrue(result1.isJsonNull());
+
+ final JsonElement result2 = converter.parseToJson("testString");
+ assertTrue(result2.isJsonPrimitive());
+
+ final JsonElement result3 = converter.parseToJson("1");
+ assertTrue(result3.isJsonPrimitive());
+
+ final JsonElement result4 = converter.parseToJson("true");
+ assertTrue(result4.isJsonPrimitive());
+
+ final JsonElement result5 = converter.parseToJson("{\"get_property\":[\"relatedParty_0\",\"name\"]}");
+ assertTrue(result5.isJsonObject());
+
+ final JsonElement result6 = converter.parseToJson("[\"relatedParty_0\",\"name\"]");
+ assertTrue(result6.isJsonArray());
+
+ }
+
+ @Test
+ void testIsJsonElementAJsonPrimitive() {
+
+ JsonElement emptyStringEle = new JsonPrimitive("");
+ final Boolean result1 = converter.isJsonElementAJsonPrimitive(emptyStringEle);
+ assertTrue(result1);
+
+ JsonElement stringEle = new JsonPrimitive("testString");
+ final Boolean result2 = converter.isJsonElementAJsonPrimitive(stringEle);
+ assertTrue(result2);
+
+ JsonElement toscaFunctionEle = new JsonPrimitive("{\"get_property\":[\"relatedParty_0\",\"name\"]}");
+ final Boolean result3 = converter.isJsonElementAJsonPrimitive(toscaFunctionEle);
+ assertFalse(result3);
+
+ JsonElement jsonObjectEle = new JsonObject();
+ final Boolean result4 = converter.isJsonElementAJsonPrimitive(jsonObjectEle);
+ assertFalse(result4);
+
+ JsonElement jsonArrayEle = new JsonArray();
+ final Boolean result5 = converter.isJsonElementAJsonPrimitive(jsonArrayEle);
+ assertFalse(result5);
+
+ JsonElement intEle = new JsonPrimitive(123);
+ final Boolean result6 = converter.isJsonElementAJsonPrimitive(intEle);
+ assertTrue(result6);
+
+ JsonElement boolEle = new JsonPrimitive(true);
+ final Boolean result7 = converter.isJsonElementAJsonPrimitive(boolEle);
+ assertTrue(result7);
+
+ JsonElement nullEle = new JsonNull();
+ final Boolean result8 = converter.isJsonElementAJsonPrimitive(nullEle);
+ assertFalse(result8);
+ }
}