summaryrefslogtreecommitdiffstats
path: root/plugins/restapi-call-node/provider/src/test
diff options
context:
space:
mode:
authorStan Bonev (sb5356) <sb5356@att.com>2021-11-19 15:33:12 -0500
committerStan Bonev (sb5356) <sb5356@att.com>2021-11-19 15:33:12 -0500
commitd4c076118ff231d9ab5165a873185515896380eb (patch)
treeb26a93580d8ba24c08dd574cf86a2db759d6b335 /plugins/restapi-call-node/provider/src/test
parentaa10e7c0d663547f86cfe3183037c99fde6971a4 (diff)
Restapi-call-node: Support for "" values in JSON
Issue-ID: CCSDK-3529 Signed-off-by: Stan Bonev (sb5356) <sb5356@att.com> Change-Id: I30e903a4b7028c707f73f3516ef11eecf032c5c2
Diffstat (limited to 'plugins/restapi-call-node/provider/src/test')
-rwxr-xr-xplugins/restapi-call-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java55
1 files changed, 55 insertions, 0 deletions
diff --git a/plugins/restapi-call-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java b/plugins/restapi-call-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java
index a993bb946..595fc1de2 100755
--- a/plugins/restapi-call-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java
+++ b/plugins/restapi-call-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java
@@ -601,4 +601,59 @@ public class TestRestapiCallNode {
assertTrue(RestapiCallNode.containsMultipleUrls("https://wiki.onap.org/test=4,5,6,http://localhost:7001/test=1,2,3,http://wiki.onap.org/test=7,8,9,10"));
}
+ @Test
+ public void testKeepEmptyValue() throws Exception {
+ log.info("================= Testing keeping empty values =======================");
+
+ String template = "{\n" +
+ " \"name1\": \"value1\",\n" +
+ " \"name2\": ${empty},\n" +
+ " \"name3\": ${~empty},\n" +
+ " \"name4\": {\n" +
+ " \"name41\": \"value41\",\n" +
+ " \"name42\": ${~empty},\n" +
+ " \"name43\": ${~not_empty}\n" +
+ " },\n" +
+ " \"name5\": {\n"+
+ " \"name51\": ${~empty},\n"+
+ " \"name52\": ${empty}\n"+
+ " },\n" +
+ " \"name6\": {\n"+
+ " \"name61\": ${empty},\n"+
+ " \"name62\": ${empty}\n"+
+ " },\n" +
+ " \"name7\": \"${\"not_empty}\",\n" +
+ " \"name8\": \"${~\"not_empty}\",\n" +
+ " \"name9\": \"${\"empty}\",\n" +
+ " \"name10\": \"${~\"empty}\"\n" +
+ "}";
+
+ String expect = "{\n" +
+ " \"name1\": \"value1\",\n" +
+ " \"name3\": \"\",\n" +
+ " \"name4\": {\n" +
+ " \"name41\": \"value41\",\n" +
+ " \"name42\": \"\",\n" +
+ " \"name43\": \"some value\"\n" +
+ " },\n" +
+ " \"name5\": {\n" +
+ " \"name51\": \"\"\n" +
+ " },\n" +
+ " \"name7\": \"some value\",\n" +
+ " \"name8\": \"some value\",\n" +
+ " \"name10\": \"\"\n" +
+ "}";
+
+ SvcLogicContext ctx = new SvcLogicContext();
+ ctx.setAttribute("empty", "");
+ ctx.setAttribute("not_empty", "some value");
+
+ RestapiCallNode rcn = new RestapiCallNode();
+ String req = rcn.buildXmlJsonRequest(ctx, template, Format.JSON);
+
+ log.info("Result:\n" + req);
+ log.info("==================================================================");
+
+ assertEquals(expect, req);
+ }
}