From da54fc49d3f16d7028a42cd90ad1500973814790 Mon Sep 17 00:00:00 2001 From: janani b Date: Mon, 8 Oct 2018 16:13:36 +0530 Subject: Appending dummy root node to XML data format To hold all the children in XML message a dummy root node is added Issue-ID: CCSDK-324 Change-Id: I7cf0266d15e6bfaa2b9207e77d8bd5372a164b4f Signed-off-by: janani b --- .../dfserializer/DataFormatSerializerTest.java | 20 ++++++ .../dfserializer/DataFormatUtilsTest.java | 78 ++++++++++++---------- 2 files changed, 63 insertions(+), 35 deletions(-) (limited to 'restconf-client/provider/src/test/java/org') diff --git a/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormatSerializerTest.java b/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormatSerializerTest.java index 40f4c4b1b..1185eea1c 100644 --- a/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormatSerializerTest.java +++ b/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormatSerializerTest.java @@ -54,6 +54,7 @@ import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DataFormat import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DataFormatUtilsTest.ENCODE_TO_XML_ID; import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DataFormatUtilsTest.ENCODE_TO_XML_RPC; import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DataFormatUtilsTest.ENCODE_TO_XML_YANG; +import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DataFormatUtilsTest.ENCODE_TO_XML_YANG_AUG_POST; /** @@ -276,6 +277,25 @@ public class DataFormatSerializerTest { assertThat(dfCaptor.getResult(), is(ENCODE_TO_XML_YANG)); } + /** + * Verifies encoding of parameters to XML data format with augment as + * root child. + * + * @throws SvcLogicException when test case fails + */ + @Test + public void encodeToXmlWithAugAsRootChild() throws SvcLogicException { + String pre = "test-yang:cont1.cont2."; + SvcLogicContext ctx = createAttListYang(pre); + p.put("dirPath", "src/test/resources"); + p.put("format", "xml"); + p.put("httpMethod", "post"); + p.put("restapiUrl", "http://echo.getpostman" + + ".com/restconf/operations/test-yang:cont1/cont2/cont4"); + restconf.sendRequest(p, ctx); + assertThat(dfCaptor.getResult(), is(ENCODE_TO_XML_YANG_AUG_POST)); + } + /** * Verifies decoding of parameters from XML data format with containers, * grouping and augment. diff --git a/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormatUtilsTest.java b/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormatUtilsTest.java index 7e6445fcd..a0a154bf3 100644 --- a/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormatUtilsTest.java +++ b/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormatUtilsTest.java @@ -249,6 +249,47 @@ public final class DataFormatUtilsTest { " }\n" + "}"; + static final String ENCODE_TO_XML_YANG_COMMON = "\n" + + "\n" + + " abc\n" + + " abc\n" + + " \n" + + " abc\n" + + " \n" + + " \n" + + " abc\n" + + " \n" + + " abc\n" + + " \n" + + " abc\n" + + " \n" + + "\n" + + "\n" + + " test\n" + + "\n" + + "\n" + + " create\n" + + "\n" + + "abc\n" + + "unbounded\n" + + "8\n" + + "\n" + + " true\n" + + ""; + + static final String ENCODE_TO_XML_YANG_AUG_POST = "\n" + + "abc" + + "" + + ENCODE_TO_XML_YANG_COMMON + "\n"; + static final String ENCODE_TO_XML_YANG = "\n" + "\n" + @@ -305,40 +346,8 @@ public final class DataFormatUtilsTest { " abc\n" + " abc\n" + " \n" + - " abc\n" + - " \n" + - " abc\n" + - " abc\n" + - " \n" + - " abc\n" + - " \n" + - " \n" + - " abc\n" + - " \n" + - " abc\n" + - " \n" + - " abc\n" + - " \n" + - " \n" + - " \n" + - " test\n" + - " \n" + - " \n" + - " create\n" + - " \n" + - " abc\n" + - " unbounded\n" + - " 8\n" + - " \n" + - " true\n" + - " \n" + + " abc"+ + addSpace(ENCODE_TO_XML_YANG_COMMON, 8) + "\n" + " \n" + " abc\n" + " abc\n" + @@ -362,7 +371,6 @@ public final class DataFormatUtilsTest { " \n" + "\n"; - static final String ENCODE_TO_JSON_RPC = "{\n" + " \"test-yang:input\": {\n" + " \"leaf30\": \"abc\",\n" + -- cgit 1.2.3-korg