summaryrefslogtreecommitdiffstats
path: root/sliPluginUtils/provider/src/test
diff options
context:
space:
mode:
authorSmokowski, Kevin (ks6305) <kevin.smokowski@att.com>2019-05-22 15:31:08 +0000
committerKevin Smokowski <kevin.smokowski@att.com>2019-05-22 18:17:40 +0000
commita3d782bc5e0bc07fcc5efd9a118e109011ee2889 (patch)
treec21d826eda26ed09d5d603abed65ab76117bee72 /sliPluginUtils/provider/src/test
parent3afef48beebb503e466c611e2b731f3d761e81fb (diff)
add escape and unescape json to SliStringUtils
Add escape and unescape json to SliStringUtils. Can be useful when creating payloads from escaped json or sending payloads that involved escaped json. Change-Id: I736024ef91b5e6fff75374802b0fee2370f12b2f Issue-ID: CCSDK-1353 Signed-off-by: Smokowski, Kevin (ks6305) <kevin.smokowski@att.com>
Diffstat (limited to 'sliPluginUtils/provider/src/test')
-rw-r--r--sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliStringUtilsTest.java20
1 files changed, 20 insertions, 0 deletions
diff --git a/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliStringUtilsTest.java b/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliStringUtilsTest.java
index 085d46ef7..b88e8d2c9 100644
--- a/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliStringUtilsTest.java
+++ b/sliPluginUtils/provider/src/test/java/org/onap/ccsdk/sli/core/slipluginutils/SliStringUtilsTest.java
@@ -297,4 +297,24 @@ public class SliStringUtilsTest {
utils.substring(param, ctx);
}
+ @Test
+ public void testUnescapeJsonString() throws Exception {
+ String source = "{\\\"image_name\\\":\\\"Ubuntu 14.04\\\",\\\"service-instance-id\\\":\\\"1\\\",\\\"vnf-model-customization-uuid\\\":\\\"2f\\\",\\\"vnf-id\\\":\\\"3b\\\"}";
+ param.put(SliStringUtils.INPUT_PARAM_SOURCE, source);
+ String outputPath = "unescaped";
+ param.put(SliStringUtils.INPUT_PARAM_TARGET, outputPath);
+ SliStringUtils.unescapeJsonString(param, ctx);
+ assertEquals("{\"image_name\":\"Ubuntu 14.04\",\"service-instance-id\":\"1\",\"vnf-model-customization-uuid\":\"2f\",\"vnf-id\":\"3b\"}", ctx.getAttribute(outputPath));
+ }
+
+ @Test
+ public void testEscapeJsonString() throws Exception {
+ String source = "{\"image_name\":\"Ubuntu 14.04\",\"service-instance-id\":\"1\",\"vnf-model-customization-uuid\":\"2f\",\"vnf-id\":\"3b\"}";
+ param.put(SliStringUtils.INPUT_PARAM_SOURCE, source);
+ String outputPath = "unescaped";
+ param.put(SliStringUtils.INPUT_PARAM_TARGET, outputPath);
+ SliStringUtils.escapeJsonString(param, ctx);
+ assertEquals("{\\\"image_name\\\":\\\"Ubuntu 14.04\\\",\\\"service-instance-id\\\":\\\"1\\\",\\\"vnf-model-customization-uuid\\\":\\\"2f\\\",\\\"vnf-id\\\":\\\"3b\\\"}", ctx.getAttribute(outputPath));
+ }
+
}