From 87850a15d93c7a1162d30c129e0dc76cd1b66f94 Mon Sep 17 00:00:00 2001 From: "shashikanth.vh" Date: Thu, 4 Oct 2018 10:40:18 +0530 Subject: Add mandatory empty construct to json template Restapicallnode remove empty parameter from json template, if template mandates empty parameter to be present then it should not be removed. Change-Id: I075e0858f956eb3aff87d2a7387b55caa3310568 Issue-ID: CCSDK-607 Signed-off-by: shashikanth.vh --- .../plugins/sshapicall/TestRestapiCallNode.java | 55 ++++++++++++++++++++++ .../sli/plugins/sshapicall/TestXmlJsonUtil.java | 2 +- 2 files changed, 56 insertions(+), 1 deletion(-) (limited to 'restapi-call-node/provider/src/test/java') diff --git a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestRestapiCallNode.java b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestRestapiCallNode.java index 5c6c4e27..4008c56c 100644 --- a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestRestapiCallNode.java +++ b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestRestapiCallNode.java @@ -51,6 +51,61 @@ public class TestRestapiCallNode { rcn.sendRequest(p, ctx); } + @Test + public void testJsonSdwanVpnTopologyTemplate() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + + ctx.setAttribute("prop.topology", "topoType"); + + ctx.setAttribute("prop.roles_length", "1"); + ctx.setAttribute("prop.roles[0]", "role1"); + + ctx.setAttribute("prop.siteAttachement_length", "2"); + + ctx.setAttribute("prop.siteAttachement[0].siteId", "site1"); + ctx.setAttribute("prop.siteAttachement[0].roles_length", "0"); + ctx.setAttribute("prop.siteAttachement[0].roles[0]", "role1"); + ctx.setAttribute("prop.siteAttachement[0].roles[1]", "role3"); + + ctx.setAttribute("prop.siteAttachement[1].siteId", "site2"); + ctx.setAttribute("prop.siteAttachement[1].roles_length", "1"); + ctx.setAttribute("prop.siteAttachement[1].roles[0]", "role2"); + + Map p = new HashMap(); + p.put("templateFileName", "src/test/resources/sdwan-vpn-topology.json"); + p.put("restapiUrl", "http://echo.getpostman.com"); + p.put("restapiUser", "user1"); + p.put("restapiPassword", "abc123"); + p.put("format", "json"); + p.put("httpMethod", "post"); + p.put("responsePrefix", "response"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } + + @Test + public void testJsonSdwanSiteTemplate() throws SvcLogicException { + SvcLogicContext ctx = new SvcLogicContext(); + + ctx.setAttribute("prop.name", "site1"); + + + Map p = new HashMap(); + p.put("templateFileName", "src/test/resources/sdwan-site.json"); + p.put("restapiUrl", "http://echo.getpostman.com"); + p.put("restapiUser", "user1"); + p.put("restapiPassword", "abc123"); + p.put("format", "json"); + p.put("httpMethod", "post"); + p.put("responsePrefix", "response"); + p.put("skipSending", "true"); + + RestapiCallNode rcn = new RestapiCallNode(); + rcn.sendRequest(p, ctx); + } + @Test public void testJsonTemplate() throws SvcLogicException { SvcLogicContext ctx = new SvcLogicContext(); diff --git a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestXmlJsonUtil.java b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestXmlJsonUtil.java index bd9ff1c9..31fa2f9f 100644 --- a/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestXmlJsonUtil.java +++ b/restapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestXmlJsonUtil.java @@ -254,7 +254,7 @@ public class TestXmlJsonUtil { "}\r\n" + ""; - String xmlout = XmlJsonUtil.removeEmptyStructJson(xmlin); + String xmlout = XmlJsonUtil.removeEmptyStructJson(null, xmlin); log.info(xmlout); Assert.assertEquals(xmloutexpected, xmlout); -- cgit 1.2.3-korg