aboutsummaryrefslogtreecommitdiffstats
path: root/adapters/mso-adapter-utils/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'adapters/mso-adapter-utils/src/test')
-rw-r--r--adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/utils/MsoCloudifyUtilsTest.java13
-rw-r--r--adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatUtilsUnitTest.java16
2 files changed, 25 insertions, 4 deletions
diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/utils/MsoCloudifyUtilsTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/utils/MsoCloudifyUtilsTest.java
index f63aab7ce1..833b4ab760 100644
--- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/utils/MsoCloudifyUtilsTest.java
+++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/utils/MsoCloudifyUtilsTest.java
@@ -24,6 +24,7 @@ package org.onap.so.cloudify.utils;
import static com.shazam.shazamcrest.MatcherAssert.assertThat;
import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
@@ -70,6 +71,7 @@ import org.skyscreamer.jsonassert.JSONAssert;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.JsonMappingException;
+import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
public class MsoCloudifyUtilsTest {
@@ -305,11 +307,18 @@ public class MsoCloudifyUtilsTest {
paramJson.setParamType("json");
paramJson.setParamName("my-json");
- Map<String, Object> jsonMap = mapper.readValue(getJson("free-form.json"), new TypeReference<Map<String, Object>>(){});
+ HeatTemplateParam paramJsonEscaped = new HeatTemplateParam();
+ paramJsonEscaped.setParamType("json");
+ paramJsonEscaped.setParamName("my-json-escaped");
+ Map<String, Object> jsonMap = mapper.readValue(getJson("free-form.json"), new TypeReference<Map<String, Object>>(){});
+
assertEquals(3, utils.convertInputValue("3", paramNum));
assertEquals("hello", utils.convertInputValue("hello", paramString));
- JSONAssert.assertEquals(getJson("free-form.json"), utils.convertInputValue(jsonMap, paramJson).toString(), false);
+ assertTrue("expect no change in type", utils.convertInputValue(jsonMap, paramJson) instanceof Map);
+ assertTrue("expect string to become jsonNode", utils.convertInputValue(getJson("free-form.json"), paramJsonEscaped) instanceof JsonNode);
+
+ JSONAssert.assertEquals(getJson("free-form.json"), mapper.writeValueAsString(utils.convertInputValue(getJson("free-form.json"), paramJsonEscaped)), false);
}
diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatUtilsUnitTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatUtilsUnitTest.java
index 40bbe90218..66d6f59e79 100644
--- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatUtilsUnitTest.java
+++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatUtilsUnitTest.java
@@ -1,6 +1,7 @@
package org.onap.so.openstack.utils;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
import java.io.IOException;
import java.nio.file.Files;
@@ -17,6 +18,7 @@ import org.skyscreamer.jsonassert.JSONAssert;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.JsonMappingException;
+import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
public class MsoHeatUtilsUnitTest {
@@ -45,18 +47,28 @@ public class MsoHeatUtilsUnitTest {
paramJson.setParamType("json");
paramJson.setParamName("my-json");
+ HeatTemplateParam paramJsonEscaped = new HeatTemplateParam();
+ paramJsonEscaped.setParamType("json");
+ paramJsonEscaped.setParamName("my-json-escaped");
+
Map<String, Object> jsonMap = mapper.readValue(getJson("free-form.json"), new TypeReference<Map<String, Object>>(){});
input.put("my-json", jsonMap);
+ input.put("my-json-escaped", getJson("free-form.json"));
+
parameters.add(paramNum);
parameters.add(paramString);
parameters.add(paramJson);
-
+ parameters.add(paramJsonEscaped);
+
Map<String, Object> output = utils.convertInputMap(input, template);
assertEquals(3, output.get("my-number"));
assertEquals("hello", output.get("my-string"));
- JSONAssert.assertEquals(getJson("free-form.json"), (String)output.get("my-json"), false);
+ assertTrue("expect no change in type", output.get("my-json") instanceof Map);
+ assertTrue("expect string to become jsonNode", output.get("my-json-escaped") instanceof JsonNode);
+
+ JSONAssert.assertEquals(getJson("free-form.json"), mapper.writeValueAsString(output.get("my-json-escaped")), false);
}