summaryrefslogtreecommitdiffstats
path: root/adapters/mso-adapter-utils/src/test
diff options
context:
space:
mode:
authorBenjamin, Max (mb388a) <mb388a@us.att.com>2019-03-08 00:23:11 -0500
committerBenjamin, Max (mb388a) <mb388a@us.att.com>2019-03-08 10:47:51 -0500
commit50368411fba4fca7efdc5341f9d485ff821eee2c (patch)
treecfae840cf398b41d1e5492ddd6706b58c99e84de /adapters/mso-adapter-utils/src/test
parente4ecd51f615f81fca7567aac583892a32f6a4c3f (diff)
only convert object type json when String
only convert object type json when input is a String Change-Id: I465dfe905f5d85de583b6232640dc4dc13a09c7a Issue-ID: SO-1610 Signed-off-by: Benjamin, Max (mb388a) <mb388a@us.att.com>
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);
}