summaryrefslogtreecommitdiffstats
path: root/restconf-client/provider/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'restconf-client/provider/src/test')
-rw-r--r--restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/SseServerMock.java68
-rw-r--r--restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/TestRestconfDiscoveryNode.java175
-rw-r--r--restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormatSerializerTest.java996
-rw-r--r--restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormatUtilsTest.java631
-rw-r--r--restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/IdentifierValidationTest.java762
-rw-r--r--restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/IdentifierValidationUtilsTest.java469
-rw-r--r--restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/PropertiesSerializerTest.java1144
-rw-r--r--restconf-client/provider/src/test/resources/yang/execution-service.yang43
-rw-r--r--restconf-client/provider/src/test/resources/yang/identity-test.yang77
-rw-r--r--restconf-client/provider/src/test/resources/yang/identity-types-second.yang25
-rw-r--r--restconf-client/provider/src/test/resources/yang/identity-types.yang17
-rw-r--r--restconf-client/provider/src/test/resources/yang/test-augment.yang106
-rw-r--r--restconf-client/provider/src/test/resources/yang/test-yang.yang231
-rw-r--r--restconf-client/provider/src/test/resources/yang/test_augment_1_for_module.yang108
-rw-r--r--restconf-client/provider/src/test/resources/yang/test_name_of_the_module.yang231
15 files changed, 5083 insertions, 0 deletions
diff --git a/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/SseServerMock.java b/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/SseServerMock.java
new file mode 100644
index 000000000..35ac221fb
--- /dev/null
+++ b/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/SseServerMock.java
@@ -0,0 +1,68 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - CCSDK
+ * ================================================================================
+ * Copyright (C) 2018 Huawei Technologies Co., Ltd. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.ccsdk.sli.plugins.restconfdiscovery;
+
+import org.glassfish.jersey.media.sse.EventOutput;
+import org.glassfish.jersey.media.sse.OutboundEvent;
+import org.glassfish.jersey.media.sse.SseFeature;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import java.io.IOException;
+
+@Path("events")
+public class SseServerMock {
+
+ @GET
+ @Produces(SseFeature.SERVER_SENT_EVENTS)
+ public EventOutput getServerSentEvents() throws IOException {
+ String data = "{" +
+ "\"ietf-restconf:notification\" : {" +
+ " \"eventTime\" : \"2017-10-25T08:22:33.44Z\"," +
+ " \"ietf-yang-push:push-change-update\": {" +
+ "\"subscription-id\":\"89\"," +
+ "\"datastore-changes\": {" +
+ "\"ietf-yang-patch:yang-patch\":{" +
+ "\"patch-id\":\"1\"," +
+ "\"edit\":[{" +
+ "\"edit-id\":\"edit1\"," +
+ "\"operation\":\"merge\"," +
+ "\"target\":\"/ietf-interfaces:interfaces-state\"," +
+ "\"value\": {" +
+ "\"ietf-interfaces:interfaces-state\":{"+
+ "\"interface\": {" +
+ "\"name\":\"eth0\"," +
+ "\"oper-status\":\"down\"," +
+ "}" +
+ "}" +
+ "}" +
+ "}]"+
+ "}" +
+ "}" +
+ "}" +
+ "}" +
+ "}";
+ final EventOutput result = new EventOutput();
+ result.write(new OutboundEvent.Builder().data(String.class, data).build());
+ result.close();
+ return result;
+ }
+}
diff --git a/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/TestRestconfDiscoveryNode.java b/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/TestRestconfDiscoveryNode.java
new file mode 100644
index 000000000..aa89d67d7
--- /dev/null
+++ b/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/TestRestconfDiscoveryNode.java
@@ -0,0 +1,175 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - CCSDK
+ * ================================================================================
+ * Copyright (C) 2018 Huawei Technologies Co., Ltd. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.ccsdk.sli.plugins.restconfdiscovery;
+
+import org.glassfish.grizzly.http.server.HttpServer;
+import org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory;
+import org.glassfish.jersey.media.sse.SseFeature;
+import org.glassfish.jersey.server.ResourceConfig;
+import org.junit.Test;
+import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
+import org.onap.ccsdk.sli.core.sli.SvcLogicException;
+import org.onap.ccsdk.sli.plugins.restapicall.RestapiCallNode;
+import org.onap.ccsdk.sli.plugins.restconfapicall.RestconfApiCallNode;
+
+import java.io.IOException;
+import java.net.URI;
+import java.util.HashMap;
+import java.util.Map;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+
+public class TestRestconfDiscoveryNode {
+
+ private static final URI CONTEXT = URI.create("http://localhost:8080/");
+
+ @Test
+ public void sendRequest() throws SvcLogicException, InterruptedException, IOException {
+ final ResourceConfig resourceConfig = new ResourceConfig(
+ SseServerMock.class, SseFeature.class);
+ HttpServer server = GrizzlyHttpServerFactory.createHttpServer(CONTEXT,
+ resourceConfig);
+ server.start();
+ RestconfApiCallNode restconf = mock(RestconfApiCallNode.class);
+ doNothing().when(restconf)
+ .sendRequest(any(Map.class), any(SvcLogicContext.class));
+ RestapiCallNode restApi = new RestapiCallNode();
+ doReturn(restApi).when(restconf).getRestapiCallNode();
+
+ SvcLogicContext ctx = new SvcLogicContext();
+ ctx.setAttribute("prop.encoding-json", "encoding-json");
+ ctx.setAttribute("restapi-result.response-code", "200");
+ ctx.setAttribute("restapi-result.ietf-subscribed-notifications" +
+ ":establish-subscription.output.identifier",
+ "89");
+
+ Map<String, String> p = new HashMap<>();
+ p.put("sseConnectURL", "http://localhost:8080/events");
+ p.put("subscriberId", "networkId");
+ p.put("responsePrefix", "restapi-result");
+ p.put("restapiUser", "access");
+ p.put("restapiPassword", "abc@123");
+ p.put("customHttpHeaders", "X-ACCESS-TOKEN=x-ik2ps4ikvzupbx0486ft" +
+ "1ebzs7rt85futh9ho6eofy3wjsap7wqktemlqm4bbsmnar3vrtbyrzuk" +
+ "bv5itd6m1cftldpjarnyle3sdcqq9hftc4lebz464b5ffxmlbvg9");
+ p.put("restapiUrl", "https://localhost:8080/restconf/operations/" +
+ "ietf-subscribed-notifications:establish-subscription");
+ p.put("module", "testmodule");
+ p.put("rpc", "testrpc");
+ p.put("version", "1.0");
+ p.put("mode", "sync");
+ RestconfDiscoveryNode rdn = new RestconfDiscoveryNode(restconf);
+ rdn.establishSubscription(p, ctx);
+ Thread.sleep(1000);
+ rdn.deleteSubscription(p, ctx);
+ server.shutdown();
+ }
+
+ @Test(expected = SvcLogicException.class)
+ public void testSubGraphExecution() throws SvcLogicException{
+ SvcLogicGraphInfo subDg = new SvcLogicGraphInfo();
+ subDg.mode("sync");
+ subDg.module("l3VpnService");
+ subDg.rpc("createVpn");
+ subDg.version("1.0");
+ SvcLogicContext ctx = new SvcLogicContext();
+ subDg.executeGraph(ctx);
+ }
+
+ @Test(expected = SvcLogicException.class)
+ public void testEstablishSubscriptionWithoutSubscriberId()
+ throws SvcLogicException{
+ SvcLogicContext ctx = new SvcLogicContext();
+ Map<String, String> p = new HashMap<>();
+ RestconfDiscoveryNode rdn = new RestconfDiscoveryNode(
+ new RestconfApiCallNode(new RestapiCallNode()));
+ rdn.establishSubscription(p, ctx);
+ }
+
+ @Test
+ public void testResponseCode() {
+ SvcLogicContext ctx = new SvcLogicContext();
+ ctx.setAttribute("restapi-result.response-code", "200");
+ ctx.setAttribute("response-code", "404");
+ RestconfDiscoveryNode rdn = new RestconfDiscoveryNode(
+ new RestconfApiCallNode(new RestapiCallNode()));
+ assertThat(rdn.getResponseCode("restapi-result", ctx),
+ is("200"));
+ assertThat(rdn.getResponseCode(null, ctx),
+ is("404"));
+ }
+
+ @Test
+ public void testOutputIdentifier() {
+ SvcLogicContext ctx = new SvcLogicContext();
+ ctx.setAttribute("restapi-result.ietf-subscribed-notifications:" +
+ "establish-subscription.output.identifier",
+ "89");
+ ctx.setAttribute("ietf-subscribed-notifications:establish-subscripti" +
+ "on.output.identifier", "89");
+ RestconfDiscoveryNode rdn = new RestconfDiscoveryNode(
+ new RestconfApiCallNode(new RestapiCallNode()));
+ assertThat(rdn.getOutputIdentifier("restapi-result", ctx),
+ is("89"));
+ }
+
+ @Test
+ public void testGetTokenId() {
+ String customHttpHeaders = "X-ACCESS-TOKEN=x-ik2ps4ikvzupbx0486ft1ebzs7rt85" +
+ "futh9ho6eofy3wjsap7wqktemlqm4bbsmnar3vrtbyrzukbv5itd6m1cftldpjarny" +
+ "le3sdcqq9hftc4lebz464b5ffxmlbvg9";
+ RestconfDiscoveryNode rdn = new RestconfDiscoveryNode(
+ new RestconfApiCallNode(new RestapiCallNode()));
+
+ assertThat(rdn.getTokenId(customHttpHeaders),
+ is("x-ik2ps4ikvzupbx0486ft1ebzs7rt85futh9ho6eofy3wjsap7wqkt" +
+ "emlqm4bbsmnar3vrtbyrzukbv5itd6m1cftldpjarnyle3sdcqq9h" +
+ "ftc4lebz464b5ffxmlbvg9"));
+ }
+
+ @Test
+ public void testSubscriptionInfo() throws SvcLogicException {
+ SubscriptionInfo info = new SubscriptionInfo();
+ info.subscriberId("network-id");
+ info.subscriptionId("8");
+ info.filterUrl("/ietf-interfaces:interfaces");
+ info.yangFilePath("/opt/yang");
+ SvcLogicGraphInfo svcLogicGraphInfo = new SvcLogicGraphInfo();
+ svcLogicGraphInfo.mode("sync");
+ svcLogicGraphInfo.module("testModule");
+ svcLogicGraphInfo.rpc("testRpc");
+ svcLogicGraphInfo.version("1.0");
+ info.callBackDG(svcLogicGraphInfo);
+ assertThat(info.subscriberId(), is("network-id"));
+ assertThat(info.subscriptionId(), is("8"));
+ assertThat(info.filterUrl(), is("/ietf-interfaces:interfaces"));
+ assertThat(info.yangFilePath(), is("/opt/yang"));
+ assertThat(info.callBackDG().module(), is("testModule"));
+ assertThat(info.callBackDG().mode(), is("sync"));
+ assertThat(info.callBackDG().rpc(), is("testRpc"));
+ assertThat(info.callBackDG().version(), is("1.0"));
+ }
+}
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
new file mode 100644
index 000000000..aa1e50d6a
--- /dev/null
+++ b/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormatSerializerTest.java
@@ -0,0 +1,996 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - CCSDK
+ * ================================================================================
+ * Copyright (C) 2018 Huawei Technologies Co., Ltd. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.ccsdk.sli.plugins.yangserializers.dfserializer;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.invocation.InvocationOnMock;
+import org.mockito.stubbing.Answer;
+import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
+import org.onap.ccsdk.sli.core.sli.SvcLogicException;
+import org.onap.ccsdk.sli.plugins.restapicall.HttpResponse;
+import org.onap.ccsdk.sli.plugins.restapicall.RestapiCallNode;
+import org.onap.ccsdk.sli.plugins.restconfapicall.RestconfApiCallNode;
+import org.opendaylight.restconf.common.context.InstanceIdentifierContext;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.doAnswer;
+import static org.mockito.Mockito.doCallRealMethod;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+import static org.onap.ccsdk.sli.plugins.restapicall.HttpMethod.GET;
+import static org.onap.ccsdk.sli.plugins.restapicall.HttpMethod.PATCH;
+import static org.onap.ccsdk.sli.plugins.restapicall.HttpMethod.POST;
+import static org.onap.ccsdk.sli.plugins.restapicall.HttpMethod.PUT;
+import static org.onap.ccsdk.sli.plugins.restconfapicall.RestconfApiUtils.parseUrl;
+import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DataFormatUtilsTest.DECODE_ANYXML_RESPONSE;
+import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DataFormatUtilsTest.DECODE_FROM_JSON_RPC;
+import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DataFormatUtilsTest.DECODE_FROM_XML_RPC;
+import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DataFormatUtilsTest.ENCODE_TO_ANYXML;
+import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DataFormatUtilsTest.ENCODE_TO_JSON_ID;
+import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DataFormatUtilsTest.ENCODE_TO_JSON_ID_PUT;
+import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DataFormatUtilsTest.ENCODE_TO_JSON_RPC;
+import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DataFormatUtilsTest.ENCODE_TO_JSON_YANG;
+import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DataFormatUtilsTest.ENCODE_TO_JSON_YANG_AUG_POST;
+import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DataFormatUtilsTest.ENCODE_TO_JSON_YANG_PUT;
+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_ID_PUT;
+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;
+import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DataFormatUtilsTest.ENCODE_TO_XML_YANG_PUT;
+
+
+/**
+ * Unit test cases for data format serialization and restconf api call node.
+ */
+public class DataFormatSerializerTest {
+
+ private Map<String, String> p;
+
+ private RestconfApiCallNode restconf;
+
+ private RestapiCallNode restApi;
+
+ private DfCaptor dfCaptor;
+
+ /**
+ * Sets up the pre-requisite for each test case.
+ *
+ * @throws SvcLogicException when test case fails
+ */
+ @Before
+ public void setUp() throws SvcLogicException {
+ p = new HashMap<>();
+ p.put("restapiUser", "user1");
+ p.put("restapiPassword", "abc123");
+ p.put("responsePrefix", "response");
+ p.put("skipSending", "true");
+ restApi = new RestapiCallNode();
+ restconf = mock(RestconfApiCallNode.class);
+ dfCaptor = new DfCaptor();
+ createMethodMocks();
+ }
+
+ /**
+ * Creates method mocks using mockito for RestconfApiCallNode class.
+ *
+ * @throws SvcLogicException when test case fails
+ */
+ private void createMethodMocks() throws SvcLogicException {
+ doReturn(restApi).when(restconf).getRestapiCallNode();
+ doCallRealMethod().when(restconf).sendRequest(
+ any(Map.class), any(SvcLogicContext.class));
+ doCallRealMethod().when(restconf).sendRequest(
+ any(Map.class), any(SvcLogicContext.class), any(Integer.class));
+ doAnswer(dfCaptor).when(restconf).serializeRequest(
+ any(Map.class), any(YangParameters.class), any(String.class),
+ any(InstanceIdentifierContext.class));
+ doAnswer(dfCaptor).when(restconf).updateReq(
+ any(String.class), any(YangParameters.class),
+ any(InstanceIdentifierContext.class));
+ }
+
+ /**
+ * Creates mock using mockito with input data for decoding.
+ *
+ * @param decodeData input data
+ * @throws SvcLogicException when test case fails
+ */
+ private void createMockForDecode(String decodeData)
+ throws SvcLogicException {
+ doReturn(decodeData).when(restconf).getResponse(
+ any(SvcLogicContext.class), any(YangParameters.class),
+ any(String.class), any(HttpResponse.class));
+ doCallRealMethod().when(restconf).serializeResponse(
+ any(YangParameters.class), any(String.class), any(String.class),
+ any(InstanceIdentifierContext.class));
+ }
+
+ /**
+ * Verifies encoding of parameters to JSON data format with identity-ref
+ * and inter-file linking.
+ *
+ * @throws SvcLogicException when test case fails
+ */
+ @Test
+ public void encodeToJsonId() throws SvcLogicException {
+ String pre = "identity-test_test.";
+ SvcLogicContext ctx = createAttList(pre);
+ ctx.setAttribute(pre + "l", "abc");
+ p.put("dirPath", "src/test/resources");
+ p.put("format", "json");
+ p.put("httpMethod", "post");
+ p.put("restapiUrl", "http://echo.getpostman" +
+ ".com/restconf/operations/identity-test:test");
+ restconf.sendRequest(p, ctx);
+ assertThat(dfCaptor.getResult(), is(ENCODE_TO_JSON_ID));
+ }
+
+ /**
+ * Verifies encoding of parameters to JSON data format any xml in it.
+ *
+ * @throws SvcLogicException when test case fails
+ */
+ @Test
+ public void encodeForAnyXml() throws SvcLogicException {
+ String pre = "execution-service_process.";
+ SvcLogicContext ctx = createAnyXmlAttList(pre);
+ p.put("dirPath", "src/test/resources");
+ p.put("format", "json");
+ p.put("httpMethod", "post");
+ p.put("restapiUrl", "http://echo.getpostman" +
+ ".com/api/v1/execution-service/process");
+ restconf.sendRequest(p, ctx);
+ assertThat(dfCaptor.getResult(), is(ENCODE_TO_ANYXML));
+ }
+
+ /**
+ * Verifies encoding of parameters to JSON data format with identity-ref
+ * and inter-file linking for put operation-type.
+ *
+ * @throws SvcLogicException when test case fails
+ */
+ @Test
+ public void encodeToJsonIdWithPut() throws SvcLogicException {
+ String pre = "identity-test_test.";
+ SvcLogicContext ctx = createAttList(pre);
+ ctx.setAttribute(pre + "l", "abc");
+ p.put("dirPath", "src/test/resources");
+ p.put("format", "json");
+ p.put("httpMethod", "put");
+ p.put("restapiUrl", "http://echo.getpostman" +
+ ".com/restconf/operations/identity-test:test");
+ restconf.sendRequest(p, ctx);
+ assertThat(dfCaptor.getResult(), is(ENCODE_TO_JSON_ID_PUT));
+ }
+
+ /**
+ * Verifies encoding of parameters to JSON data format with identity-ref
+ * and inter-file linking for patch operation-type.
+ *
+ * @throws SvcLogicException when test case fails
+ */
+ @Test
+ public void encodeToJsonIdWithPatch() throws SvcLogicException {
+ String pre = "identity-test_test.";
+ SvcLogicContext ctx = createAttList(pre);
+ ctx.setAttribute(pre + "l", "abc");
+ p.put("dirPath", "src/test/resources");
+ p.put("format", "json");
+ p.put("httpMethod", "patch");
+ p.put("restapiUrl", "http://echo.getpostman" +
+ ".com/restconf/operations/identity-test:test");
+ restconf.sendRequest(p, ctx);
+ assertThat(dfCaptor.getResult(), is(ENCODE_TO_JSON_ID_PUT));
+ }
+
+ /**
+ * Verifies encoding of parameters to XML data format with identity-ref
+ * and inter-file linking.
+ *
+ * @throws SvcLogicException when test case fails
+ */
+ @Test
+ public void encodeToXmlId() throws SvcLogicException {
+ String pre = "identity-test_test.";
+ SvcLogicContext ctx = createAttList(pre);
+ p.put("dirPath", "src/test/resources");
+ p.put("format", "xml");
+ p.put("httpMethod", "post");
+ p.put("restapiUrl", "http://echo.getpostman" +
+ ".com/restconf/operations/identity-test:test");
+ restconf.sendRequest(p, ctx);
+ assertThat(dfCaptor.getResult(), is(ENCODE_TO_XML_ID));
+ }
+
+ /**
+ * Verifies encoding of parameters to XML data format with identity-ref
+ * and inter-file linking for put operation-type.
+ *
+ * @throws SvcLogicException when test case fails
+ */
+ @Test
+ public void encodeToXmlIdWithPut() throws SvcLogicException {
+ String pre = "identity-test_test.";
+ SvcLogicContext ctx = createAttList(pre);
+ p.put("dirPath", "src/test/resources");
+ p.put("format", "xml");
+ p.put("httpMethod", "put");
+ p.put("restapiUrl", "http://echo.getpostman" +
+ ".com/restconf/operations/identity-test:test");
+ restconf.sendRequest(p, ctx);
+ assertThat(dfCaptor.getResult(), is(ENCODE_TO_XML_ID_PUT));
+ }
+
+ /**
+ * Verifies encoding of parameters to XML data format with identity-ref
+ * and inter-file linking for patch operation-type.
+ *
+ * @throws SvcLogicException when test case fails
+ */
+ @Test
+ public void encodeToXmlIdWithPatch() throws SvcLogicException {
+ String pre = "identity-test_test.";
+ SvcLogicContext ctx = createAttList(pre);
+ p.put("dirPath", "src/test/resources");
+ p.put("format", "xml");
+ p.put("httpMethod", "patch");
+ p.put("restapiUrl", "http://echo.getpostman" +
+ ".com/restconf/operations/identity-test:test");
+ restconf.sendRequest(p, ctx);
+ assertThat(dfCaptor.getResult(), is(ENCODE_TO_XML_ID_PUT));
+ }
+
+ /**
+ * Verifies decoding of parameters from JSON data format with identity-ref
+ * and inter-file linking.
+ *
+ * @throws SvcLogicException when test case fails
+ */
+ @Test
+ public void decodeToJsonId() throws SvcLogicException {
+ createMockForDecode(ENCODE_TO_JSON_ID);
+ SvcLogicContext ctx = new SvcLogicContext();
+ String pre = "identity-test_test.";
+ p.put("dirPath", "src/test/resources");
+ p.put("format", "json");
+ p.put("httpMethod", "get");
+ p.put("restapiUrl", "http://echo.getpostman" +
+ ".com/restconf/operations/identity-test:test");
+ restconf.sendRequest(p, ctx);
+ assertThat(ctx.getAttribute(pre + "l"), is("abc"));
+ verifyAttList(ctx, pre);
+ }
+
+ /**
+ * Verifies decoding of parameters from XML data format with identity-ref
+ * and inter-file linking.
+ *
+ * @throws SvcLogicException when test case fails
+ */
+ @Test
+ public void decodeToXmlId() throws SvcLogicException {
+ createMockForDecode(ENCODE_TO_XML_ID);
+ SvcLogicContext ctx = new SvcLogicContext();
+ String pre = "identity-test_test.";
+ p.put("dirPath", "src/test/resources");
+ p.put("format", "xml");
+ p.put("httpMethod", "get");
+ p.put("restapiUrl", "http://echo.getpostman" +
+ ".com/restconf/operations/identity-test:test");
+ restconf.sendRequest(p, ctx);
+ verifyAttList(ctx, pre);
+ }
+
+ /**
+ * Verifies encoding of parameters to JSON data format with containers,
+ * grouping and augment.
+ *
+ * @throws SvcLogicException when test case fails
+ */
+ @Test
+ public void encodeToJsonYang() throws SvcLogicException {
+ String pre = "test-yang_cont1.cont2.";
+ SvcLogicContext ctx = createAttListYang(pre);
+ p.put("dirPath", "src/test/resources");
+ p.put("format", "json");
+ p.put("httpMethod", "post");
+ p.put("restapiUrl", "http://echo.getpostman" +
+ ".com/restconf/operations/test-yang:cont1");
+ restconf.sendRequest(p, ctx);
+ assertThat(dfCaptor.getResult(), is(ENCODE_TO_JSON_YANG));
+ }
+
+ /**
+ * Verifies encoding of parameters to JSON data format with containers,
+ * grouping and augment for put operation-type.
+ *
+ * @throws SvcLogicException when test case fails
+ */
+ @Test
+ public void encodeToJsonYangWithPut() throws SvcLogicException {
+ String pre = "test-yang_cont1.cont2.";
+ SvcLogicContext ctx = createAttListYang(pre);
+ p.put("dirPath", "src/test/resources");
+ p.put("format", "json");
+ p.put("httpMethod", "put");
+ p.put("restapiUrl", "http://echo.getpostman" +
+ ".com/restconf/operations/test-yang:cont1/cont2/cont4");
+ restconf.sendRequest(p, ctx);
+ assertThat(dfCaptor.getResult(), is(ENCODE_TO_JSON_YANG_PUT));
+ }
+
+ /**
+ * Verifies encoding of parameters to JSON data format with containers,
+ * grouping and augment for patch operation-type.
+ *
+ * @throws SvcLogicException when test case fails
+ */
+ @Test
+ public void encodeToJsonYangWithPatch() throws SvcLogicException {
+ String pre = "test-yang_cont1.cont2.";
+ SvcLogicContext ctx = createAttListYang(pre);
+ p.put("dirPath", "src/test/resources");
+ p.put("format", "json");
+ p.put("httpMethod", "patch");
+ p.put("restapiUrl", "http://echo.getpostman" +
+ ".com/restconf/operations/test-yang:cont1/cont2/cont4");
+ restconf.sendRequest(p, ctx);
+ assertThat(dfCaptor.getResult(), is(ENCODE_TO_JSON_YANG_PUT));
+ }
+
+ /**
+ * Verifies encoding of parameters to JSON data format with augment as
+ * root child.
+ *
+ * @throws SvcLogicException when test case fails
+ */
+ @Test
+ public void encodeToJsonWithAugAsRootChild() throws SvcLogicException {
+ String pre = "test-yang_cont1.cont2.";
+ SvcLogicContext ctx = createAttListYang(pre);
+ p.put("dirPath", "src/test/resources");
+ p.put("format", "json");
+ 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_JSON_YANG_AUG_POST));
+ }
+
+ /**
+ * Verifies decoding of parameters from JSON data format with containers,
+ * grouping and augment.
+ *
+ * @throws SvcLogicException when test case fails
+ */
+ @Test
+ public void decodeToJsonYang() throws SvcLogicException {
+ createMockForDecode(ENCODE_TO_JSON_YANG);
+ SvcLogicContext ctx = new SvcLogicContext();
+ String pre = "test-yang_cont1.cont2.";
+ p.put("dirPath", "src/test/resources");
+ p.put("format", "json");
+ p.put("httpMethod", "get");
+ p.put("restapiUrl", "http://echo.getpostman" +
+ ".com/restconf/operations/test-yang:cont1");
+ restconf.sendRequest(p, ctx);
+ verifyAttListYang(ctx, pre);
+ }
+
+ /**
+ * Verifies encoding of parameters to XML data format with containers,
+ * grouping and augment.
+ *
+ * @throws SvcLogicException when test case fails
+ */
+ @Test
+ public void encodeToXmlYang() 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");
+ restconf.sendRequest(p, ctx);
+ assertThat(dfCaptor.getResult(), is(ENCODE_TO_XML_YANG));
+ }
+
+ /**
+ * Verifies encoding of parameters to XML data format with containers,
+ * grouping and augment for put operation-type
+ *
+ * @throws SvcLogicException when test case fails
+ */
+ @Test
+ public void encodeToXmlYangWithPut() 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", "put");
+ 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_PUT));
+ }
+
+ /**
+ * Verifies encoding of parameters to XML data format with containers,
+ * grouping and augment for patch operation-type
+ *
+ * @throws SvcLogicException when test case fails
+ */
+ @Test
+ public void encodeToXmlYangWithPatch() 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", "put");
+ 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_PUT));
+ }
+
+ /**
+ * 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.
+ *
+ * @throws SvcLogicException when test case fails
+ */
+ @Test
+ public void decodeToXmlYang() throws SvcLogicException {
+ createMockForDecode(ENCODE_TO_XML_YANG);
+ SvcLogicContext ctx = new SvcLogicContext();
+ String pre = "test-yang_cont1.cont2.";
+ p.put("dirPath", "src/test/resources");
+ p.put("format", "xml");
+ p.put("httpMethod", "get");
+ p.put("restapiUrl", "http://echo.getpostman" +
+ ".com/restconf/operations/test-yang:cont1");
+ restconf.sendRequest(p, ctx);
+ verifyAttListYang(ctx, pre);
+ }
+
+ /**
+ * Verifies encoding of and decoding from, JSON respectively for data
+ * format with containers, grouping and augment.
+ *
+ * @throws SvcLogicException when test case fails
+ */
+ @Test
+ public void codecToJsonRpc() throws SvcLogicException {
+ createMockForDecode(DECODE_FROM_JSON_RPC);
+ String inPre = "test-yang_create-sfc.input.";
+ String outPre = "test-yang_create-sfc.output.";
+ SvcLogicContext ctx = createAttListRpc(inPre);
+ p.put("dirPath", "src/test/resources");
+ p.put("format", "json");
+ p.put("httpMethod", "post");
+ p.put("restapiUrl", "http://echo.getpostman" +
+ ".com/restconf/operations/test-yang:create-sfc");
+ restconf.sendRequest(p, ctx);
+ assertThat(dfCaptor.getResult(), is(ENCODE_TO_JSON_RPC));
+ verifyAttListRpc(ctx, outPre);
+ }
+
+ /**
+ * Verifies encoding of and decoding from, JSON for ANYXML.
+ *
+ * @throws SvcLogicException when test case fails
+ */
+ @Test
+ public void codecForNormalAnyXml() throws SvcLogicException {
+ createMockForDecode(DECODE_ANYXML_RESPONSE);
+ String inPre = "execution-service_process.";
+ SvcLogicContext ctx = createAnyXmlAttList(inPre);
+ p.put("dirPath", "src/test/resources");
+ p.put("format", "json");
+ p.put("httpMethod", "post");
+ p.put("responsePrefix", "pp");
+ p.put("restapiUrl", "http://echo.getpostman" +
+ ".com/api/v1/execution-service/process");
+ restconf.sendRequest(p, ctx);
+ assertThat(dfCaptor.getResult(), is(ENCODE_TO_ANYXML));
+ verifyOutputOfAnyXml(ctx);
+ }
+
+ /**
+ * Verifies encoding of and decoding from, XML respectively for data
+ * format with containers, grouping and augment.
+ *
+ * @throws SvcLogicException when test case fails
+ */
+ @Test
+ public void codecToXmlRpc() throws SvcLogicException {
+ createMockForDecode(DECODE_FROM_XML_RPC);
+ String inPre = "test-yang_create-sfc.input.";
+ String outPre = "test-yang_create-sfc.output.";
+ SvcLogicContext ctx = createAttListRpc(inPre);
+ 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:create-sfc");
+ restconf.sendRequest(p, ctx);
+ assertThat(dfCaptor.getResult(), is(ENCODE_TO_XML_RPC));
+ verifyAttListRpc(ctx, outPre);
+ }
+
+ /**
+ * Verifies URL parser returning path with only schema information for all
+ * kind of URL.
+ *
+ * @throws SvcLogicException when test case fails
+ */
+ @Test
+ public void validateUrlParser() throws SvcLogicException {
+ String actVal = "identity-test:test";
+ String putId = "/for-put";
+ String url1 = "http://echo.getpostman.com/restconf/operations/" +
+ actVal;
+ String url2 = "http://echo.getpostman.com/restconf/data/" + actVal;
+ String url3 = "https://echo.getpostman.com/restconf/operations/" +
+ actVal;
+ String url4 = "https://echo.getpostman.com/restconf/data/" + actVal +
+ putId;
+ String url5 = "http://localhost:8282/restconf/operations/" + actVal;
+ String url6 = "https://localhost:8282/restconf/operations/" + actVal;
+ String url7 = "http://localhost:8282/restconf/data/" + actVal +
+ putId;
+ String url8 = "https://localhost:8282/restconf/data/" + actVal;
+ String url9 = "http://182.2.61.24:2250/restconf/data/" + actVal;
+ String url10 = "https://182.2.61.24:2250/restconf/operations/" + actVal;
+ String url11 = "https://182.2.61.24:2250/api/v1/execution-service" +
+ "/process";
+ String url12 = "https://182.2.61.24:2250/api/v1/execution-service" +
+ "/process/payload";
+ String url13 = "https://182.2.61.24:2250/api/v1/execution-service" +
+ "/process/payload/";
+ String val1 = parseUrl(url1, POST);
+ String val2 = parseUrl(url2, GET);
+ String val3 = parseUrl(url3, PATCH);
+ String val4 = parseUrl(url4, PUT);
+ String val5 = parseUrl(url5, GET);
+ String val6 = parseUrl(url6, POST);
+ String val7 = parseUrl(url7, PUT);
+ String val8 = parseUrl(url8, POST);
+ String val9 = parseUrl(url9, GET);
+ String val10 = parseUrl(url10, POST);
+ String val11 = parseUrl(url11, POST);
+ String val12 = parseUrl(url12, POST);
+ String val13 = parseUrl(url13, POST);
+ assertThat(val1, is(actVal));
+ assertThat(val2, is(actVal));
+ assertThat(val3, is(actVal));
+ assertThat(val4, is(actVal + putId));
+ assertThat(val5, is(actVal));
+ assertThat(val6, is(actVal));
+ assertThat(val7, is(actVal + putId));
+ assertThat(val8, is(actVal));
+ assertThat(val9, is(actVal));
+ assertThat(val10, is(actVal));
+ assertThat(val11, is("execution-service:process"));
+ assertThat(val12, is("execution-service:process/payload"));
+ assertThat(val13, is("execution-service:process/payload/"));
+ }
+
+ /**
+ * Creates attribute list for encoding JSON or XML with ANYXML YANG
+ * file.
+ *
+ * @param pre prefix
+ * @return service logic context
+ */
+ private SvcLogicContext createAnyXmlAttList(String pre) {
+ SvcLogicContext ctx = new SvcLogicContext();
+ String pre1 = pre + "commonHeader.";
+ String pre2 = pre + "actionIdentifiers.";
+ ctx.setAttribute(pre + "isNonAppend", "true");
+ ctx.setAttribute(pre1 + "originatorId", "SDNC_DG");
+ ctx.setAttribute(pre1 + "requestId", "123456-1000");
+ ctx.setAttribute(pre1 + "subRequestId", "sub-123456-1000");
+ ctx.setAttribute(pre2 + "blueprintName",
+ "baseconfiguration");
+ ctx.setAttribute(pre2 + "blueprintVersion", "1.0.0");
+ ctx.setAttribute(pre2 + "actionName", "assign-activate");
+ ctx.setAttribute(pre2 + "mode", "sync");
+ ctx.setAttribute(pre + "payload." +
+ "template-prefix", "vDNS-test");
+ ctx.setAttribute(pre + "payload.resource-assignment-request" +
+ ".resource-assignment-properties",
+ "{\n" +
+ " \"service-instance-id\": " +
+ "\"1234\",\n" +
+ " \"vnf-id\": \"3526\",\n" +
+ " \"customer-name\": \"htipl\",\n" +
+ " \"subscriber-name\": \"huawei\"\n" +
+ " }");
+ return ctx;
+ }
+
+ /**
+ * Creates attribute list for encoding JSON or XML with identity-ref YANG
+ * file.
+ *
+ * @param pre prefix
+ * @return service logic context
+ */
+ private SvcLogicContext createAttList(String pre) {
+ SvcLogicContext ctx = new SvcLogicContext();
+ String pre1 = pre + "con1.interfaces.";
+ ctx.setAttribute(pre + "con1.interface", "identity-types:physical");
+ ctx.setAttribute(pre1 + "int-list[0].iden", "optical");
+ ctx.setAttribute(pre1 + "int-list[0].available.ll[0]", "Giga");
+ ctx.setAttribute(pre1 + "int-list[0].available.ll[1]",
+ "identity-types:Loopback");
+ ctx.setAttribute(pre1 + "int-list[0].available.ll[2]",
+ "identity-types-second:Ethernet");
+ ctx.setAttribute(pre1 + "int-list[0].available.leaf1", "58");
+ ctx.setAttribute(pre1 + "int-list[0].available.leaf2",
+ "identity-types-second:iden2");
+
+ ctx.setAttribute(pre1 + "int-list[1].iden", "214748364");
+ ctx.setAttribute(pre1 + "int-list[1].available.ll[0]", "Giga");
+ ctx.setAttribute(pre1 + "int-list[1].available.ll[1]",
+ "identity-types:Loopback");
+ ctx.setAttribute(pre1 + "int-list[1].available.ll[2]",
+ "identity-types-second:Ethernet");
+ ctx.setAttribute(pre1 + "int-list[1].available.leaf1",
+ "8888");
+ ctx.setAttribute(pre1 + "int-list[1].available.leaf2",
+ "identity-types-second:iden2");
+ return ctx;
+ }
+
+ /**
+ * Creates attribute list for encoding JSON or XML with container,
+ * grouping and augmented YANG file.
+ *
+ * @param pre prefix
+ * @return service logic context
+ */
+ private SvcLogicContext createAttListYang(String pre) {
+ SvcLogicContext ctx = new SvcLogicContext();
+ ctx.setAttribute(pre + "cont3.leaf10", "abc");
+ ctx.setAttribute(pre + "list1[0].leaf1", "true");
+ ctx.setAttribute(pre + "list1[0].leaf2", "abc");
+ ctx.setAttribute(pre + "list1[0].leaf3", "abc");
+ ctx.setAttribute(pre + "list1[0].ll1[0]", "abc");
+ ctx.setAttribute(pre + "list1[0].ll1[1]", "abc");
+ ctx.setAttribute(pre + "list1[0].ll2[0]", "abc");
+ ctx.setAttribute(pre + "list1[0].ll2[1]", "abc");
+ ctx.setAttribute(pre + "list1[0].cont4.leaf11", "abc");
+ ctx.setAttribute(pre + "list1[0].list4[0].leaf8", "abc");
+ ctx.setAttribute(pre + "list1[0].list4[1].leaf8", "abc");
+ ctx.setAttribute(pre + "list1[0].list5[0].leaf9", "abc");
+ ctx.setAttribute(pre + "list1[0].list5[1].leaf9", "abc");
+ ctx.setAttribute(pre + "list1[1].leaf1", "true");
+ ctx.setAttribute(pre + "list1[1].leaf2", "abc");
+ ctx.setAttribute(pre + "list1[1].leaf3", "abc");
+ ctx.setAttribute(pre + "list1[1].ll1[0]", "abc");
+ ctx.setAttribute(pre + "list1[1].ll1[1]", "abc");
+ ctx.setAttribute(pre + "list1[1].ll2[0]", "abc");
+ ctx.setAttribute(pre + "list1[1].ll2[1]", "abc");
+ ctx.setAttribute(pre + "list1[1].cont4.leaf11", "abc");
+ ctx.setAttribute(pre + "list1[1].list4[0].leaf8", "abc");
+ ctx.setAttribute(pre + "list1[1].list4[1].leaf8", "abc");
+ ctx.setAttribute(pre + "list1[1].list5[0].leaf9", "abc");
+ ctx.setAttribute(pre + "list1[1].list5[1].leaf9", "abc");
+ ctx.setAttribute(pre + "list2[0].leaf4", "abc");
+ ctx.setAttribute(pre + "list2[1].leaf4", "abc");
+ ctx.setAttribute(pre + "leaf5", "abc");
+ ctx.setAttribute(pre + "leaf6", "abc");
+ ctx.setAttribute(pre + "ll3[0]", "abc");
+ ctx.setAttribute(pre + "ll3[1]", "abc");
+ ctx.setAttribute(pre + "ll4[0]", "abc");
+ ctx.setAttribute(pre + "ll4[1]", "abc");
+ ctx.setAttribute(pre + "cont4.leaf10", "abc");
+ ctx.setAttribute(pre + "list6[0].leaf11", "abc");
+ ctx.setAttribute(pre + "list6[1].leaf11", "abc");
+ ctx.setAttribute(pre + "leaf12", "abc");
+ ctx.setAttribute(pre + "ll5[0]", "abc");
+ ctx.setAttribute(pre + "ll5[1]", "abc");
+ ctx.setAttribute(pre + "cont4.test-augment_cont5.leaf13", "true");
+ ctx.setAttribute(pre + "cont4.test-augment_list7[0].leaf14", "test");
+ ctx.setAttribute(pre + "cont4.test-augment_list7[1].leaf14", "create");
+ ctx.setAttribute(pre + "cont4.test-augment_leaf15", "abc");
+ ctx.setAttribute(pre + "cont4.test-augment_ll6[0]", "unbounded");
+ ctx.setAttribute(pre + "cont4.test-augment_ll6[1]", "8");
+ ctx.setAttribute(pre + "cont4.test-augment_cont13.cont12.leaf26",
+ "abc");
+ ctx.setAttribute(pre + "cont4.test-augment_cont13.list9[0].leaf27",
+ "abc");
+ ctx.setAttribute(pre + "cont4.test-augment_cont13.list9[1].leaf27",
+ "abc");
+ ctx.setAttribute(pre + "cont4.test-augment_cont13.leaf28", "abc");
+ ctx.setAttribute(pre + "cont4.test-augment_cont13.ll9[0]", "abc");
+ ctx.setAttribute(pre + "cont4.test-augment_cont13.ll9[1]", "abc");
+ return ctx;
+ }
+
+ /**
+ * Creates attribute list for encoding JSON or XML with RPC YANG file.
+ *
+ * @param pre prefix
+ * @return service logic context
+ */
+ private SvcLogicContext createAttListRpc(String pre) {
+ SvcLogicContext ctx = new SvcLogicContext();
+ ctx.setAttribute(pre + "cont14.leaf28", "abc");
+ ctx.setAttribute(pre + "list10[0].leaf29", "abc");
+ ctx.setAttribute(pre + "list10[1].leaf29", "abc");
+ ctx.setAttribute(pre + "leaf30", "abc");
+ ctx.setAttribute(pre + "ll10[0]", "abc");
+ ctx.setAttribute(pre + "ll10[1]", "abc");
+ ctx.setAttribute(pre + "cont15.leaf31", "abc");
+ ctx.setAttribute(pre + "cont13.list9[0].leaf27", "abc");
+ ctx.setAttribute(pre + "cont13.list9[1].leaf27", "abc");
+ ctx.setAttribute(pre + "cont13.leaf28", "abc");
+ ctx.setAttribute(pre + "cont13.ll9[0]", "abc");
+ ctx.setAttribute(pre + "cont13.ll9[1]", "abc");
+ return ctx;
+ }
+
+ /**
+ * Verifies the attribute list for decoding from JSON or XML with
+ * identity-ref YANG file.
+ *
+ * @param ctx service logic context
+ * @param pre prefix
+ */
+ private void verifyAttList(SvcLogicContext ctx, String pre) {
+ String pre1 = pre + "con1.interfaces.";
+ assertThat(ctx.getAttribute(pre + "con1.interface"), is(
+ "identity-types:physical"));
+ assertThat(ctx.getAttribute(pre + "con1.interface"), is(
+ "identity-types:physical"));
+ assertThat(ctx.getAttribute(pre1 + "int-list[0].iden"), is("optical"));
+ assertThat(ctx.getAttribute(pre1 + "int-list[0].available.ll[0]"), is(
+ "Giga"));
+ assertThat(ctx.getAttribute(pre1 + "int-list[0].available.ll[1]"), is(
+ "identity-types:Loopback"));
+ assertThat(ctx.getAttribute(pre1 + "int-list[0].available.ll[2]"), is(
+ "identity-types-second:Ethernet"));
+ assertThat(ctx.getAttribute(pre1 + "int-list[0].available.leaf1"), is(
+ "58"));
+ assertThat(ctx.getAttribute(pre1 + "int-list[0].available.leaf2"), is(
+ "identity-types-second:iden2"));
+
+ assertThat(ctx.getAttribute(pre1 + "int-list[1].iden"), is(
+ "214748364"));
+ assertThat(ctx.getAttribute(pre1 + "int-list[1].available.ll[0]"), is(
+ "Giga"));
+ assertThat(ctx.getAttribute(pre1 + "int-list[1].available.ll[1]"), is(
+ "identity-types:Loopback"));
+ assertThat(ctx.getAttribute(pre1 + "int-list[1].available.ll[2]"), is(
+ "identity-types-second:Ethernet"));
+ assertThat(ctx.getAttribute(pre1 + "int-list[1].available.leaf1"), is(
+ "8888"));
+ assertThat(ctx.getAttribute(pre1 + "int-list[1].available.leaf2"), is(
+ "identity-types-second:iden2"));
+ }
+
+ /**
+ * Verifies the attribute list for decoding from JSON or XML with
+ * container, grouping and augmented file.
+ *
+ * @param ctx service logic context
+ * @param pre prefix
+ */
+ private void verifyAttListYang(SvcLogicContext ctx, String pre) {
+ assertThat(ctx.getAttribute(pre + "cont3.leaf10"), is("abc"));
+ assertThat(ctx.getAttribute(pre + "list1[0].leaf1"), is("true"));
+ assertThat(ctx.getAttribute(pre + "list1[0].leaf2"), is("abc"));
+ assertThat(ctx.getAttribute(pre + "list1[0].leaf3"), is("abc"));
+ assertThat(ctx.getAttribute(pre + "list1[0].ll1[0]"), is("abc"));
+ assertThat(ctx.getAttribute(pre + "list1[0].ll1[1]"), is("abc"));
+ assertThat(ctx.getAttribute(pre + "list1[0].ll2[0]"), is("abc"));
+ assertThat(ctx.getAttribute(pre + "list1[0].ll2[1]"), is("abc"));
+ assertThat(ctx.getAttribute(pre + "list1[0].cont4.leaf11"), is("abc"));
+ assertThat(ctx.getAttribute(pre + "list1[0].list4[0].leaf8"),
+ is("abc"));
+ assertThat(ctx.getAttribute(pre + "list1[0].list4[1].leaf8"),
+ is("abc"));
+ assertThat(ctx.getAttribute(pre + "list1[0].list5[0].leaf9"),
+ is("abc"));
+ assertThat(ctx.getAttribute(pre + "list1[0].list5[1].leaf9"),
+ is("abc"));
+ assertThat(ctx.getAttribute(pre + "list1[1].leaf1"), is("true"));
+ assertThat(ctx.getAttribute(pre + "list1[1].leaf2"), is("abc"));
+ assertThat(ctx.getAttribute(pre + "list1[1].leaf3"), is("abc"));
+ assertThat(ctx.getAttribute(pre + "list1[1].ll1[0]"), is("abc"));
+ assertThat(ctx.getAttribute(pre + "list1[1].ll1[1]"), is("abc"));
+ assertThat(ctx.getAttribute(pre + "list1[1].ll2[0]"), is("abc"));
+ assertThat(ctx.getAttribute(pre + "list1[1].ll2[1]"), is("abc"));
+ assertThat(ctx.getAttribute(pre + "list1[1].cont4.leaf11"), is("abc"));
+ assertThat(ctx.getAttribute(pre + "list1[1].list4[0].leaf8"),
+ is("abc"));
+ assertThat(ctx.getAttribute(pre + "list1[1].list4[1].leaf8"),
+ is("abc"));
+ assertThat(ctx.getAttribute(pre + "list1[1].list5[0].leaf9"),
+ is("abc"));
+ assertThat(ctx.getAttribute(pre + "list1[1].list5[1].leaf9"),
+ is("abc"));
+ assertThat(ctx.getAttribute(pre + "list2[0].leaf4"), is("abc"));
+ assertThat(ctx.getAttribute(pre + "list2[1].leaf4"), is("abc"));
+ assertThat(ctx.getAttribute(pre + "leaf5"), is("abc"));
+ assertThat(ctx.getAttribute(pre + "leaf6"), is("abc"));
+ assertThat(ctx.getAttribute(pre + "ll3[0]"), is("abc"));
+ assertThat(ctx.getAttribute(pre + "ll3[1]"), is("abc"));
+ assertThat(ctx.getAttribute(pre + "ll4[0]"), is("abc"));
+ assertThat(ctx.getAttribute(pre + "ll4[1]"), is("abc"));
+ assertThat(ctx.getAttribute(pre + "cont4.leaf10"), is( "abc"));
+ assertThat(ctx.getAttribute(pre + "list6[0].leaf11"), is("abc"));
+ assertThat(ctx.getAttribute(pre + "list6[1].leaf11"), is("abc"));
+ assertThat(ctx.getAttribute(pre + "leaf12"), is("abc"));
+ assertThat(ctx.getAttribute(pre + "ll5[0]"), is("abc"));
+ assertThat(ctx.getAttribute(pre + "ll5[1]"), is("abc"));
+ assertThat(ctx.getAttribute(pre + "cont4.test-augment_cont5.leaf13"),
+ is("true"));
+ assertThat(ctx.getAttribute(pre + "cont4.test-augment_list7[0].leaf14"),
+ is("test"));
+ assertThat(ctx.getAttribute(pre + "cont4.test-augment_list7[1].leaf14"),
+ is("create"));
+ assertThat(ctx.getAttribute(pre + "cont4.test-augment_leaf15"),
+ is("abc"));
+ assertThat(ctx.getAttribute(pre + "cont4.test-augment_ll6[0]"),
+ is("unbounded"));
+ assertThat(ctx.getAttribute(pre + "cont4.test-augment_ll6[1]"),
+ is("8"));
+ assertThat(ctx.getAttribute(pre + "cont4.test-augment_cont13" +
+ ".cont12.leaf26"), is("abc"));
+ assertThat(ctx.getAttribute(pre + "cont4.test-augment_cont13.list9[0]" +
+ ".leaf27"), is("abc"));
+ assertThat(ctx.getAttribute(pre + "cont4.test-augment_cont13.list9[1]" +
+ ".leaf27"), is("abc"));
+ assertThat(ctx.getAttribute(pre + "cont4.test-augment_cont13.leaf28"),
+ is("abc"));
+ assertThat(ctx.getAttribute(pre + "cont4.test-augment_cont13.ll9[0]"),
+ is("abc"));
+ assertThat(ctx.getAttribute(pre + "cont4.test-augment_cont13.ll9[1]"),
+ is("abc"));
+ }
+
+ /**
+ * Verifies the attribute list for decoding from JSON or XML with
+ * RPC YANG file.
+ *
+ * @param ctx service logic context
+ * @param pre prefix
+ */
+ private void verifyAttListRpc(SvcLogicContext ctx, String pre) {
+ assertThat(ctx.getAttribute(pre + "cont16.leaf32"), is("abc"));
+ assertThat(ctx.getAttribute(pre + "list11[0].leaf33"), is("abc"));
+ assertThat(ctx.getAttribute(pre + "list11[1].leaf33"), is("abc"));
+ assertThat(ctx.getAttribute(pre + "leaf34"), is("abc"));
+ assertThat(ctx.getAttribute(pre + "ll11[0]"), is("abc"));
+ assertThat(ctx.getAttribute(pre + "ll11[1]"), is("abc"));
+ assertThat(ctx.getAttribute(pre + "cont17.leaf35"), is("abc"));
+ assertThat(ctx.getAttribute(pre + "cont13.cont12.leaf26"), is("abc"));
+ assertThat(ctx.getAttribute(pre + "cont13.list9[0].leaf27"), is("abc"));
+ assertThat(ctx.getAttribute(pre + "cont13.list9[1].leaf27"), is("abc"));
+ assertThat(ctx.getAttribute(pre + "cont13.ll9[0]"), is("abc"));
+ assertThat(ctx.getAttribute(pre + "cont13.ll9[1]"), is("abc"));
+ assertThat(ctx.getAttribute(pre + "cont13.leaf28"), is("abc"));
+ }
+
+ /**
+ * Verifies the attribute list for decoding from JSON or XML with
+ * ANYXML YANG file.
+ *
+ * @param ctx service logic context
+ */
+ private void verifyOutputOfAnyXml(SvcLogicContext ctx) {
+ System.out.println(ctx.getAttribute("pp.status.eventType"));
+ assertThat(ctx.getAttribute("pp.status.eventType"), is(
+ "EVENT_COMPONENT_EXECUTED"));
+ assertThat(ctx.getAttribute("pp.actionIdentifiers.blueprintName"),
+ is("golden"));
+ assertThat(ctx.getAttribute("pp.actionIdentifiers.mode"),
+ is("sync"));
+ assertThat(ctx.getAttribute("pp.stepData.name"),
+ is("resource-assignment"));
+ assertThat(ctx.getAttribute("pp.status.message"),
+ is("success"));
+ assertThat(ctx.getAttribute("pp.commonHeader.originatorId"),
+ is("System"));
+ assertThat(ctx.getAttribute("pp.status.code"),
+ is("200"));
+ assertThat(ctx.getAttribute("pp.commonHeader.requestId"),
+ is("1234"));
+ assertThat(ctx.getAttribute("pp.commonHeader.subRequestId"),
+ is("1234-12234"));
+ assertThat(ctx.getAttribute("pp.commonHeader.timestamp"),
+ is("2019-05-18T23:42:41.658Z"));
+ assertThat(ctx.getAttribute("pp.status.timestamp"),
+ is("2019-05-18T23:42:41.950Z"));
+ assertThat(ctx.getAttribute("pp.actionIdentifiers.blueprintV" +
+ "ersion"), is("1.0.0"));
+ assertThat(ctx.getAttribute("pp.actionIdentifiers.actionName"),
+ is("resource-assignment"));
+ assertThat(ctx.getAttribute("pp.payload.resource-assignment-resp" +
+ "onse.meshed-template.vf-module-1"),
+ is("<interface>\n <description>This i" +
+ "s the Virtual Firewall entity</description>\n" +
+ " <vfw>10.0.101.20/24</vfw>\n" +
+ "</interface>"));
+ assertThat(ctx.getAttribute("pp.actionIdentifiers.actionName"),
+ is("resource-assignment"));
+ }
+
+
+ /**
+ * Captures the data format messages by mocking it, which can be used in
+ * testing the value.
+ *
+ * @param <String> capturing data format
+ */
+ public class DfCaptor<String> implements Answer {
+
+ private String result;
+
+ /**
+ * Returns the captured data format message.
+ *
+ * @return data format message.
+ */
+ public String getResult() {
+ return result;
+ }
+
+ @Override
+ public String answer(InvocationOnMock invocationOnMock)
+ throws Throwable {
+ result = (String) invocationOnMock.callRealMethod();
+ return result;
+ }
+ }
+
+}
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
new file mode 100644
index 000000000..c1bb71985
--- /dev/null
+++ b/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormatUtilsTest.java
@@ -0,0 +1,631 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - CCSDK
+ * ================================================================================
+ * Copyright (C) 2018 Huawei Technologies Co., Ltd. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.ccsdk.sli.plugins.yangserializers.dfserializer;
+
+/**
+ * Unit test case utilities for data format serializer and restconf api call
+ * node.
+ */
+public final class DataFormatUtilsTest {
+
+ static final String ENCODE_TO_JSON_ID_COMMON = "\n \"interfaces\"" +
+ ": " +
+ "{\n" +
+ " \"int-list\": [\n" +
+ " {\n" +
+ " \"iden\": \"optical\",\n" +
+ " \"available\": {\n" +
+ " \"ll\": [\n" +
+ " \"Giga\",\n" +
+ " \"identity-types:Loopback\",\n" +
+ " \"identity-types-second:Ethernet" +
+ "\"\n" +
+ " ],\n" +
+ " \"leaf1\": \"58\",\n" +
+ " \"leaf2\": \"identity-types-second:iden" +
+ "2\"\n" +
+ " }\n" +
+ " },\n" +
+ " {\n" +
+ " \"iden\": \"214748364\",\n" +
+ " \"available\": {\n" +
+ " \"ll\": [\n" +
+ " \"Giga\",\n" +
+ " \"identity-types:Loopback\",\n" +
+ " \"identity-types-second:Ethernet" +
+ "\"\n" +
+ " ],\n" +
+ " \"leaf1\": \"8888\",\n" +
+ " \"leaf2\": \"identity-types-second:ide" +
+ "n2\"\n" +
+ " }\n" +
+ " }\n" +
+ " ]\n" +
+ " },\n" +
+ " \"interface\": \"identity-types:physical\"\n" +
+ " }";
+
+ static final String ENCODE_TO_JSON_ID = "{\n" +
+ " \"identity-test:con1\": {" + ENCODE_TO_JSON_ID_COMMON +
+ ",\n" +
+ " \"identity-test:l\": \"abc\"\n" +
+ "}";
+
+ static final String ENCODE_TO_ANYXML = "{\n" +
+ " \"actionIdentifiers\": {\n" +
+ " \"mode\": \"sync\",\n" +
+ " \"blueprintName\": \"baseconfiguration\",\n" +
+ " \"blueprintVersion\": \"1.0.0\",\n" +
+ " \"actionName\": \"assign-activate\"\n" +
+ " },\n" +
+ " \"payload\": {\n" +
+ " \"template-prefix\": \"vDNS-test\",\n" +
+ " \"resource-assignment-request\": {\n" +
+ " \"resource-assignment-properties\": {\n" +
+ " \"service-instance-id\": \"1234\",\n" +
+ " \"vnf-id\": \"3526\",\n" +
+ " \"customer-name\": \"htipl\",\n" +
+ " \"subscriber-name\": \"huawei\"\n" +
+ " }\n" +
+ " }\n" +
+ " },\n" +
+ " \"commonHeader\": {\n" +
+ " \"subRequestId\": \"sub-123456-1000\",\n" +
+ " \"requestId\": \"123456-1000\",\n" +
+ " \"originatorId\": \"SDNC_DG\"\n" +
+ " }\n" +
+ "}";
+
+ static final String ENCODE_TO_JSON_ID_PUT = "{\n" +
+ " \"identity-test:test\": {\n" +
+ " \"con1\": {" + addSpace(ENCODE_TO_JSON_ID_COMMON, 4) +
+ ",\n" +
+ " \"l\": \"abc\"\n" +
+ " }\n" +
+ "}";
+
+ static final String ENCODE_TO_XML_ID_COMMON = "\n <interfaces>\n" +
+ " <int-list>\n" +
+ " <iden>optical</iden>\n" +
+ " <available>\n" +
+ " <ll>Giga</ll>\n" +
+ " <ll xmlns:yangid=\"identity:list:ns:test:json:se" +
+ "r\">yangid:Loopback</ll>\n" +
+ " <ll xmlns:yangid=\"identity:list:second:ns:test" +
+ ":json:ser\">yangid:Ethernet</ll>\n" +
+ " <leaf1>58</leaf1>\n" +
+ " <leaf2 xmlns:yangid=\"identity:list:second:ns:t" +
+ "est:json:ser\">yangid:iden2</leaf2>\n" +
+ " </available>\n" +
+ " </int-list>\n" +
+ " <int-list>\n" +
+ " <iden>214748364</iden>\n" +
+ " <available>\n" +
+ " <ll>Giga</ll>\n" +
+ " <ll xmlns:yangid=\"identity:list:ns:test:json:s" +
+ "er\">yangid:Loopback</ll>\n" +
+ " <ll xmlns:yangid=\"identity:list:second:ns:test" +
+ ":json:ser\">yangid:Ethernet</ll>\n" +
+ " <leaf1>8888</leaf1>\n" +
+ " <leaf2 xmlns:yangid=\"identity:list:second:ns:t" +
+ "est:json:ser\">yangid:iden2</leaf2>\n" +
+ " </available>\n" +
+ " </int-list>\n" +
+ " </interfaces>\n" +
+ " <interface xmlns:yangid=\"identity:list:ns:test:json:ser\">" +
+ "yangid:physical</interface>";
+
+ static final String ENCODE_TO_XML_ID = "<?xml version=\"1.0\" encoding=" +
+ "\"UTF-8\" standalone=\"no\"?>\n" +
+ "<con1 xmlns=\"identity:ns:test:json:ser\">" +
+ ENCODE_TO_XML_ID_COMMON + "\n</con1>\n";
+
+ static final String ENCODE_TO_XML_ID_PUT = "<?xml version=\"1.0\" enco" +
+ "ding=\"UTF-8\" standalone=\"no\"?>\n" +
+ "<test xmlns=\"identity:ns:test:json:ser\">\n" +
+ " <con1>" + addSpace(ENCODE_TO_XML_ID_COMMON, 4)
+ + "\n </con1>\n" +
+ "</test>\n";
+
+ static final String ENCODE_TO_JSON_YANG_COMMON = "\n " +
+ "\"test-augment:ll6\": [\n" +
+ " \"unbounded\",\n" +
+ " \"8\"\n" +
+ " ],\n" +
+ " \"test-augment:cont13\": {\n" +
+ " \"ll9\": [\n" +
+ " \"abc\",\n" +
+ " \"abc\"\n" +
+ " ],\n" +
+ " \"list9\": [\n" +
+ " {\n" +
+ " \"leaf27\": \"abc\"\n" +
+ " },\n" +
+ " {\n" +
+ " \"leaf27\": \"abc\"\n" +
+ " }\n" +
+ " ],\n" +
+ " \"leaf28\": \"abc\",\n" +
+ " \"cont12\": {\n" +
+ " \"leaf26\": \"abc\"\n" +
+ " }\n" +
+ " },\n" +
+ " \"test-augment:list7\": [\n" +
+ " {\n" +
+ " \"leaf14\": \"test\"\n" +
+ " },\n" +
+ " {\n" +
+ " \"leaf14\": \"create\"\n" +
+ " }\n" +
+ " ],\n" +
+ " \"test-augment:leaf15\": \"abc\",\n" +
+ " \"test-augment:cont5\": {\n" +
+ " \"leaf13\": \"true\"\n" +
+ " }";
+
+ static final String ENCODE_TO_JSON_YANG_AUG_POST = "{\n" +
+ " \"test-yang:leaf10\": \"abc\"," +
+ ENCODE_TO_JSON_YANG_COMMON + "\n}";
+
+ static final String ENCODE_TO_JSON_YANG = "{\n" +
+ " \"test-yang:cont2\": {\n" +
+ " \"list1\": [\n" +
+ " {\n" +
+ " \"ll1\": [\n" +
+ " \"abc\",\n" +
+ " \"abc\"\n" +
+ " ],\n" +
+ " \"leaf1\": \"true\",\n" +
+ " \"ll2\": [\n" +
+ " \"abc\",\n" +
+ " \"abc\"\n" +
+ " ],\n" +
+ " \"list5\": [\n" +
+ " {\n" +
+ " \"leaf9\": \"abc\"\n" +
+ " },\n" +
+ " {\n" +
+ " \"leaf9\": \"abc\"\n" +
+ " }\n" +
+ " ],\n" +
+ " \"leaf3\": \"abc\",\n" +
+ " \"leaf2\": \"abc\",\n" +
+ " \"list4\": [\n" +
+ " {\n" +
+ " \"leaf8\": \"abc\"\n" +
+ " },\n" +
+ " {\n" +
+ " \"leaf8\": \"abc\"\n" +
+ " }\n" +
+ " ],\n" +
+ " \"cont4\": {\n" +
+ " \"leaf11\": \"abc\"\n" +
+ " }\n" +
+ " },\n" +
+ " {\n" +
+ " \"ll1\": [\n" +
+ " \"abc\",\n" +
+ " \"abc\"\n" +
+ " ],\n" +
+ " \"leaf1\": \"true\",\n" +
+ " \"ll2\": [\n" +
+ " \"abc\",\n" +
+ " \"abc\"\n" +
+ " ],\n" +
+ " \"leaf3\": \"abc\",\n" +
+ " \"list5\": [\n" +
+ " {\n" +
+ " \"leaf9\": \"abc\"\n" +
+ " },\n" +
+ " {\n" +
+ " \"leaf9\": \"abc\"\n" +
+ " }\n" +
+ " ],\n" +
+ " \"list4\": [\n" +
+ " {\n" +
+ " \"leaf8\": \"abc\"\n" +
+ " },\n" +
+ " {\n" +
+ " \"leaf8\": \"abc\"\n" +
+ " }\n" +
+ " ],\n" +
+ " \"leaf2\": \"abc\",\n" +
+ " \"cont4\": {\n" +
+ " \"leaf11\": \"abc\"\n" +
+ " }\n" +
+ " }\n" +
+ " ],\n" +
+ " \"ll3\": [\n" +
+ " \"abc\",\n" +
+ " \"abc\"\n" +
+ " ],\n" +
+ " \"ll5\": [\n" +
+ " \"abc\",\n" +
+ " \"abc\"\n" +
+ " ],\n" +
+ " \"cont4\": {\n" +
+ " \"leaf10\": \"abc\"," +
+ addSpace(ENCODE_TO_JSON_YANG_COMMON, 8) + "\n" +
+ " },\n" +
+ " \"ll4\": [\n" +
+ " \"abc\",\n" +
+ " \"abc\"\n" +
+ " ],\n" +
+ " \"cont3\": {\n" +
+ " \"leaf10\": \"abc\"\n" +
+ " },\n" +
+ " \"leaf5\": \"abc\",\n" +
+ " \"list2\": [\n" +
+ " {\n" +
+ " \"leaf4\": \"abc\"\n" +
+ " },\n" +
+ " {\n" +
+ " \"leaf4\": \"abc\"\n" +
+ " }\n" +
+ " ],\n" +
+ " \"leaf12\": \"abc\",\n" +
+ " \"leaf6\": \"abc\",\n" +
+ " \"list6\": [\n" +
+ " {\n" +
+ " \"leaf11\": \"abc\"\n" +
+ " },\n" +
+ " {\n" +
+ " \"leaf11\": \"abc\"\n" +
+ " }\n" +
+ " ]\n" +
+ " }\n" +
+ "}";
+
+ static final String ENCODE_TO_JSON_YANG_PUT = "{\n" +
+ " \"test-yang:cont4\": {" + addSpace(
+ ENCODE_TO_JSON_YANG_COMMON, 4) + ",\n" +
+ " \"leaf10\": \"abc\"\n" +
+ " }\n" +
+ "}";
+
+ static final String ENCODE_TO_XML_YANG_COMMON = "\n" +
+ "<ll6 xmlns=\"urn:opendaylight:params:xml:ns:yang:aug" +
+ "ment\">unbounded</ll6>\n" +
+ "<ll6 xmlns=\"urn:opendaylight:params:xml:ns:yang:aug" +
+ "ment\">8</ll6>\n" +
+ "<cont13 xmlns=\"urn:opendaylight:params:xml:ns:yang:" +
+ "augment\">\n" +
+ " <ll9>abc</ll9>\n" +
+ " <ll9>abc</ll9>\n" +
+ " <list9>\n" +
+ " <leaf27>abc</leaf27>\n" +
+ " </list9>\n" +
+ " <list9>\n" +
+ " <leaf27>abc</leaf27>\n" +
+ " </list9>\n" +
+ " <leaf28>abc</leaf28>\n" +
+ " <cont12>\n" +
+ " <leaf26>abc</leaf26>\n" +
+ " </cont12>\n" +
+ "</cont13>\n" +
+ "<list7 xmlns=\"urn:opendaylight:params:xml:ns:yang:a" +
+ "ugment\">\n" +
+ " <leaf14>test</leaf14>\n" +
+ "</list7>\n" +
+ "<list7 xmlns=\"urn:opendaylight:params:xml:ns:yang:a" +
+ "ugment\">\n" +
+ " <leaf14>create</leaf14>\n" +
+ "</list7>\n" +
+ "<leaf15 xmlns=\"urn:opendaylight:params:xml:ns:yang:" +
+ "augment\">abc</leaf15>\n" +
+ "<cont5 xmlns=\"urn:opendaylight:params:xml:ns:yang:a" +
+ "ugment\">\n" +
+ " <leaf13>true</leaf13>\n" +
+ "</cont5>";
+
+ static final String ENCODE_TO_XML_YANG_AUG_POST = "<?xml version=\"1.0\"" +
+ " encoding=\"UTF-8\" standalone=\"no\"?>\n" +
+ "<leaf10 xmlns=\"urn:opendaylight:params:xml:ns:yang:test\">abc" +
+ "</leaf10>" +
+ ENCODE_TO_XML_YANG_COMMON + "\n";
+
+ static final String ENCODE_TO_XML_YANG_PUT = "<?xml version=\"1.0\" enc" +
+ "oding=\"UTF-8\" standalone=\"no\"?>\n" +
+ "<cont4 xmlns=\"urn:opendaylight:params:xml:ns:yang:test\">\n" +
+ " <leaf10>abc</leaf10>" +
+ addSpace(ENCODE_TO_XML_YANG_COMMON, 4) + "\n</cont4>\n";
+
+ static final String ENCODE_TO_XML_YANG = "<?xml version=\"1.0\" encoding" +
+ "=\"UTF-8\" standalone=\"no\"?>\n" +
+ "<cont2 xmlns=\"urn:opendaylight:params:xml:ns:yang:test\">\n" +
+ " <list1>\n" +
+ " <ll1>abc</ll1>\n" +
+ " <ll1>abc</ll1>\n" +
+ " <leaf1>true</leaf1>\n" +
+ " <ll2>abc</ll2>\n" +
+ " <ll2>abc</ll2>\n" +
+ " <list5>\n" +
+ " <leaf9>abc</leaf9>\n" +
+ " </list5>\n" +
+ " <list5>\n" +
+ " <leaf9>abc</leaf9>\n" +
+ " </list5>\n" +
+ " <leaf3>abc</leaf3>\n" +
+ " <leaf2>abc</leaf2>\n" +
+ " <list4>\n" +
+ " <leaf8>abc</leaf8>\n" +
+ " </list4>\n" +
+ " <list4>\n" +
+ " <leaf8>abc</leaf8>\n" +
+ " </list4>\n" +
+ " <cont4>\n" +
+ " <leaf11>abc</leaf11>\n" +
+ " </cont4>\n" +
+ " </list1>\n" +
+ " <list1>\n" +
+ " <ll1>abc</ll1>\n" +
+ " <ll1>abc</ll1>\n" +
+ " <leaf1>true</leaf1>\n" +
+ " <ll2>abc</ll2>\n" +
+ " <ll2>abc</ll2>\n" +
+ " <leaf3>abc</leaf3>\n" +
+ " <list5>\n" +
+ " <leaf9>abc</leaf9>\n" +
+ " </list5>\n" +
+ " <list5>\n" +
+ " <leaf9>abc</leaf9>\n" +
+ " </list5>\n" +
+ " <list4>\n" +
+ " <leaf8>abc</leaf8>\n" +
+ " </list4>\n" +
+ " <list4>\n" +
+ " <leaf8>abc</leaf8>\n" +
+ " </list4>\n" +
+ " <leaf2>abc</leaf2>\n" +
+ " <cont4>\n" +
+ " <leaf11>abc</leaf11>\n" +
+ " </cont4>\n" +
+ " </list1>\n" +
+ " <ll3>abc</ll3>\n" +
+ " <ll3>abc</ll3>\n" +
+ " <ll5>abc</ll5>\n" +
+ " <ll5>abc</ll5>\n" +
+ " <cont4>\n" +
+ " <leaf10>abc</leaf10>"+
+ addSpace(ENCODE_TO_XML_YANG_COMMON, 8) + "\n" +
+ " </cont4>\n" +
+ " <ll4>abc</ll4>\n" +
+ " <ll4>abc</ll4>\n" +
+ " <cont3>\n" +
+ " <leaf10>abc</leaf10>\n" +
+ " </cont3>\n" +
+ " <leaf5>abc</leaf5>\n" +
+ " <list2>\n" +
+ " <leaf4>abc</leaf4>\n" +
+ " </list2>\n" +
+ " <list2>\n" +
+ " <leaf4>abc</leaf4>\n" +
+ " </list2>\n" +
+ " <leaf12>abc</leaf12>\n" +
+ " <leaf6>abc</leaf6>\n" +
+ " <list6>\n" +
+ " <leaf11>abc</leaf11>\n" +
+ " </list6>\n" +
+ " <list6>\n" +
+ " <leaf11>abc</leaf11>\n" +
+ " </list6>\n" +
+ "</cont2>\n";
+
+ static final String ENCODE_TO_JSON_RPC = "{\n" +
+ " \"test-yang:input\": {\n" +
+ " \"leaf30\": \"abc\",\n" +
+ " \"list10\": [\n" +
+ " {\n" +
+ " \"leaf29\": \"abc\"\n" +
+ " },\n" +
+ " {\n" +
+ " \"leaf29\": \"abc\"\n" +
+ " }\n" +
+ " ],\n" +
+ " \"cont15\": {\n" +
+ " \"leaf31\": \"abc\"\n" +
+ " },\n" +
+ " \"cont14\": {\n" +
+ " \"leaf28\": \"abc\"\n" +
+ " },\n" +
+ " \"cont13\": {\n" +
+ " \"list9\": [\n" +
+ " {\n" +
+ " \"leaf27\": \"abc\"\n" +
+ " },\n" +
+ " {\n" +
+ " \"leaf27\": \"abc\"\n" +
+ " }\n" +
+ " ],\n" +
+ " \"ll9\": [\n" +
+ " \"abc\",\n" +
+ " \"abc\"\n" +
+ " ],\n" +
+ " \"leaf28\": \"abc\"\n" +
+ " },\n" +
+ " \"ll10\": [\n" +
+ " \"abc\",\n" +
+ " \"abc\"\n" +
+ " ]\n" +
+ " }\n" +
+ "}";
+
+ static final String DECODE_FROM_JSON_RPC = "{\n" +
+ " \"test-yang:output\": {\n" +
+ " \"cont16\": {\n" +
+ " \"leaf32\": \"abc\"\n" +
+ " },\n" +
+ " \"list11\": [\n" +
+ " {\n" +
+ " \"leaf33\": \"abc\"\n" +
+ " },\n" +
+ " {\n" +
+ " \"leaf33\": \"abc\"\n" +
+ " }\n" +
+ " ],\n" +
+ " \"leaf34\": \"abc\",\n" +
+ " \"ll11\": [\n" +
+ " \"abc\",\n" +
+ " \"abc\"\n" +
+ " ],\n" +
+ " \"cont17\": {\n" +
+ " \"leaf35\": \"abc\"\n" +
+ " },\n" +
+ " \"cont13\": {\n" +
+ " \"cont12\": {\n" +
+ " \"leaf26\": \"abc\"\n" +
+ " },\n" +
+ " \"list9\": [\n" +
+ " {\n" +
+ " \"leaf27\": \"abc\"\n" +
+ " },\n" +
+ " {\n" +
+ " \"leaf27\": \"abc\"\n" +
+ " }\n" +
+ " ],\n" +
+ " \"ll9\": [\n" +
+ " \"abc\",\n" +
+ " \"abc\"\n" +
+ " ],\n" +
+ " \"leaf28\": \"abc\"\n" +
+ " }\n" +
+ " }\n" +
+ "}";
+
+ static final String DECODE_ANYXML_RESPONSE = "{\n" +
+ " \"commonHeader\": {\n" +
+ " \"timestamp\": \"2019-05-18T23:42:41.658Z\",\n" +
+ " \"originatorId\": \"System\",\n" +
+ " \"requestId\": \"1234\",\n" +
+ " \"subRequestId\": \"1234-12234\",\n" +
+ " \"flags\": null\n" +
+ " },\n" +
+ " \"actionIdentifiers\": {\n" +
+ " \"blueprintName\": \"golden\",\n" +
+ " \"blueprintVersion\": \"1.0.0\",\n" +
+ " \"actionName\": \"resource-assignment\",\n" +
+ " \"mode\": \"sync\"\n" +
+ " },\n" +
+ " \"status\": {\n" +
+ " \"code\": 200,\n" +
+ " \"eventType\": \"EVENT_COMPONENT_EXECUTED\",\n" +
+ " \"timestamp\": \"2019-05-18T23:42:41.950Z\",\n" +
+ " \"errorMessage\": null,\n" +
+ " \"message\": \"success\"\n" +
+ " },\n" +
+ " \"payload\": {\n" +
+ " \"resource-assignment-response\": {\n" +
+ " \"meshed-template\": {\n" +
+ " \"vf-module-1\": \"<interface>\\n " +
+ " <description>This is the Virtual Firewall entity</" +
+ "description>\\n <vfw>10.0.101.20/24</vfw>\\n</interface>\"\n" +
+ " }\n" +
+ " }\n" +
+ " },\n" +
+ " \"stepData\": {\n" +
+ " \"name\": \"resource-assignment\",\n" +
+ " \"properties\": {\n" +
+ " \"resource-assignment-params\": null,\n" +
+ " \"status\": null\n" +
+ " }\n" +
+ " }\n" +
+ "}";
+
+ static final String ENCODE_TO_XML_RPC = "<?xml version=\"1.0\" encoding" +
+ "=\"UTF-8\" standalone=\"no\"?>\n" +
+ "<input xmlns=\"urn:opendaylight:params:xml:ns:yang:test\">\n" +
+ " <leaf30>abc</leaf30>\n" +
+ " <list10>\n" +
+ " <leaf29>abc</leaf29>\n" +
+ " </list10>\n" +
+ " <list10>\n" +
+ " <leaf29>abc</leaf29>\n" +
+ " </list10>\n" +
+ " <cont15>\n" +
+ " <leaf31>abc</leaf31>\n" +
+ " </cont15>\n" +
+ " <cont14>\n" +
+ " <leaf28>abc</leaf28>\n" +
+ " </cont14>\n" +
+ " <cont13>\n" +
+ " <list9>\n" +
+ " <leaf27>abc</leaf27>\n" +
+ " </list9>\n" +
+ " <list9>\n" +
+ " <leaf27>abc</leaf27>\n" +
+ " </list9>\n" +
+ " <ll9>abc</ll9>\n" +
+ " <ll9>abc</ll9>\n" +
+ " <leaf28>abc</leaf28>\n" +
+ " </cont13>\n" +
+ " <ll10>abc</ll10>\n" +
+ " <ll10>abc</ll10>\n" +
+ "</input>\n";
+
+ static final String DECODE_FROM_XML_RPC = "<?xml version=\"1.0\" encodi" +
+ "ng=\"UTF-8\" standalone=\"no\"?>\n" +
+ "<output xmlns=\"urn:opendaylight:params:xml:ns:yang:test\">\n" +
+ " <cont16>\n" +
+ " <leaf32>abc</leaf32>\n" +
+ " </cont16>\n" +
+ " <list11>\n" +
+ " <leaf33>abc</leaf33>\n" +
+ " </list11>\n" +
+ " <list11>\n" +
+ " <leaf33>abc</leaf33>\n" +
+ " </list11>\n" +
+ " <leaf34>abc</leaf34>\n" +
+ " <ll11>abc</ll11>\n" +
+ " <ll11>abc</ll11>\n" +
+ " <cont17>\n" +
+ " <leaf35>abc</leaf35>\n" +
+ " </cont17>\n" +
+ " <cont13>\n" +
+ " <cont12>\n" +
+ " <leaf26>abc</leaf26>\n" +
+ " </cont12>\n" +
+ " <list9>\n" +
+ " <leaf27>abc</leaf27>\n" +
+ " </list9>\n" +
+ " <list9>\n" +
+ " <leaf27>abc</leaf27>\n" +
+ " </list9>\n" +
+ " <ll9>abc</ll9>\n" +
+ " <ll9>abc</ll9>\n" +
+ " <leaf28>abc</leaf28>\n" +
+ " </cont13>\n" +
+ "</output>";
+
+ /**
+ * Adds the specified number of space required for a req in each line.
+ *
+ * @param req request message
+ * @param i number of space
+ * @return space appended string
+ */
+ public static String addSpace(String req, int i) {
+ StringBuilder space = new StringBuilder();
+ for (int sp = 0; sp < i; sp++) {
+ space = space.append(" ");
+ }
+ return req.replaceAll("\n", "\n" + space.toString());
+ }
+}
diff --git a/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/IdentifierValidationTest.java b/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/IdentifierValidationTest.java
new file mode 100644
index 000000000..1109d426c
--- /dev/null
+++ b/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/IdentifierValidationTest.java
@@ -0,0 +1,762 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - CCSDK
+ * ================================================================================
+ * Copyright (C) 2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.ccsdk.sli.plugins.yangserializers.dfserializer;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.invocation.InvocationOnMock;
+import org.mockito.stubbing.Answer;
+import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
+import org.onap.ccsdk.sli.core.sli.SvcLogicException;
+import org.onap.ccsdk.sli.plugins.restapicall.HttpResponse;
+import org.onap.ccsdk.sli.plugins.restapicall.RestapiCallNode;
+import org.onap.ccsdk.sli.plugins.restconfapicall.RestconfApiCallNode;
+import org.opendaylight.restconf.common.context.InstanceIdentifierContext;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.doAnswer;
+import static org.mockito.Mockito.doCallRealMethod;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.IdentifierValidationUtilsTest.DECODE_FROM_JSON_RPC_ID;
+import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.IdentifierValidationUtilsTest.DECODE_FROM_XML_RPC_ID;
+import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.IdentifierValidationUtilsTest.ENCODE_TO_JSON_RPC_ID;
+import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.IdentifierValidationUtilsTest.ENCODE_TO_JSON_WITH_AUG_PATH;
+import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.IdentifierValidationUtilsTest.ENCODE_TO_JSON_YANG_AUG_POST_ID;
+import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.IdentifierValidationUtilsTest.ENCODE_TO_JSON_YANG_ID;
+import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.IdentifierValidationUtilsTest.ENCODE_TO_JSON_YANG_PUT_ID;
+import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.IdentifierValidationUtilsTest.ENCODE_TO_XML_RPC_ID;
+import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.IdentifierValidationUtilsTest.ENCODE_TO_XML_YANG_AUG_POST_ID;
+import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.IdentifierValidationUtilsTest.ENCODE_TO_XML_YANG_ID;
+import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.IdentifierValidationUtilsTest.ENCODE_TO_XML_YANG_PUT_ID;
+
+/**
+ * Unit test cases for identifier validation test.
+ */
+public class IdentifierValidationTest {
+
+ private Map<String, String> p;
+
+ private RestconfApiCallNode restconf;
+
+ private RestapiCallNode restApi;
+
+ private DfCaptor dfCaptor;
+
+ /**
+ * Sets up the pre-requisite for each test case.
+ *
+ * @throws SvcLogicException when test case fails
+ */
+ @Before
+ public void setUp() throws SvcLogicException {
+ p = new HashMap<>();
+ p.put("restapiUser", "user1");
+ p.put("restapiPassword", "abc123");
+ p.put("responsePrefix", "response");
+ p.put("skipSending", "true");
+ restApi = new RestapiCallNode();
+ restconf = mock(RestconfApiCallNode.class);
+ dfCaptor = new DfCaptor();
+ createMethodMocks();
+ }
+
+ /**
+ * Creates method mocks using mockito for RestconfApiCallNode class.
+ *
+ * @throws SvcLogicException when test case fails
+ */
+ private void createMethodMocks() throws SvcLogicException {
+ doReturn(restApi).when(restconf).getRestapiCallNode();
+ doCallRealMethod().when(restconf).sendRequest(
+ any(Map.class), any(SvcLogicContext.class));
+ doCallRealMethod().when(restconf).sendRequest(
+ any(Map.class), any(SvcLogicContext.class), any(Integer.class));
+ doAnswer(dfCaptor).when(restconf).serializeRequest(
+ any(Map.class), any(YangParameters.class), any(String.class),
+ any(InstanceIdentifierContext.class));
+ doAnswer(dfCaptor).when(restconf).updateReq(
+ any(String.class), any(YangParameters.class),
+ any(InstanceIdentifierContext.class));
+ }
+
+ /**
+ * Creates mock using mockito with input data for decoding.
+ *
+ * @param decodeData input data
+ * @throws SvcLogicException when test case fails
+ */
+ private void createMockForDecode(String decodeData)
+ throws SvcLogicException {
+ doReturn(decodeData).when(restconf).getResponse(
+ any(SvcLogicContext.class), any(YangParameters.class),
+ any(String.class), any(HttpResponse.class));
+ doCallRealMethod().when(restconf).serializeResponse(
+ any(YangParameters.class), any(String.class), any(String.class),
+ any(InstanceIdentifierContext.class));
+ }
+
+ /**
+ * Verifies encoding of parameters to JSON data format with containers,
+ * grouping and augment.
+ *
+ * @throws SvcLogicException when test case fails
+ */
+ @Test
+ public void encodeToJsonYang() throws SvcLogicException {
+ String pre = "test_name_of_the_module_name_of_the_cont1.name_" +
+ "of_the_cont2.";
+ SvcLogicContext ctx = createAttListYang(pre);
+ p.put("dirPath", "src/test/resources");
+ p.put("format", "json");
+ p.put("httpMethod", "post");
+ p.put("restapiUrl", "http://echo.getpostman.com/restconf/operati" +
+ "ons/test_name_of_the_module:name_of_the_cont1");
+ restconf.sendRequest(p, ctx);
+ assertThat(dfCaptor.getResult(), is(ENCODE_TO_JSON_YANG_ID));
+ }
+
+ /**
+ * Verifies encoding of parameters with augment in the URL.
+ *
+ * @throws SvcLogicException when test case fails
+ */
+ @Test
+ public void encodeToJsonYangWithAugUrl() throws SvcLogicException {
+ String pre = "test_name_of_the_module_name_of_the_cont1.name_" +
+ "of_the_cont2.";
+ SvcLogicContext ctx = createAttListYang(pre);
+ p.put("dirPath", "src/test/resources");
+ p.put("format", "json");
+ p.put("httpMethod", "post");
+ p.put("restapiUrl", "http://echo.getpostman.com/restconf/operati" +
+ "ons/test_name_of_the_module:name_of_the_cont1/name_of_t" +
+ "he_cont2/name_of_the_cont4/test_augment_1_for_module:na" +
+ "me_of_the_cont5");
+ restconf.sendRequest(p, ctx);
+ assertThat(dfCaptor.getResult(), is(ENCODE_TO_JSON_WITH_AUG_PATH));
+ }
+
+ /**
+ * Verifies encoding of parameters to JSON data format with containers,
+ * grouping and augment for put operation-type.
+ *
+ * @throws SvcLogicException when test case fails
+ */
+ @Test
+ public void encodeToJsonYangWithPut() throws SvcLogicException {
+ String pre = "test_name_of_the_module_name_of_the_cont1.name_of_the_cont2.";
+ SvcLogicContext ctx = createAttListYang(pre);
+ p.put("dirPath", "src/test/resources");
+ p.put("format", "json");
+ p.put("httpMethod", "put");
+ p.put("restapiUrl", "http://echo.getpostman" +
+ ".com/restconf/operations/test_name_of_the_module:name_of" +
+ "_the_cont1/name_of_the_cont2/name_of_the_cont4");
+ restconf.sendRequest(p, ctx);
+ assertThat(dfCaptor.getResult(), is(ENCODE_TO_JSON_YANG_PUT_ID));
+ }
+
+ /**
+ * Verifies encoding of parameters to JSON data format with containers,
+ * grouping and augment for patch operation-type.
+ *
+ * @throws SvcLogicException when test case fails
+ */
+ @Test
+ public void encodeToJsonYangWithPatch() throws SvcLogicException {
+ String pre = "test_name_of_the_module_name_of_the_cont1.name_o" +
+ "f_the_cont2.";
+ SvcLogicContext ctx = createAttListYang(pre);
+ p.put("dirPath", "src/test/resources");
+ p.put("format", "json");
+ p.put("httpMethod", "patch");
+ p.put("restapiUrl", "http://echo.getpostman" +
+ ".com/restconf/operations/test_name_of_the_module:name_of_" +
+ "the_cont1/name_of_the_cont2/name_of_the_cont4");
+ restconf.sendRequest(p, ctx);
+ assertThat(dfCaptor.getResult(), is(ENCODE_TO_JSON_YANG_PUT_ID));
+ }
+
+ /**
+ * Verifies encoding of parameters to JSON data format with augment as
+ * root child.
+ *
+ * @throws SvcLogicException when test case fails
+ */
+ @Test
+ public void encodeToJsonWithAugAsRootChild() throws SvcLogicException {
+ String pre = "test_name_of_the_module_name_of_the_cont1.name_of_" +
+ "the_cont2.";
+ SvcLogicContext ctx = createAttListYang(pre);
+ p.put("dirPath", "src/test/resources");
+ p.put("format", "json");
+ p.put("httpMethod", "post");
+ p.put("restapiUrl", "http://echo.getpostman" +
+ ".com/restconf/operations/test_name_of_the_module:name_of_" +
+ "the_cont1/name_of_the_cont2/name_of_the_cont4");
+ restconf.sendRequest(p, ctx);
+ assertThat(dfCaptor.getResult(), is(ENCODE_TO_JSON_YANG_AUG_POST_ID));
+ }
+
+ /**
+ * Verifies decoding of parameters from JSON data format with containers,
+ * grouping and augment.
+ *
+ * @throws SvcLogicException when test case fails
+ */
+ @Test
+ public void decodeToJsonYang() throws SvcLogicException {
+ createMockForDecode(ENCODE_TO_JSON_YANG_ID);
+ SvcLogicContext ctx = new SvcLogicContext();
+ String pre = "test_name_of_the_module_name_of_the_cont1.name_" +
+ "of_the_cont2.";
+ p.put("dirPath", "src/test/resources");
+ p.put("format", "json");
+ p.put("httpMethod", "get");
+ p.put("restapiUrl", "http://echo.getpostman" +
+ ".com/restconf/operations/test_name_of_the_module:name" +
+ "_of_the_cont1");
+ restconf.sendRequest(p, ctx);
+ verifyAttListYang(ctx, pre);
+ }
+
+ /**
+ * Verifies encoding of parameters to XML data format with containers,
+ * grouping and augment.
+ *
+ * @throws SvcLogicException when test case fails
+ */
+ @Test
+ public void encodeToXmlYang() throws SvcLogicException {
+ String pre = "test_name_of_the_module_name_of_the_cont1.name_of" +
+ "_the_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_name_of_the_module:name_of_the_cont1");
+ restconf.sendRequest(p, ctx);
+ assertThat(dfCaptor.getResult(), is(ENCODE_TO_XML_YANG_ID));
+ }
+
+ /**
+ * Verifies encoding of parameters to XML data format with containers,
+ * grouping and augment for put operation-type
+ *
+ * @throws SvcLogicException when test case fails
+ */
+ @Test
+ public void encodeToXmlYangWithPut() throws SvcLogicException {
+ String pre = "test_name_of_the_module_name_of_the_cont1.name_" +
+ "of_the_cont2.";
+ SvcLogicContext ctx = createAttListYang(pre);
+ p.put("dirPath", "src/test/resources");
+ p.put("format", "xml");
+ p.put("httpMethod", "put");
+ p.put("restapiUrl", "http://echo.getpostman.com/restconf/operations/" +
+ "test_name_of_the_module:name_of_the_cont1/name_of_the_cont2" +
+ "/name_of_the_cont4");
+ restconf.sendRequest(p, ctx);
+ assertThat(dfCaptor.getResult(), is(ENCODE_TO_XML_YANG_PUT_ID));
+ }
+
+ /**
+ * Verifies encoding of parameters to XML data format with containers,
+ * grouping and augment for patch operation-type
+ *
+ * @throws SvcLogicException when test case fails
+ */
+ @Test
+ public void encodeToXmlYangWithPatch() throws SvcLogicException {
+ String pre = "test_name_of_the_module_name_of_the_cont1.name_of" +
+ "_the_cont2.";
+ SvcLogicContext ctx = createAttListYang(pre);
+ p.put("dirPath", "src/test/resources");
+ p.put("format", "xml");
+ p.put("httpMethod", "put");
+ p.put("restapiUrl", "http://echo.getpostman.com/restconf/operation" +
+ "s/test_name_of_the_module:name_of_the_cont1/name_of_the_c" +
+ "ont2/name_of_the_cont4");
+ restconf.sendRequest(p, ctx);
+ assertThat(dfCaptor.getResult(), is(ENCODE_TO_XML_YANG_PUT_ID));
+ }
+
+ /**
+ * 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_name_of_the_module_name_of_the_cont1.name_of_the" +
+ "_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_name_of_the_module:name_of_the_cont1/name_of_the_cont2" +
+ "/name_of_the_cont4");
+ restconf.sendRequest(p, ctx);
+ assertThat(dfCaptor.getResult(), is(ENCODE_TO_XML_YANG_AUG_POST_ID));
+ }
+
+ /**
+ * Verifies decoding of parameters from XML data format with containers,
+ * grouping and augment.
+ *
+ * @throws SvcLogicException when test case fails
+ */
+ @Test
+ public void decodeToXmlYang() throws SvcLogicException {
+ createMockForDecode(ENCODE_TO_XML_YANG_ID);
+ SvcLogicContext ctx = new SvcLogicContext();
+ String pre = "test_name_of_the_module_name_of_the_cont1.name_of_" +
+ "the_cont2.";
+ p.put("dirPath", "src/test/resources");
+ p.put("format", "xml");
+ p.put("httpMethod", "get");
+ p.put("restapiUrl", "http://echo.getpostman.com/restconf/operation" +
+ "s/test_name_of_the_module:name_of_the_cont1");
+ restconf.sendRequest(p, ctx);
+ verifyAttListYang(ctx, pre);
+ }
+
+ /**
+ * Verifies encoding of and decoding from, JSON respectively for data
+ * format with containers, grouping and augment.
+ *
+ * @throws SvcLogicException when test case fails
+ */
+ @Test
+ public void codecToJsonRpc() throws SvcLogicException {
+ createMockForDecode(DECODE_FROM_JSON_RPC_ID);
+ String inPre = "test_name_of_the_module_name_of_the_create-sfc.input.";
+ String outPre = "test_name_of_the_module_name_of_the_create-sfc" +
+ ".output.";
+ SvcLogicContext ctx = createAttListRpc(inPre);
+ p.put("dirPath", "src/test/resources");
+ p.put("format", "json");
+ p.put("httpMethod", "post");
+ p.put("restapiUrl", "http://echo.getpostman.com/restconf/operations" +
+ "/test_name_of_the_module:name_of_the_create-sfc");
+ restconf.sendRequest(p, ctx);
+ assertThat(dfCaptor.getResult(), is(ENCODE_TO_JSON_RPC_ID));
+ verifyAttListRpc(ctx, outPre);
+ }
+
+ /**
+ * Verifies encoding of and decoding from, XML respectively for data
+ * format with containers, grouping and augment.
+ *
+ * @throws SvcLogicException when test case fails
+ */
+ @Test
+ public void codecToXmlRpc() throws SvcLogicException {
+ createMockForDecode(DECODE_FROM_XML_RPC_ID);
+ String inPre = "test_name_of_the_module_name_of_the_create-sfc.input.";
+ String outPre = "test_name_of_the_module_name_of_the_create-sfc.output.";
+ SvcLogicContext ctx = createAttListRpc(inPre);
+ p.put("dirPath", "src/test/resources");
+ p.put("format", "xml");
+ p.put("httpMethod", "post");
+ p.put("restapiUrl", "http://echo.getpostman" +
+ ".com/restconf/operations/test_name_of_the_module" +
+ ":name_of_the_create-sfc");
+ restconf.sendRequest(p, ctx);
+ assertThat(dfCaptor.getResult(), is(ENCODE_TO_XML_RPC_ID));
+ verifyAttListRpc(ctx, outPre);
+ }
+
+ /**
+ * Creates attribute list for encoding JSON or XML with container,
+ * grouping and augmented YANG file.
+ *
+ * @param pre prefix
+ * @return service logic context
+ */
+ private SvcLogicContext createAttListYang(String pre) {
+ SvcLogicContext ctx = new SvcLogicContext();
+ ctx.setAttribute(pre + "name_of_the_cont3.name_of_the_leaf" +
+ "10", "abc");
+ ctx.setAttribute(pre + "name_of_the_list1[0].name_of_the_leaf1" +
+ "", "true");
+ ctx.setAttribute(pre + "name_of_the_list1[0].name_of_the_leaf2" +
+ "", "abc");
+ ctx.setAttribute(pre + "name_of_the_list1[0].name_of_the_leaf3" +
+ "", "abc");
+ ctx.setAttribute(pre + "name_of_the_list1[0].name_of_the_" +
+ "ll1[0]", "abc");
+ ctx.setAttribute(pre + "name_of_the_list1[0].name_of_the_" +
+ "ll1[1]", "abc");
+ ctx.setAttribute(pre + "name_of_the_list1[0].name_of_the_" +
+ "ll2[0]", "abc");
+ ctx.setAttribute(pre + "name_of_the_list1[0].name_of_the_" +
+ "ll2[1]", "abc");
+ ctx.setAttribute(pre + "name_of_the_list1[0].name_of_the_" +
+ "cont4.name_of_the_leaf11", "abc");
+ ctx.setAttribute(pre + "name_of_the_list1[0].name_of_the_" +
+ "list4[0].name_of_the_leaf8", "abc");
+ ctx.setAttribute(pre + "name_of_the_list1[0].name_of_the_" +
+ "list4[1].name_of_the_leaf8", "abc");
+ ctx.setAttribute(pre + "name_of_the_list1[0].name_of_the_" +
+ "list5[0].name_of_the_leaf9", "abc");
+ ctx.setAttribute(pre + "name_of_the_list1[0].name_of_the_" +
+ "list5[1].name_of_the_leaf9", "abc");
+ ctx.setAttribute(pre + "name_of_the_list1[1].name_of_the_" +
+ "leaf1", "true");
+ ctx.setAttribute(pre + "name_of_the_list1[1].name_of_the_" +
+ "leaf2", "abc");
+ ctx.setAttribute(pre + "name_of_the_list1[1].name_of_the_" +
+ "leaf3", "abc");
+ ctx.setAttribute(pre + "name_of_the_list1[1].name_of_the_" +
+ "ll1[0]", "abc");
+ ctx.setAttribute(pre + "name_of_the_list1[1].name_of_the_" +
+ "ll1[1]", "abc");
+ ctx.setAttribute(pre + "name_of_the_list1[1].name_of_the_" +
+ "ll2[0]", "abc");
+ ctx.setAttribute(pre + "name_of_the_list1[1].name_of_the_" +
+ "ll2[1]", "abc");
+ ctx.setAttribute(pre + "name_of_the_list1[1].name_of_the_" +
+ "cont4.name_of_the_leaf11", "abc");
+ ctx.setAttribute(pre + "name_of_the_list1[1].name_of_the_" +
+ "list4[0].name_of_the_leaf8", "abc");
+ ctx.setAttribute(pre + "name_of_the_list1[1].name_of_the_" +
+ "list4[1].name_of_the_leaf8", "abc");
+ ctx.setAttribute(pre + "name_of_the_list1[1].name_of_the_" +
+ "list5[0].name_of_the_leaf9", "abc");
+ ctx.setAttribute(pre + "name_of_the_list1[1].name_of_the_" +
+ "list5[1].name_of_the_leaf9", "abc");
+ ctx.setAttribute(pre + "name_of_the_list2[0].name_of_the_" +
+ "leaf4", "abc");
+ ctx.setAttribute(pre + "name_of_the_list2[1].name_of_the_" +
+ "leaf4", "abc");
+ ctx.setAttribute(pre + "name_of_the_leaf5", "abc");
+ ctx.setAttribute(pre + "name_of_the_leaf6", "abc");
+ ctx.setAttribute(pre + "name_of_the_ll3[0]", "abc");
+ ctx.setAttribute(pre + "name_of_the_ll3[1]", "abc");
+ ctx.setAttribute(pre + "name_of_the_ll4[0]", "abc");
+ ctx.setAttribute(pre + "name_of_the_ll4[1]", "abc");
+ ctx.setAttribute(pre + "name_of_the_cont4.name_of_the_leaf10",
+ "abc");
+ ctx.setAttribute(pre + "name_of_the_list6[0].name_of_the_leaf11",
+ "abc");
+ ctx.setAttribute(pre + "name_of_the_list6[1].name_of_the_leaf11",
+ "abc");
+ ctx.setAttribute(pre + "name_of_the_leaf12", "abc");
+ ctx.setAttribute(pre + "name_of_the_ll5[0]", "abc");
+ ctx.setAttribute(pre + "name_of_the_ll5[1]", "abc");
+ ctx.setAttribute(pre + "name_of_the_cont4.test_augment_1_for_" +
+ "module_name_of_the_cont5.name_of_the_leaf13",
+ "true");
+ ctx.setAttribute(pre + "name_of_the_cont4.test_augment_1_for_" +
+ "module_name_of_the_list7[0].name_of_the" +
+ "_leaf14", "test");
+ ctx.setAttribute(pre + "name_of_the_cont4.test_augment_1_for_" +
+ "module_name_of_the_list7[1].name_of_the" +
+ "_leaf14", "create");
+ ctx.setAttribute(pre + "name_of_the_cont4.test_augment_1_for_" +
+ "module_name_of_the_leaf15", "abc");
+ ctx.setAttribute(pre + "name_of_the_cont4.test_augment_1_for_" +
+ "module_name_of_the_ll6[0]",
+ "unbounded");
+ ctx.setAttribute(pre + "name_of_the_cont4.test_augment_1_for" +
+ "_module_name_of_the_ll6[1]", "8");
+ ctx.setAttribute(pre + "name_of_the_cont4.test_augment_1_for" +
+ "_module_name_of_the_cont13.name_of_the_" +
+ "cont12.name_of_the_leaf26",
+ "abc");
+ ctx.setAttribute(pre + "name_of_the_cont4.test_augment_1_for_" +
+ "module_name_of_the_cont13.name_of_the_" +
+ "list9[0].name_of_the_leaf27",
+ "abc");
+ ctx.setAttribute(pre + "name_of_the_cont4.test_augment_1_for" +
+ "_module_name_of_the_cont13.name_of_the_" +
+ "list9[1].name_of_the_leaf27",
+ "abc");
+ ctx.setAttribute(pre + "name_of_the_cont4.test_augment_1_for" +
+ "_module_name_of_the_cont13.name_of_the_" +
+ "leaf28", "abc");
+ ctx.setAttribute(pre + "name_of_the_cont4.test_augment_1_for" +
+ "_module_name_of_the_cont13.name_of_the_" +
+ "ll9[0]", "abc");
+ ctx.setAttribute(pre + "name_of_the_cont4.test_augment_1_for" +
+ "_module_name_of_the_cont13.name_of_the_" +
+ "ll9[1]", "abc");
+ return ctx;
+ }
+
+ /**
+ * Creates attribute list for encoding JSON or XML with RPC YANG file.
+ *
+ * @param pre prefix
+ * @return service logic context
+ */
+ private SvcLogicContext createAttListRpc(String pre) {
+ SvcLogicContext ctx = new SvcLogicContext();
+ ctx.setAttribute(pre + "name_of_the_cont14.name_of_the_leaf28",
+ "abc");
+ ctx.setAttribute(pre + "name_of_the_list10[0].name_of_the_leaf29",
+ "abc");
+ ctx.setAttribute(pre + "name_of_the_list10[1].name_of_the_leaf29",
+ "abc");
+ ctx.setAttribute(pre + "name_of_the_leaf30", "abc");
+ ctx.setAttribute(pre + "name_of_the_ll10[0]", "abc");
+ ctx.setAttribute(pre + "name_of_the_ll10[1]", "abc");
+ ctx.setAttribute(pre + "name_of_the_cont15.name_of_the_leaf31",
+ "abc");
+ ctx.setAttribute(pre + "name_of_the_cont13.name_of_the_list9[0]" +
+ ".name_of_the_leaf27", "abc");
+ ctx.setAttribute(pre + "name_of_the_cont13.name_of_the_list9[1]" +
+ ".name_of_the_leaf27", "abc");
+ ctx.setAttribute(pre + "name_of_the_cont13.name_of_the_leaf28",
+ "abc");
+ ctx.setAttribute(pre + "name_of_the_cont13.name_of_the_ll9[0]",
+ "abc");
+ ctx.setAttribute(pre + "name_of_the_cont13.name_of_the_ll9[1]",
+ "abc");
+ return ctx;
+ }
+
+ /**
+ * Verifies the attribute list for decoding from JSON or XML with
+ * container, grouping and augmented file.
+ *
+ * @param ctx service logic context
+ * @param pre prefix
+ */
+ private void verifyAttListYang(SvcLogicContext ctx, String pre) {
+ assertThat(ctx.getAttribute(pre + "name_of_the_cont3.name_of" +
+ "_the_leaf10"), is("abc"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_list1[0].name" +
+ "_of_the_leaf1"), is("true"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_list1[0].name" +
+ "_of_the_leaf2"), is("abc"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_list1[0].name" +
+ "_of_the_leaf3"), is("abc"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_list1[0].name" +
+ "_of_the_ll1[0]"), is("abc"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_list1[0].name" +
+ "_of_the_ll1[1]"), is("abc"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_list1[0].name" +
+ "_of_the_ll2[0]"), is("abc"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_list1[0].name" +
+ "_of_the_ll2[1]"), is("abc"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_list1[0].name" +
+ "_of_the_cont4.name_of_the_leaf11"),
+ is("abc"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_list1[0].name_of" +
+ "_the_list4[0].name_of_the_leaf8"),
+ is("abc"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_list1[0].name_of" +
+ "_the_list4[1].name_of_the_leaf8"),
+ is("abc"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_list1[0].name_of" +
+ "_the_list5[0].name_of_the_leaf9"),
+ is("abc"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_list1[0].name_of" +
+ "_the_list5[1].name_of_the_leaf9"),
+ is("abc"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_list1[1].name_of" +
+ "_the_leaf1"), is("true"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_list1[1].name_of" +
+ "_the_leaf2"), is("abc"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_list1[1].name_of" +
+ "_the_leaf3"), is("abc"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_list1[1].name_of" +
+ "_the_ll1[0]"), is("abc"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_list1[1].name_of" +
+ "_the_ll1[1]"), is("abc"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_list1[1].name_of" +
+ "_the_ll2[0]"), is("abc"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_list1[1].name_of" +
+ "_the_ll2[1]"), is("abc"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_list1[1].name_of" +
+ "_the_cont4.name_of_the_leaf11"),
+ is("abc"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_list1[1].name_of" +
+ "_the_list4[0].name_of_the_leaf8"),
+ is("abc"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_list1[1].name_of" +
+ "_the_list4[1].name_of_the_leaf8"),
+ is("abc"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_list1[1].name_of" +
+ "_the_list5[0].name_of_the_leaf9"),
+ is("abc"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_list1[1].name_of" +
+ "_the_list5[1].name_of_the_leaf9"),
+ is("abc"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_list2[0].name_of" +
+ "_the_leaf4"), is("abc"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_list2[1].name_of" +
+ "_the_leaf4"), is("abc"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_leaf5"),
+ is("abc"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_leaf6"),
+ is("abc"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_ll3[0]"),
+ is("abc"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_ll3[1]"),
+ is("abc"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_ll4[0]"),
+ is("abc"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_ll4[1]"),
+ is("abc"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_cont4.name_of" +
+ "_the_leaf10"), is( "abc"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_list6[0].name_of" +
+ "_the_leaf11"), is("abc"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_list6[1].name_of" +
+ "_the_leaf11"), is("abc"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_leaf12"),
+ is("abc"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_ll5[0]"),
+ is("abc"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_ll5[1]"),
+ is("abc"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_cont4.test_" +
+ "augment_1_for_module_name_of_" +
+ "the_cont5.name_of_the_leaf13"),
+ is("true"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_cont4.test_" +
+ "augment_1_for_module_name_of_" +
+ "the_list7[0].name_of_the_leaf14"),
+ is("test"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_cont4.test_" +
+ "augment_1_for_module_name_of_" +
+ "the_list7[1].name_of_the_leaf14"),
+ is("create"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_cont4.test_" +
+ "augment_1_for_module_name_of_" +
+ "the_leaf15"),
+ is("abc"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_cont4.test_" +
+ "augment_1_for_module_name_of_" +
+ "the_ll6[0]"),
+ is("unbounded"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_cont4.test_" +
+ "augment_1_for_module_name_of_" +
+ "the_ll6[1]"),
+ is("8"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_cont4.test_" +
+ "augment_1_for_module_name_of_" +
+ "the_cont13" +
+ ".name_of_the_cont12.name_of_" +
+ "the_leaf26"), is("abc"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_cont4.test_" +
+ "augment_1_for_module_name_of_" +
+ "the_cont13.name_of_the_list9[0]" +
+ ".name_of_the_leaf27"),
+ is("abc"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_cont4.test_" +
+ "augment_1_for_module_name_of_" +
+ "the_cont13.name_of_the_list9[1]" +
+ ".name_of_the_leaf27"),
+ is("abc"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_cont4.test_" +
+ "augment_1_for_module_name_of_" +
+ "the_cont13.name_of_the_leaf28"),
+ is("abc"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_cont4.test_" +
+ "augment_1_for_module_name_of_" +
+ "the_cont13.name_of_the_ll9[0]"),
+ is("abc"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_cont4.test_" +
+ "augment_1_for_module_name_of_" +
+ "the_cont13.name_of_the_ll9[1]"),
+ is("abc"));
+ }
+
+ /**
+ * Verifies the attribute list for decoding from JSON or XML with
+ * RPC YANG file.
+ *
+ * @param ctx service logic context
+ * @param pre prefix
+ */
+ private void verifyAttListRpc(SvcLogicContext ctx, String pre) {
+ assertThat(ctx.getAttribute(pre + "name_of_the_cont16.name_of_" +
+ "the_leaf32"), is("abc"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_list11[0].name" +
+ "_of_the_leaf33"), is("abc"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_list11[1].name" +
+ "_of_the_leaf33"), is("abc"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_leaf34"),
+ is("abc"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_ll11[0]"),
+ is("abc"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_ll11[1]"),
+ is("abc"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_cont17.name_of_" +
+ "the_leaf35"), is("abc"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_cont13.name_of_" +
+ "the_cont12.name_of_the_leaf26"),
+ is("abc"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_cont13.name_of_" +
+ "the_list9[0].name_of_the_leaf27"),
+ is("abc"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_cont13.name_of_" +
+ "the_list9[1].name_of_the_leaf27"),
+ is("abc"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_cont13.name_of_" +
+ "the_ll9[0]"), is("abc"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_cont13.name_of_" +
+ "the_ll9[1]"), is("abc"));
+ assertThat(ctx.getAttribute(pre + "name_of_the_cont13.name_of_" +
+ "the_leaf28"), is("abc"));
+ }
+
+ /**
+ * Captures the data format messages by mocking it, which can be used in
+ * testing the value.
+ *
+ * @param <String> capturing data format
+ */
+ public class DfCaptor<String> implements Answer {
+
+ private String result;
+
+ /**
+ * Returns the captured data format message.
+ *
+ * @return data format message.
+ */
+ public String getResult() {
+ return result;
+ }
+
+ @Override
+ public String answer(InvocationOnMock invocationOnMock)
+ throws Throwable {
+ result = (String) invocationOnMock.callRealMethod();
+ return result;
+ }
+ }
+
+}
diff --git a/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/IdentifierValidationUtilsTest.java b/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/IdentifierValidationUtilsTest.java
new file mode 100644
index 000000000..a866f1c4a
--- /dev/null
+++ b/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/IdentifierValidationUtilsTest.java
@@ -0,0 +1,469 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - CCSDK
+ * ================================================================================
+ * Copyright (C) 2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.ccsdk.sli.plugins.yangserializers.dfserializer;
+
+import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DataFormatUtilsTest.addSpace;
+
+/**
+ * Unit test case utilities for identifier validation and restconf api
+ * call node.
+ */
+public final class IdentifierValidationUtilsTest {
+
+ static final String ENCODE_TO_JSON_YANG_COMMON_ID = "\n " +
+ "\"test_augment_1_for_module:name_of_the_ll6\": [\n" +
+ " \"unbounded\",\n" +
+ " \"8\"\n" +
+ " ],\n" +
+ " \"test_augment_1_for_module:name_of_the_cont13\": {\n" +
+ " \"name_of_the_cont12\": {\n" +
+ " \"name_of_the_leaf26\": \"abc\"\n" +
+ " },\n" +
+ " \"name_of_the_ll9\": [\n" +
+ " \"abc\",\n" +
+ " \"abc\"\n" +
+ " ],\n" +
+ " \"name_of_the_leaf28\": \"abc\",\n" +
+ " \"name_of_the_list9\": [\n" +
+ " {\n" +
+ " \"name_of_the_leaf27\": \"abc\"\n" +
+ " },\n" +
+ " {\n" +
+ " \"name_of_the_leaf27\": \"abc\"\n" +
+ " }\n" +
+ " ]\n" +
+ " },\n" +
+ " \"test_augment_1_for_module:name_of_the_list7\": [\n" +
+ " {\n" +
+ " \"name_of_the_leaf14\": \"test\"\n" +
+ " },\n" +
+ " {\n" +
+ " \"name_of_the_leaf14\": \"create\"\n" +
+ " }\n" +
+ " ],\n" +
+ " \"test_augment_1_for_module:name_of_the_leaf15\": \"abc\",\n" +
+ " \"test_augment_1_for_module:name_of_the_cont5\": {\n" +
+ " \"name_of_the_leaf13\": \"true\"\n" +
+ " }";
+
+ static final String ENCODE_TO_JSON_YANG_AUG_POST_ID = "{\n" +
+ " \"test_name_of_the_module:name_of_the_leaf10\": \"abc\"," +
+ ENCODE_TO_JSON_YANG_COMMON_ID + "\n}";
+
+ static final String ENCODE_TO_JSON_YANG_ID = "{\n" +
+ " \"test_name_of_the_module:name_of_the_cont2\": {\n" +
+ " \"name_of_the_ll4\": [\n" +
+ " \"abc\",\n" +
+ " \"abc\"\n" +
+ " ],\n" +
+ " \"name_of_the_leaf5\": \"abc\",\n" +
+ " \"name_of_the_list6\": [\n" +
+ " {\n" +
+ " \"name_of_the_leaf11\": \"abc\"\n" +
+ " },\n" +
+ " {\n" +
+ " \"name_of_the_leaf11\": \"abc\"\n" +
+ " }\n" +
+ " ],\n" +
+ " \"name_of_the_ll5\": [\n" +
+ " \"abc\",\n" +
+ " \"abc\"\n" +
+ " ],\n" +
+ " \"name_of_the_ll3\": [\n" +
+ " \"abc\",\n" +
+ " \"abc\"\n" +
+ " ],\n" +
+ " \"name_of_the_leaf6\": \"abc\",\n" +
+ " \"name_of_the_cont3\": {\n" +
+ " \"name_of_the_leaf10\": \"abc\"\n" +
+ " },\n" +
+ " \"name_of_the_list2\": [\n" +
+ " {\n" +
+ " \"name_of_the_leaf4\": \"abc\"\n" +
+ " },\n" +
+ " {\n" +
+ " \"name_of_the_leaf4\": \"abc\"\n" +
+ " }\n" +
+ " ],\n" +
+ " \"name_of_the_list1\": [\n" +
+ " {\n" +
+ " \"name_of_the_ll2\": [\n" +
+ " \"abc\",\n" +
+ " \"abc\"\n" +
+ " ],\n" +
+ " \"name_of_the_list5\": [\n" +
+ " {\n" +
+ " \"name_of_the_leaf9\": \"abc\"\n" +
+ " },\n" +
+ " {\n" +
+ " \"name_of_the_leaf9\": \"abc\"\n" +
+ " }\n" +
+ " ],\n" +
+ " \"name_of_the_list4\": [\n" +
+ " {\n" +
+ " \"name_of_the_leaf8\": \"abc\"\n" +
+ " },\n" +
+ " {\n" +
+ " \"name_of_the_leaf8\": \"abc\"\n" +
+ " }\n" +
+ " ],\n" +
+ " \"name_of_the_leaf1\": \"true\",\n" +
+ " \"name_of_the_leaf3\": \"abc\",\n" +
+ " \"name_of_the_leaf2\": \"abc\",\n" +
+ " \"name_of_the_cont4\": {\n" +
+ " \"name_of_the_leaf11\": \"abc\"\n" +
+ " },\n" +
+ " \"name_of_the_ll1\": [\n" +
+ " \"abc\",\n" +
+ " \"abc\"\n" +
+ " ]\n" +
+ " },\n" +
+ " {\n" +
+ " \"name_of_the_ll2\": [\n" +
+ " \"abc\",\n" +
+ " \"abc\"\n" +
+ " ],\n" +
+ " \"name_of_the_list5\": [\n" +
+ " {\n" +
+ " \"name_of_the_leaf9\": \"abc\"\n" +
+ " },\n" +
+ " {\n" +
+ " \"name_of_the_leaf9\": \"abc\"\n" +
+ " }\n" +
+ " ],\n" +
+ " \"name_of_the_list4\": [\n" +
+ " {\n" +
+ " \"name_of_the_leaf8\": \"abc\"\n" +
+ " },\n" +
+ " {\n" +
+ " \"name_of_the_leaf8\": \"abc\"\n" +
+ " }\n" +
+ " ],\n" +
+ " \"name_of_the_leaf1\": \"true\",\n" +
+ " \"name_of_the_leaf3\": \"abc\",\n" +
+ " \"name_of_the_leaf2\": \"abc\",\n" +
+ " \"name_of_the_cont4\": {\n" +
+ " \"name_of_the_leaf11\": \"abc\"\n" +
+ " },\n" +
+ " \"name_of_the_ll1\": [\n" +
+ " \"abc\",\n" +
+ " \"abc\"\n" +
+ " ]\n" +
+ " }\n" +
+ " ],\n" +
+ " \"name_of_the_cont4\": {\n" +
+ " \"name_of_the_leaf10\": \"abc\"," +
+ addSpace(ENCODE_TO_JSON_YANG_COMMON_ID,8) + "\n" +
+ " },\n" +
+ " \"name_of_the_leaf12\": \"abc\"\n" +
+ " }\n" +
+ "}";
+
+ static final String ENCODE_TO_JSON_WITH_AUG_PATH = "{\n" +
+ " \"test_augment_1_for_module:name_of_the_leaf13\": \"true\"\n" +
+ "}";
+
+ static final String ENCODE_TO_JSON_YANG_PUT_ID = "{\n" +
+ " \"test_name_of_the_module:name_of_the_cont4\": {" + addSpace(
+ ENCODE_TO_JSON_YANG_COMMON_ID, 4) + ",\n" +
+ " \"name_of_the_leaf10\": \"abc\"\n" +
+ " }\n" +
+ "}";
+
+ static final String ENCODE_TO_XML_YANG_COMMON_ID = "\n" +
+ "<name_of_the_ll6 xmlns=\"urn:opendaylight:params:xml:ns:yang:" +
+ "test:augment:name\">unbounded</name_of_the_ll6>\n" +
+ "<name_of_the_ll6 xmlns=\"urn:opendaylight:params:xml:ns:yang:" +
+ "test:augment:name\">8</name_of_the_ll6>\n" +
+ "<name_of_the_cont13 xmlns=\"urn:opendaylight:params:xml:ns:ya" +
+ "ng:test:augment:name\">\n" +
+ " <name_of_the_cont12>\n" +
+ " <name_of_the_leaf26>abc</name_of_the_leaf26>\n" +
+ " </name_of_the_cont12>\n" +
+ " <name_of_the_ll9>abc</name_of_the_ll9>\n" +
+ " <name_of_the_ll9>abc</name_of_the_ll9>\n" +
+ " <name_of_the_leaf28>abc</name_of_the_leaf28>\n" +
+ " <name_of_the_list9>\n" +
+ " <name_of_the_leaf27>abc</name_of_the_leaf27>\n" +
+ " </name_of_the_list9>\n" +
+ " <name_of_the_list9>\n" +
+ " <name_of_the_leaf27>abc</name_of_the_leaf27>\n" +
+ " </name_of_the_list9>\n" +
+ "</name_of_the_cont13>\n" +
+ "<name_of_the_list7 xmlns=\"urn:opendaylight:params:xml:ns:yan" +
+ "g:test:augment:name\">\n" +
+ " <name_of_the_leaf14>test</name_of_the_leaf14>\n" +
+ "</name_of_the_list7>\n" +
+ "<name_of_the_list7 xmlns=\"urn:opendaylight:params:xml:ns:yan" +
+ "g:test:augment:name\">\n" +
+ " <name_of_the_leaf14>create</name_of_the_leaf14>\n" +
+ "</name_of_the_list7>\n" +
+ "<name_of_the_leaf15 xmlns=\"urn:opendaylight:params:xml:ns:ya" +
+ "ng:test:augment:name\">abc</name_of_the_leaf15>\n" +
+ "<name_of_the_cont5 xmlns=\"urn:opendaylight:params:xml:ns:yan" +
+ "g:test:augment:name\">\n" +
+ " <name_of_the_leaf13>true</name_of_the_leaf13>\n" +
+ "</name_of_the_cont5>";
+
+ static final String ENCODE_TO_XML_YANG_AUG_POST_ID = "<?xml version=\"1" +
+ ".0\" encoding=\"UTF-8\" standalone=\"no\"?>\n" +
+ "<name_of_the_leaf10 xmlns=\"urn:opendaylight:params:xml:ns:yan" +
+ "g:test:name\">abc</name_of_the_leaf10>" +
+ ENCODE_TO_XML_YANG_COMMON_ID + "\n";
+
+ static final String ENCODE_TO_XML_YANG_PUT_ID = "<?xml version=\"1.0\" " +
+ "encoding=\"UTF-8\" standalone=\"no\"?>\n" +
+ "<name_of_the_cont4 xmlns=\"urn:opendaylight:params:xml:ns:yang" +
+ ":test:name\">\n" +
+ " <name_of_the_leaf10>abc</name_of_the_leaf10>" +
+ addSpace(ENCODE_TO_XML_YANG_COMMON_ID, 4) + "\n</name_of_the_co" +
+ "nt4>\n";
+
+ static final String ENCODE_TO_XML_YANG_ID= "<?xml version=\"1.0\" " +
+ "encoding=\"UTF-8\" standalone=\"no\"?>\n" +
+ "<name_of_the_cont2 xmlns=\"urn:opendaylight:params:xml:ns:yan" +
+ "g:test:name\">\n" +
+ " <name_of_the_ll4>abc</name_of_the_ll4>\n" +
+ " <name_of_the_ll4>abc</name_of_the_ll4>\n" +
+ " <name_of_the_leaf5>abc</name_of_the_leaf5>\n" +
+ " <name_of_the_list6>\n" +
+ " <name_of_the_leaf11>abc</name_of_the_leaf11>\n" +
+ " </name_of_the_list6>\n" +
+ " <name_of_the_list6>\n" +
+ " <name_of_the_leaf11>abc</name_of_the_leaf11>\n" +
+ " </name_of_the_list6>\n" +
+ " <name_of_the_ll5>abc</name_of_the_ll5>\n" +
+ " <name_of_the_ll5>abc</name_of_the_ll5>\n" +
+ " <name_of_the_ll3>abc</name_of_the_ll3>\n" +
+ " <name_of_the_ll3>abc</name_of_the_ll3>\n" +
+ " <name_of_the_leaf6>abc</name_of_the_leaf6>\n" +
+ " <name_of_the_cont3>\n" +
+ " <name_of_the_leaf10>abc</name_of_the_leaf10>\n" +
+ " </name_of_the_cont3>\n" +
+ " <name_of_the_list2>\n" +
+ " <name_of_the_leaf4>abc</name_of_the_leaf4>\n" +
+ " </name_of_the_list2>\n" +
+ " <name_of_the_list2>\n" +
+ " <name_of_the_leaf4>abc</name_of_the_leaf4>\n" +
+ " </name_of_the_list2>\n" +
+ " <name_of_the_list1>\n" +
+ " <name_of_the_ll2>abc</name_of_the_ll2>\n" +
+ " <name_of_the_ll2>abc</name_of_the_ll2>\n" +
+ " <name_of_the_list5>\n" +
+ " <name_of_the_leaf9>abc</name_of_the_leaf9>\n" +
+ " </name_of_the_list5>\n" +
+ " <name_of_the_list5>\n" +
+ " <name_of_the_leaf9>abc</name_of_the_leaf9>\n" +
+ " </name_of_the_list5>\n" +
+ " <name_of_the_list4>\n" +
+ " <name_of_the_leaf8>abc</name_of_the_leaf8>\n" +
+ " </name_of_the_list4>\n" +
+ " <name_of_the_list4>\n" +
+ " <name_of_the_leaf8>abc</name_of_the_leaf8>\n" +
+ " </name_of_the_list4>\n" +
+ " <name_of_the_leaf1>true</name_of_the_leaf1>\n" +
+ " <name_of_the_leaf3>abc</name_of_the_leaf3>\n" +
+ " <name_of_the_leaf2>abc</name_of_the_leaf2>\n" +
+ " <name_of_the_cont4>\n" +
+ " <name_of_the_leaf11>abc</name_of_the_leaf11>\n" +
+ " </name_of_the_cont4>\n" +
+ " <name_of_the_ll1>abc</name_of_the_ll1>\n" +
+ " <name_of_the_ll1>abc</name_of_the_ll1>\n" +
+ " </name_of_the_list1>\n" +
+ " <name_of_the_list1>\n" +
+ " <name_of_the_ll2>abc</name_of_the_ll2>\n" +
+ " <name_of_the_ll2>abc</name_of_the_ll2>\n" +
+ " <name_of_the_list5>\n" +
+ " <name_of_the_leaf9>abc</name_of_the_leaf9>\n" +
+ " </name_of_the_list5>\n" +
+ " <name_of_the_list5>\n" +
+ " <name_of_the_leaf9>abc</name_of_the_leaf9>\n" +
+ " </name_of_the_list5>\n" +
+ " <name_of_the_list4>\n" +
+ " <name_of_the_leaf8>abc</name_of_the_leaf8>\n" +
+ " </name_of_the_list4>\n" +
+ " <name_of_the_list4>\n" +
+ " <name_of_the_leaf8>abc</name_of_the_leaf8>\n" +
+ " </name_of_the_list4>\n" +
+ " <name_of_the_leaf1>true</name_of_the_leaf1>\n" +
+ " <name_of_the_leaf3>abc</name_of_the_leaf3>\n" +
+ " <name_of_the_leaf2>abc</name_of_the_leaf2>\n" +
+ " <name_of_the_cont4>\n" +
+ " <name_of_the_leaf11>abc</name_of_the_leaf11>\n" +
+ " </name_of_the_cont4>\n" +
+ " <name_of_the_ll1>abc</name_of_the_ll1>\n" +
+ " <name_of_the_ll1>abc</name_of_the_ll1>\n" +
+ " </name_of_the_list1>\n" +
+ " <name_of_the_cont4>\n" +
+ " <name_of_the_leaf10>abc</name_of_the_leaf10>" +
+ addSpace(ENCODE_TO_XML_YANG_COMMON_ID, 8) + "\n" +
+ " </name_of_the_cont4>\n" +
+ " <name_of_the_leaf12>abc</name_of_the_leaf12>\n" +
+ "</name_of_the_cont2>\n";
+
+ static final String ENCODE_TO_JSON_RPC_ID = "{\n" +
+ " \"test_name_of_the_module:input\": {\n" +
+ " \"name_of_the_cont14\": {\n" +
+ " \"name_of_the_leaf28\": \"abc\"\n" +
+ " },\n" +
+ " \"name_of_the_cont13\": {\n" +
+ " \"name_of_the_ll9\": [\n" +
+ " \"abc\",\n" +
+ " \"abc\"\n" +
+ " ],\n" +
+ " \"name_of_the_leaf28\": \"abc\",\n" +
+ " \"name_of_the_list9\": [\n" +
+ " {\n" +
+ " \"name_of_the_leaf27\": \"abc\"\n" +
+ " },\n" +
+ " {\n" +
+ " \"name_of_the_leaf27\": \"abc\"\n" +
+ " }\n" +
+ " ]\n" +
+ " },\n" +
+ " \"name_of_the_leaf30\": \"abc\",\n" +
+ " \"name_of_the_ll10\": [\n" +
+ " \"abc\",\n" +
+ " \"abc\"\n" +
+ " ],\n" +
+ " \"name_of_the_list10\": [\n" +
+ " {\n" +
+ " \"name_of_the_leaf29\": \"abc\"\n" +
+ " },\n" +
+ " {\n" +
+ " \"name_of_the_leaf29\": \"abc\"\n" +
+ " }\n" +
+ " ],\n" +
+ " \"name_of_the_cont15\": {\n" +
+ " \"name_of_the_leaf31\": \"abc\"\n" +
+ " }\n" +
+ " }\n" +
+ "}";
+
+ static final String DECODE_FROM_JSON_RPC_ID = "{\n" +
+ " \"test_name_of_the_module:output\": {\n" +
+ " \"name_of_the_cont16\": {\n" +
+ " \"name_of_the_leaf32\": \"abc\"\n" +
+ " },\n" +
+ " \"name_of_the_list11\": [\n" +
+ " {\n" +
+ " \"name_of_the_leaf33\": \"abc\"\n" +
+ " },\n" +
+ " {\n" +
+ " \"name_of_the_leaf33\": \"abc\"\n" +
+ " }\n" +
+ " ],\n" +
+ " \"name_of_the_leaf34\": \"abc\",\n" +
+ " \"name_of_the_ll11\": [\n" +
+ " \"abc\",\n" +
+ " \"abc\"\n" +
+ " ],\n" +
+ " \"name_of_the_cont17\": {\n" +
+ " \"name_of_the_leaf35\": \"abc\"\n" +
+ " },\n" +
+ " \"name_of_the_cont13\": {\n" +
+ " \"name_of_the_cont12\": {\n" +
+ " \"name_of_the_leaf26\": \"abc\"\n" +
+ " },\n" +
+ " \"name_of_the_list9\": [\n" +
+ " {\n" +
+ " \"name_of_the_leaf27\": \"abc\"\n" +
+ " },\n" +
+ " {\n" +
+ " \"name_of_the_leaf27\": \"abc\"\n" +
+ " }\n" +
+ " ],\n" +
+ " \"name_of_the_ll9\": [\n" +
+ " \"abc\",\n" +
+ " \"abc\"\n" +
+ " ],\n" +
+ " \"name_of_the_leaf28\": \"abc\"\n" +
+ " }\n" +
+ " }\n" +
+ "}";
+
+ static final String ENCODE_TO_XML_RPC_ID = "<?xml version=\"1.0\" " +
+ "encoding=\"UTF-8\" standalone=\"no\"?>\n" +
+ "<input xmlns=\"urn:opendaylight:params:xml:ns:yang:test:name\"" +
+ ">\n" +
+ " <name_of_the_cont14>\n" +
+ " <name_of_the_leaf28>abc</name_of_the_leaf28>\n" +
+ " </name_of_the_cont14>\n" +
+ " <name_of_the_cont13>\n" +
+ " <name_of_the_ll9>abc</name_of_the_ll9>\n" +
+ " <name_of_the_ll9>abc</name_of_the_ll9>\n" +
+ " <name_of_the_leaf28>abc</name_of_the_leaf28>\n" +
+ " <name_of_the_list9>\n" +
+ " <name_of_the_leaf27>abc</name_of_the_leaf27>\n" +
+ " </name_of_the_list9>\n" +
+ " <name_of_the_list9>\n" +
+ " <name_of_the_leaf27>abc</name_of_the_leaf27>\n" +
+ " </name_of_the_list9>\n" +
+ " </name_of_the_cont13>\n" +
+ " <name_of_the_leaf30>abc</name_of_the_leaf30>\n" +
+ " <name_of_the_ll10>abc</name_of_the_ll10>\n" +
+ " <name_of_the_ll10>abc</name_of_the_ll10>\n" +
+ " <name_of_the_list10>\n" +
+ " <name_of_the_leaf29>abc</name_of_the_leaf29>\n" +
+ " </name_of_the_list10>\n" +
+ " <name_of_the_list10>\n" +
+ " <name_of_the_leaf29>abc</name_of_the_leaf29>\n" +
+ " </name_of_the_list10>\n" +
+ " <name_of_the_cont15>\n" +
+ " <name_of_the_leaf31>abc</name_of_the_leaf31>\n" +
+ " </name_of_the_cont15>\n" +
+ "</input>\n";
+
+ static final String DECODE_FROM_XML_RPC_ID = "<?xml version=\"1.0\" " +
+ "encoding=\"UTF-8\" standalone=\"no\"?>\n" +
+ "<output xmlns=\"urn:opendaylight:params:xml:ns:yang:test:name" +
+ "\">\n" +
+ " <name_of_the_cont16>\n" +
+ " <name_of_the_leaf32>abc</name_of_the_leaf32>\n" +
+ " </name_of_the_cont16>\n" +
+ " <name_of_the_list11>\n" +
+ " <name_of_the_leaf33>abc</name_of_the_leaf33>\n" +
+ " </name_of_the_list11>\n" +
+ " <name_of_the_list11>\n" +
+ " <name_of_the_leaf33>abc</name_of_the_leaf33>\n" +
+ " </name_of_the_list11>\n" +
+ " <name_of_the_leaf34>abc</name_of_the_leaf34>\n" +
+ " <name_of_the_ll11>abc</name_of_the_ll11>\n" +
+ " <name_of_the_ll11>abc</name_of_the_ll11>\n" +
+ " <name_of_the_cont17>\n" +
+ " <name_of_the_leaf35>abc</name_of_the_leaf35>\n" +
+ " </name_of_the_cont17>\n" +
+ " <name_of_the_cont13>\n" +
+ " <name_of_the_cont12>\n" +
+ " <name_of_the_leaf26>abc</name_of_the_leaf26>\n" +
+ " </name_of_the_cont12>\n" +
+ " <name_of_the_list9>\n" +
+ " <name_of_the_leaf27>abc</name_of_the_leaf27>\n" +
+ " </name_of_the_list9>\n" +
+ " <name_of_the_list9>\n" +
+ " <name_of_the_leaf27>abc</name_of_the_leaf27>\n" +
+ " </name_of_the_list9>\n" +
+ " <name_of_the_ll9>abc</name_of_the_ll9>\n" +
+ " <name_of_the_ll9>abc</name_of_the_ll9>\n" +
+ " <name_of_the_leaf28>abc</name_of_the_leaf28>\n" +
+ " </name_of_the_cont13>\n" +
+ "</output>";
+}
diff --git a/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/PropertiesSerializerTest.java b/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/PropertiesSerializerTest.java
new file mode 100644
index 000000000..c3a6b4ea8
--- /dev/null
+++ b/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/pnserializer/PropertiesSerializerTest.java
@@ -0,0 +1,1144 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - CCSDK
+ * ================================================================================
+ * Copyright (C) 2018 Huawei Technologies Co., Ltd. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.ccsdk.sli.plugins.yangserializers.pnserializer;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.ccsdk.sli.core.sli.SvcLogicException;
+import org.opendaylight.restconf.common.context.InstanceIdentifierContext;
+import org.opendaylight.restconf.nb.rfc8040.utils.parser.ParserIdentifier;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertTrue;
+
+public final class PropertiesSerializerTest {
+ private SchemaContext context;
+
+ @Before
+ public void initialization() throws FileNotFoundException {
+ context = compileYangFile();
+ }
+
+ @Test
+ public void testBasicConstructs() throws SvcLogicException {
+ String uri = "test-yang:cont1/cont2";
+ Map<String, String> params = new HashMap<>();
+ params.put("test-yang_cont1.cont2.cont3.leaf10", "abc");
+ params.put("test-yang_cont1.cont2.list1[0].leaf1", "abc");
+ params.put("test-yang_cont1.cont2.list1[0].leaf2", "abc");
+ params.put("test-yang_cont1.cont2.list1[0].leaf3", "abc");
+ params.put("test-yang_cont1.cont2.list1[0].ll1[0]", "abc");
+ params.put("test-yang_cont1.cont2.list1[0].ll1[1]", "abc");
+ params.put("test-yang_cont1.cont2.list1[0].ll2[0]", "abc");
+ params.put("test-yang_cont1.cont2.list1[0].ll2[1]", "abc");
+ params.put("test-yang_cont1.cont2.list1[0].cont4.leaf11", "abc");
+ params.put("test-yang_cont1.cont2.list1[0].list4[0].leaf8", "abc");
+ params.put("test-yang_cont1.cont2.list1[0].list4[1].leaf8", "abc");
+ params.put("test-yang_cont1.cont2.list1[0].list5[0].leaf9", "abc");
+ params.put("test-yang_cont1.cont2.list1[0].list5[1].leaf9", "abc");
+ params.put("test-yang_cont1.cont2.list1[1].leaf1", "abc");
+ params.put("test-yang_cont1.cont2.list1[1].leaf2", "abc");
+ params.put("test-yang_cont1.cont2.list1[1].leaf3", "abc");
+ params.put("test-yang_cont1.cont2.list1[1].ll1[0]", "abc");
+ params.put("test-yang_cont1.cont2.list1[1].ll1[1]", "abc");
+ params.put("test-yang_cont1.cont2.list1[1].ll2[0]", "abc");
+ params.put("test-yang_cont1.cont2.list1[1].ll2[1]", "abc");
+ params.put("test-yang_cont1.cont2.list1[1].cont4.leaf11", "abc");
+ params.put("test-yang_cont1.cont2.list1[1].list4[0].leaf8", "abc");
+ params.put("test-yang_cont1.cont2.list1[1].list4[1].leaf8", "abc");
+ params.put("test-yang_cont1.cont2.list1[1].list5[0].leaf9", "abc");
+ params.put("test-yang_cont1.cont2.list1[1].list5[1].leaf9", "abc");
+ params.put("test-yang_cont1.cont2.list2[0].leaf4", "abc");
+ params.put("test-yang_cont1.cont2.list2[1].leaf4", "abc");
+ params.put("test-yang_cont1.cont2.leaf5", "abc");
+ params.put("test-yang_cont1.cont2.leaf6", "abc");
+ params.put("test-yang_cont1.cont2.ll3[0]", "abc");
+ params.put("test-yang_cont1.cont2.ll3[1]", "abc");
+ params.put("test-yang_cont1.cont2.ll4[0]", "abc");
+ params.put("test-yang_cont1.cont2.ll4[1]", "abc");
+ InstanceIdentifierContext<?> iCtx = ParserIdentifier
+ .toInstanceIdentifier(uri, context, null);
+
+ PropertiesNodeSerializer ser = new MdsalPropertiesNodeSerializer(
+ iCtx.getSchemaNode(), context, uri);
+ PropertiesNode node = ser.encode(params);
+
+ Map<String, PropertiesNode> childNodes = ((RootNode) node).children();
+
+ assertThat(childNodes.containsKey("cont3"), is(true));
+ SingleInstanceNode cont3 = ((SingleInstanceNode) childNodes.get("cont3"));
+ assertThat(cont3.uri(), is("test-yang:cont1.cont2.cont3"));
+ assertThat(cont3.children().containsKey("leaf10"), is(true));
+
+ assertThat(childNodes.containsKey("list1"), is(true));
+ HolderNode list1Holder = ((ListHolderNode) childNodes.get("list1"));
+ assertThat(list1Holder.uri(), is("test-yang:cont1.cont2.list1"));
+ MultiInstanceNode list10 = ((MultiInstanceNode) list1Holder.child("0"));
+ assertThat(list10.uri(), is("test-yang:cont1.cont2.list1[0]"));
+ Map<String, DataNodeChild> list10Child = list10.children();
+ assertThat(list10Child.containsKey("leaf1"), is(true));
+ LeafNode l = ((LeafNode) list10Child.get("leaf1"));
+ assertThat(l.uri(), is("test-yang:cont1.cont2.list1[0].leaf1"));
+ assertThat(list10Child.containsKey("leaf2"), is(true));
+ l = ((LeafNode) list10Child.get("leaf2"));
+ assertThat(l.uri(), is("test-yang:cont1.cont2.list1[0].leaf2"));
+ assertThat(list10Child.containsKey("leaf2"), is(true));
+ l = ((LeafNode) list10Child.get("leaf3"));
+ assertThat(l.uri(), is("test-yang:cont1.cont2.list1[0].leaf3"));
+
+ LeafListHolderNode ll1Holder = ((LeafListHolderNode) list10Child.get("ll1"));
+ assertThat(ll1Holder.uri(), is("test-yang:cont1.cont2.list1[0].ll1"));
+ assertThat(ll1Holder.children().containsKey("0"), is(true));
+ l = ((LeafNode) ll1Holder.child("0"));
+ assertThat(l.uri(), is("test-yang:cont1.cont2.list1[0].ll1[0]"));
+ assertThat(ll1Holder.children().containsKey("1"), is(true));
+ l = ((LeafNode) ll1Holder.child("1"));
+ assertThat(l.uri(), is("test-yang:cont1.cont2.list1[0].ll1[1]"));
+
+ LeafListHolderNode ll2Holder = ((LeafListHolderNode) list10Child.get("ll2"));
+ assertThat(ll2Holder.uri(), is("test-yang:cont1.cont2.list1[0].ll2"));
+ assertThat(ll2Holder.children().containsKey("0"), is(true));
+ l = ((LeafNode) ll2Holder.child("0"));
+ assertThat(l.uri(), is("test-yang:cont1.cont2.list1[0].ll2[0]"));
+ assertThat(ll2Holder.children().containsKey("1"), is(true));
+ l = ((LeafNode) ll2Holder.child("1"));
+ assertThat(l.uri(), is("test-yang:cont1.cont2.list1[0].ll2[1]"));
+
+ SingleInstanceNode cont4 = ((SingleInstanceNode) list10Child.get("cont4"));
+ assertThat(cont4.uri(), is("test-yang:cont1.cont2.list1[0].cont4"));
+ assertThat(cont4.children().containsKey("leaf11"), is(true));
+ l = ((LeafNode) cont4.children().get("leaf11"));
+ assertThat(l.uri(), is("test-yang:cont1.cont2.list1[0].cont4.leaf11"));
+
+ HolderNode list4Holder = ((HolderNode) list10Child.get("list4"));
+ assertThat(list4Holder.uri(), is("test-yang:cont1.cont2.list1[0].list4"));
+ Map<String, PropertiesNode> c = list4Holder.children();
+ MultiInstanceNode list40 = ((MultiInstanceNode) c.get("0"));
+ assertThat(list40.uri(), is("test-yang:cont1.cont2.list1[0].list4[0]"));
+ assertThat(list40.children().containsKey("leaf8"), is(true));
+ l = ((LeafNode) list40.children().get("leaf8"));
+ assertThat(l.uri(), is("test-yang:cont1.cont2.list1[0].list4[0].leaf8"));
+ MultiInstanceNode list41 = ((MultiInstanceNode) c.get("1"));
+ assertThat(list41.uri(), is("test-yang:cont1.cont2.list1[0].list4[1]"));
+ assertThat(list41.children().containsKey("leaf8"), is(true));
+ l = ((LeafNode) list41.children().get("leaf8"));
+ assertThat(l.uri(), is("test-yang:cont1.cont2.list1[0].list4[1].leaf8"));
+
+ HolderNode list5Holder = ((HolderNode) list10Child.get("list5"));
+ assertThat(list5Holder.uri(), is("test-yang:cont1.cont2.list1[0].list5"));
+ c = list5Holder.children();
+ MultiInstanceNode list50 = ((MultiInstanceNode) c.get("0"));
+ assertThat(list50.uri(), is("test-yang:cont1.cont2.list1[0].list5[0]"));
+ assertThat(list50.children().containsKey("leaf9"), is(true));
+ l = ((LeafNode) list50.children().get("leaf9"));
+ assertThat(l.uri(), is("test-yang:cont1.cont2.list1[0].list5[0].leaf9"));
+ MultiInstanceNode list51 = ((MultiInstanceNode) c.get("1"));
+ assertThat(list51.uri(), is("test-yang:cont1.cont2.list1[0].list5[1]"));
+ assertThat(list51.children().containsKey("leaf9"), is(true));
+ l = ((LeafNode) list51.children().get("leaf9"));
+ assertThat(l.uri(), is("test-yang:cont1.cont2.list1[0].list5[1].leaf9"));
+
+ MultiInstanceNode list11 = ((MultiInstanceNode) list1Holder.child("1"));
+ assertThat(list11.uri(), is("test-yang:cont1.cont2.list1[1]"));
+ Map<String, DataNodeChild> list11Child = list11.children();
+ assertThat(list11Child.containsKey("leaf1"), is(true));
+ l = ((LeafNode) list11Child.get("leaf1"));
+ assertThat(l.uri(), is("test-yang:cont1.cont2.list1[1].leaf1"));
+ assertThat(list11Child.containsKey("leaf2"), is(true));
+ l = ((LeafNode) list11Child.get("leaf2"));
+ assertThat(l.uri(), is("test-yang:cont1.cont2.list1[1].leaf2"));
+ assertThat(list11Child.containsKey("leaf3"), is(true));
+ l = ((LeafNode) list11Child.get("leaf3"));
+ assertThat(l.uri(), is("test-yang:cont1.cont2.list1[1].leaf3"));
+
+ ll1Holder = ((LeafListHolderNode) list11Child.get("ll1"));
+ assertThat(ll1Holder.uri(), is("test-yang:cont1.cont2.list1[1].ll1"));
+ assertThat(ll1Holder.children().containsKey("0"), is(true));
+ l = ((LeafNode) ll1Holder.children().get("0"));
+ assertThat(l.uri(), is("test-yang:cont1.cont2.list1[1].ll1[0]"));
+ assertThat(ll1Holder.children().containsKey("1"), is(true));
+ l = ((LeafNode) ll1Holder.children().get("1"));
+ assertThat(l.uri(), is("test-yang:cont1.cont2.list1[1].ll1[1]"));
+
+ ll2Holder = ((LeafListHolderNode) list11Child.get("ll2"));
+ assertThat(ll2Holder.uri(), is("test-yang:cont1.cont2.list1[1].ll2"));
+ assertThat(ll2Holder.children().containsKey("0"), is(true));
+ l = ((LeafNode) ll2Holder.children().get("0"));
+ assertThat(l.uri(), is("test-yang:cont1.cont2.list1[1].ll2[0]"));
+ assertThat(ll2Holder.children().containsKey("1"), is(true));
+ l = ((LeafNode) ll2Holder.children().get("1"));
+ assertThat(l.uri(), is("test-yang:cont1.cont2.list1[1].ll2[1]"));
+
+ cont4 = ((SingleInstanceNode) list11Child.get("cont4"));
+ assertThat(cont4.uri(), is("test-yang:cont1.cont2.list1[1].cont4"));
+ assertThat(cont4.children().containsKey("leaf11"), is(true));
+ l = ((LeafNode) cont4.children().get("leaf11"));
+ assertThat(l.uri(), is("test-yang:cont1.cont2.list1[1].cont4.leaf11"));
+
+ list4Holder = ((HolderNode) list11Child.get("list4"));
+ assertThat(list4Holder.uri(), is("test-yang:cont1.cont2.list1[1].list4"));
+ c = list4Holder.children();
+ list40 = ((MultiInstanceNode) c.get("0"));
+ assertThat(list40.uri(), is("test-yang:cont1.cont2.list1[1].list4[0]"));
+ assertThat(list40.children().containsKey("leaf8"), is(true));
+ l = ((LeafNode) list40.children().get("leaf8"));
+ assertThat(l.uri(), is("test-yang:cont1.cont2.list1[1].list4[0].leaf8"));
+ list41 = ((MultiInstanceNode) c.get("1"));
+ assertThat(list41.uri(), is("test-yang:cont1.cont2.list1[1].list4[1]"));
+ assertThat(list41.children().containsKey("leaf8"), is(true));
+ l = ((LeafNode) list41.children().get("leaf8"));
+ assertThat(l.uri(), is("test-yang:cont1.cont2.list1[1].list4[1].leaf8"));
+
+ list5Holder = ((HolderNode) list11Child.get("list5"));
+ assertThat(list5Holder.uri(), is("test-yang:cont1.cont2.list1[1].list5"));
+ c = list5Holder.children();
+ list50 = ((MultiInstanceNode) c.get("0"));
+ assertThat(list50.uri(), is("test-yang:cont1.cont2.list1[1].list5[0]"));
+ assertThat(list50.children().containsKey("leaf9"), is(true));
+ l = ((LeafNode) list50.children().get("leaf9"));
+ assertThat(l.uri(), is("test-yang:cont1.cont2.list1[1].list5[0].leaf9"));
+ list51 = ((MultiInstanceNode) c.get("1"));
+ assertThat(list51.uri(), is("test-yang:cont1.cont2.list1[1].list5[1]"));
+ assertThat(list51.children().containsKey("leaf9"), is(true));
+ l = ((LeafNode) list51.children().get("leaf9"));
+ assertThat(l.uri(), is("test-yang:cont1.cont2.list1[1].list5[1].leaf9"));
+
+ assertThat(childNodes.containsKey("list2"), is(true));
+ HolderNode list2Holder = ((HolderNode) childNodes.get("list2"));
+ assertThat(list2Holder.uri(), is("test-yang:cont1.cont2.list2"));
+ InnerNode list20 = ((InnerNode) list2Holder.children().get("0"));
+ assertThat(list20.uri(), is("test-yang:cont1.cont2.list2[0]"));
+ assertThat(list20.children().containsKey("leaf4"), is(true));
+ l = ((LeafNode) list20.children().get("leaf4"));
+ assertThat(l.uri(), is("test-yang:cont1.cont2.list2[0].leaf4"));
+ InnerNode list21 = ((InnerNode) list2Holder.children().get("1"));
+ assertThat(list21.uri(), is("test-yang:cont1.cont2.list2[1]"));
+ assertThat(list21.children().containsKey("leaf4"), is(true));
+ l = ((LeafNode) list21.children().get("leaf4"));
+ assertThat(l.uri(), is("test-yang:cont1.cont2.list2[1].leaf4"));
+
+ assertThat(childNodes.containsKey("leaf5"), is(true));
+ l = ((LeafNode) childNodes.get("leaf5"));
+ assertThat(l.uri(), is("test-yang:cont1.cont2.leaf5"));
+ assertThat(childNodes.containsKey("leaf6"), is(true));
+ l = ((LeafNode) childNodes.get("leaf6"));
+ assertThat(l.uri(), is("test-yang:cont1.cont2.leaf6"));
+
+ HolderNode ll3Holder = ((HolderNode) childNodes.get("ll3"));
+ assertThat(ll3Holder.uri(), is("test-yang:cont1.cont2.ll3"));
+ assertThat(((LeafNode) ll3Holder.children().get("0")).name(), is("ll3"));
+ l = ((LeafNode) ll3Holder.children().get("0"));
+ assertThat(l.uri(), is("test-yang:cont1.cont2.ll3[0]"));
+ assertThat(((LeafNode) ll3Holder.children().get("1")).name(), is("ll3"));
+ l = ((LeafNode) ll3Holder.children().get("1"));
+ assertThat(l.uri(), is("test-yang:cont1.cont2.ll3[1]"));
+
+ HolderNode ll4Holder = ((HolderNode) childNodes.get("ll4"));
+ assertThat(ll4Holder.uri(), is("test-yang:cont1.cont2.ll4"));
+ assertThat(((LeafNode) ll4Holder.children().get("0")).name(), is("ll4"));
+ l = ((LeafNode) ll4Holder.children().get("0"));
+ assertThat(l.uri(), is("test-yang:cont1.cont2.ll4[0]"));
+ assertThat(((LeafNode) ll4Holder.children().get("1")).name(), is("ll4"));
+ l = ((LeafNode) ll4Holder.children().get("1"));
+ assertThat(l.uri(), is("test-yang:cont1.cont2.ll4[1]"));
+
+ Map<String, String> output = ser.decode(node);
+ assertThat(output.size(), is(params.size()));
+ for (Map.Entry<String, String> entry : output.entrySet()) {
+ assertTrue(params.containsKey(entry.getKey()));
+ }
+ }
+
+ @Test
+ public void testAugment() throws SvcLogicException {
+ String uri = "test-yang:cont1/cont2";
+ Map<String, String> params = new HashMap<>();
+ params.put("test-yang_cont1.cont2.cont4.leaf10", "abc");
+ params.put("test-yang_cont1.cont2.cont4.test-augment_cont5.leaf13", "abc");
+ params.put("test-yang_cont1.cont2.cont4.test-augment_list7[0].leaf14", "abc");
+ params.put("test-yang_cont1.cont2.cont4.test-augment_list7[1].leaf14", "abc");
+ params.put("test-yang_cont1.cont2.cont4.test-augment_leaf15", "abc");
+ params.put("test-yang_cont1.cont2.cont4.test-augment_ll6[0]", "abc");
+ params.put("test-yang_cont1.cont2.cont4.test-augment_ll6[1]", "abc");
+ params.put("test-yang_cont1.cont2.list6[0].leaf11", "abc");
+ params.put("test-yang_cont1.cont2.list6[1].leaf11", "abc");
+ params.put("test-yang_cont1.cont2.leaf12", "abc");
+ params.put("test-yang_cont1.cont2.ll5[0]", "abc");
+ params.put("test-yang_cont1.cont2.ll5[1]", "abc");
+
+ InstanceIdentifierContext<?> iCtx = ParserIdentifier
+ .toInstanceIdentifier(uri, context, null);
+ PropertiesNodeSerializer ser = new MdsalPropertiesNodeSerializer(
+ iCtx.getSchemaNode(), context, uri);
+ PropertiesNode node = ser.encode(params);
+
+ Map<String, PropertiesNode> childNodes = ((RootNode) node).children();
+
+ assertThat(childNodes.containsKey("cont4"), is(true));
+ SingleInstanceNode cont4 = ((SingleInstanceNode) childNodes.get("cont4"));
+ for (Map.Entry<Object, Collection<PropertiesNode>> augToChild
+ : cont4.augmentations().asMap().entrySet()) {
+ Collection<PropertiesNode> child = augToChild.getValue();
+ if (!child.isEmpty()) {
+ List<String> expectedNodes = new LinkedList<>();
+ expectedNodes.add("test-yang:cont1.cont2.cont4.test-augment:cont5");
+ expectedNodes.add("test-yang:cont1.cont2.cont4.test-augment:list7");
+ expectedNodes.add("test-yang:cont1.cont2.cont4.test-augment:leaf15");
+ expectedNodes.add("test-yang:cont1.cont2.cont4.test-augment:ll6");
+ assertThat(expectedNodes.size(), is(child.size()));
+ for (PropertiesNode pNode : child) {
+ assertThat(expectedNodes.contains(pNode.uri()), is(true));
+ if (pNode.uri().equals("test-yang:cont1.cont2.cont4.test-augment:cont5")) {
+ assertThat(((SingleInstanceNode) pNode).children().containsKey("leaf13"), is(true));
+ LeafNode l = ((LeafNode) ((SingleInstanceNode) pNode).children().get("leaf13"));
+ assertThat(l.uri(), is("test-yang:cont1.cont2.cont4.test-augment:cont5.leaf13"));
+ } else if (pNode.uri().equals("test-yang:cont1.cont2.cont4.test-augment:list7")) {
+ ListHolderNode list7Holder = ((ListHolderNode) pNode);
+ MultiInstanceNode list7 = ((MultiInstanceNode) list7Holder.child("0"));
+ assertThat(list7.uri(), is("test-yang:cont1.cont2.cont4.test-augment:list7[0]"));
+ Map<String, DataNodeChild> list7Child = list7.children();
+ assertThat(list7Child.containsKey("leaf14"), is(true));
+ LeafNode l = ((LeafNode) list7Child.get("leaf14"));
+ assertThat(l.uri(), is("test-yang:cont1.cont2.cont4.test-augment:list7[0].leaf14"));
+ list7 = ((MultiInstanceNode) list7Holder.child("1"));
+ assertThat(list7.uri(), is("test-yang:cont1.cont2.cont4.test-augment:list7[1]"));
+ list7Child = list7.children();
+ assertThat(list7Child.containsKey("leaf14"), is(true));
+ l = ((LeafNode) list7Child.get("leaf14"));
+ assertThat(l.uri(), is("test-yang:cont1.cont2.cont4.test-augment:list7[1].leaf14"));
+ } else if (pNode.uri().equals("test-yang:cont1.cont2.cont4.test-augment:leaf15")) {
+ LeafNode leaf15 = ((LeafNode) pNode);
+ assertThat(leaf15.name(), is("leaf15"));
+ assertThat(leaf15.uri(), is("test-yang:cont1.cont2.cont4.test-augment:leaf15"));
+ } else if (pNode.uri().equals("test-yang:cont1.cont2.cont4.test-augment:ll6")) {
+ LeafListHolderNode ll6Holder = ((LeafListHolderNode) pNode);
+ assertThat(ll6Holder.children().containsKey("0"), is(true));
+ LeafNode l = ((LeafNode) ll6Holder.children().get("0"));
+ assertThat(l.uri(), is("test-yang:cont1.cont2.cont4.test-augment:ll6[0]"));
+ assertThat(ll6Holder.children().containsKey("1"), is(true));
+ l = ((LeafNode) ll6Holder.children().get("1"));
+ assertThat(l.uri(), is("test-yang:cont1.cont2.cont4.test-augment:ll6[1]"));
+ }
+ }
+ }
+ }
+ assertThat(cont4.uri(), is("test-yang:cont1.cont2.cont4"));
+ assertThat(cont4.children().containsKey("leaf10"), is(true));
+ LeafNode l = ((LeafNode) cont4.children().get("leaf10"));
+ assertThat(l.uri(), is("test-yang:cont1.cont2.cont4.leaf10"));
+
+ assertThat(childNodes.containsKey("list6"), is(true));
+ HolderNode list6Holder = ((ListHolderNode) childNodes.get("list6"));
+ assertThat(list6Holder.uri(), is("test-yang:cont1.cont2.list6"));
+ MultiInstanceNode list6 = ((MultiInstanceNode) list6Holder.child("0"));
+ assertThat(list6.uri(), is("test-yang:cont1.cont2.list6[0]"));
+ Map<String, DataNodeChild> list6Child = list6.children();
+ assertThat(list6Child.containsKey("leaf11"), is(true));
+ l = ((LeafNode) list6Child.get("leaf11"));
+ assertThat(l.uri(), is("test-yang:cont1.cont2.list6[0].leaf11"));
+ list6 = ((MultiInstanceNode) list6Holder.child("1"));
+ assertThat(list6.uri(), is("test-yang:cont1.cont2.list6[1]"));
+ list6Child = list6.children();
+ assertThat(list6Child.containsKey("leaf11"), is(true));
+ l = ((LeafNode) list6Child.get("leaf11"));
+ assertThat(l.uri(), is("test-yang:cont1.cont2.list6[1].leaf11"));
+
+ assertThat(childNodes.containsKey("leaf12"), is(true));
+ LeafNode leaf12 = ((LeafNode) childNodes.get("leaf12"));
+ assertThat(leaf12.name(), is("leaf12"));
+ assertThat(leaf12.uri(), is("test-yang:cont1.cont2.leaf12"));
+
+ LeafListHolderNode ll5Holder = ((LeafListHolderNode) childNodes.get("ll5"));
+ assertThat(ll5Holder.uri(), is("test-yang:cont1.cont2.ll5"));
+ assertThat(ll5Holder.children().containsKey("0"), is(true));
+ l = ((LeafNode) ll5Holder.children().get("0"));
+ assertThat(l.uri(), is("test-yang:cont1.cont2.ll5[0]"));
+ assertThat(ll5Holder.children().containsKey("1"), is(true));
+ l = ((LeafNode) ll5Holder.children().get("1"));
+ assertThat(l.uri(), is("test-yang:cont1.cont2.ll5[1]"));
+
+ Map<String, String> output = ser.decode(node);
+ for (Map.Entry<String, String> entry : output.entrySet()) {
+ assertTrue(params.containsKey(entry.getKey()));
+ }
+ }
+
+ @Test
+ public void testChoiceCase1() throws SvcLogicException {
+ String uri = "test-yang:cont8";
+ Map<String, String> params = new HashMap<>();
+ params.put("test-yang_cont8.cont6.leaf16", "abc");
+ params.put("test-yang_cont8.list8[0].leaf18", "abc");
+ params.put("test-yang_cont8.list8[1].leaf18", "abc");
+ params.put("test-yang_cont8.leaf19", "abc");
+ params.put("test-yang_cont8.ll7[0]", "abc");
+ params.put("test-yang_cont8.ll7[1]", "abc");
+
+ InstanceIdentifierContext<?> iCtx = ParserIdentifier
+ .toInstanceIdentifier(uri, context, null);
+ PropertiesNodeSerializer ser = new MdsalPropertiesNodeSerializer(
+ iCtx.getSchemaNode(), context, uri);
+ PropertiesNode node = ser.encode(params);
+
+ Map<String, PropertiesNode> childNodes = ((RootNode) node).children();
+
+ assertThat(childNodes.containsKey("cont6"), is(true));
+ SingleInstanceNode cont6 = ((SingleInstanceNode) childNodes.get("cont6"));
+ assertThat(cont6.uri(), is("test-yang:cont8.cont6"));
+ assertThat(cont6.children().containsKey("leaf16"), is(true));
+ LeafNode l = ((LeafNode) cont6.children().get("leaf16"));
+ assertThat(l.uri(), is("test-yang:cont8.cont6.leaf16"));
+
+ assertThat(childNodes.containsKey("list8"), is(true));
+ HolderNode list6Holder = ((ListHolderNode) childNodes.get("list8"));
+ assertThat(list6Holder.uri(), is("test-yang:cont8.list8"));
+ MultiInstanceNode list6 = ((MultiInstanceNode) list6Holder.child("0"));
+ assertThat(list6.uri(), is("test-yang:cont8.list8[0]"));
+ Map<String, DataNodeChild> list6Child = list6.children();
+ assertThat(list6Child.containsKey("leaf18"), is(true));
+ l = ((LeafNode) list6Child.get("leaf18"));
+ assertThat(l.uri(), is("test-yang:cont8.list8[0].leaf18"));
+ list6 = ((MultiInstanceNode) list6Holder.child("1"));
+ list6Child = list6.children();
+ assertThat(list6Child.containsKey("leaf18"), is(true));
+ l = ((LeafNode) list6Child.get("leaf18"));
+ assertThat(l.uri(), is("test-yang:cont8.list8[1].leaf18"));
+
+ assertThat(childNodes.containsKey("leaf19"), is(true));
+ LeafNode leaf12 = ((LeafNode) childNodes.get("leaf19"));
+ assertThat(leaf12.name(), is("leaf19"));
+ assertThat(leaf12.uri(), is("test-yang:cont8.leaf19"));
+
+ LeafListHolderNode ll5Holder = ((LeafListHolderNode) childNodes.get("ll7"));
+ assertThat(ll5Holder.uri(), is("test-yang:cont8.ll7"));
+ assertThat(ll5Holder.children().containsKey("0"), is(true));
+ l = ((LeafNode) ll5Holder.children().get("0"));
+ assertThat(l.uri(), is("test-yang:cont8.ll7[0]"));
+ assertThat(ll5Holder.children().containsKey("1"), is(true));
+ l = ((LeafNode) ll5Holder.children().get("1"));
+ assertThat(l.uri(), is("test-yang:cont8.ll7[1]"));
+
+ Map<String, String> output = ser.decode(node);
+ assertThat(output.size(), is(params.size()));
+ for (Map.Entry<String, String> entry : output.entrySet()) {
+ assertTrue(params.containsKey(entry.getKey()));
+ }
+ }
+
+ @Test
+ public void testChoiceCase2() throws SvcLogicException {
+ String uri = "test-yang:cont9";
+ Map<String, String> params = new HashMap<>();
+ params.put("test-yang_cont9.leaf20", "abc");
+ params.put("test-yang_cont9.ll8[0]", "abc");
+ params.put("test-yang_cont9.cont11.leaf25", "abc");
+
+ InstanceIdentifierContext<?> iCtx = ParserIdentifier
+ .toInstanceIdentifier(uri, context, null);
+ PropertiesNodeSerializer ser = new MdsalPropertiesNodeSerializer(
+ iCtx.getSchemaNode(), context, uri);
+ PropertiesNode node = ser.encode(params);
+
+ Map<String, PropertiesNode> childNodes = ((RootNode) node).children();
+
+ assertThat(childNodes.containsKey("cont11"), is(true));
+ SingleInstanceNode cont4 = ((SingleInstanceNode) childNodes.get("cont11"));
+ assertThat(cont4.uri(), is("test-yang:cont9.cont11"));
+ assertThat(cont4.children().containsKey("leaf25"), is(true));
+ LeafNode l = ((LeafNode) cont4.children().get("leaf25"));
+ assertThat(l.uri(), is("test-yang:cont9.cont11.leaf25"));
+
+ assertThat(childNodes.containsKey("leaf20"), is(true));
+ l = ((LeafNode) childNodes.get("leaf20"));
+ assertThat(l.uri(), is("test-yang:cont9.leaf20"));
+
+ LeafListHolderNode ll5Holder = ((LeafListHolderNode) childNodes.get("ll8"));
+ assertThat(ll5Holder.uri(), is("test-yang:cont9.ll8"));
+ assertThat(ll5Holder.children().containsKey("0"), is(true));
+ l = ((LeafNode) ll5Holder.children().get("0"));
+ assertThat(l.uri(), is("test-yang:cont9.ll8[0]"));
+
+ Map<String, String> output = ser.decode(node);
+ assertThat(output.size(), is(params.size()));
+ for (Map.Entry<String, String> entry : output.entrySet()) {
+ assertTrue(params.containsKey(entry.getKey()));
+ }
+ }
+
+ @Test
+ public void testChoiceCase3() throws SvcLogicException {
+ String uri = "test-yang:cont8/cont6";
+ Map<String, String> params = new HashMap<>();
+ params.put("test-yang_cont8.cont6.test-augment_leaf21", "abc");
+
+ InstanceIdentifierContext<?> iCtx = ParserIdentifier
+ .toInstanceIdentifier(uri, context, null);
+ PropertiesNodeSerializer ser = new MdsalPropertiesNodeSerializer(
+ iCtx.getSchemaNode(), context, uri);
+ PropertiesNode node = ser.encode(params);
+
+ for (Map.Entry<Object, Collection<PropertiesNode>> augToChild
+ : node.augmentations().asMap().entrySet()) {
+ Collection<PropertiesNode> child = augToChild.getValue();
+ if (!child.isEmpty()) {
+ List<String> expectedNodes = new LinkedList<>();
+ expectedNodes.add("test-yang:cont8.cont6.test-augment:leaf21");
+ assertThat(expectedNodes.size(), is(child.size()));
+ for (PropertiesNode pNode : child) {
+ assertThat(expectedNodes.contains(pNode.uri()), is(true));
+ }
+ }
+ }
+
+ Map<String, PropertiesNode> childNodes = ((RootNode) node).children();
+
+ assertThat(childNodes.containsKey("leaf21"), is(true));
+ LeafNode leaf12 = ((LeafNode) childNodes.get("leaf21"));
+ assertThat(leaf12.name(), is("leaf21"));
+ assertThat(leaf12.uri(), is("test-yang:cont8.cont6.test-augment:leaf21"));
+
+ Map<String, String> output = ser.decode(node);
+ assertThat(output.size(), is(params.size()));
+ for (Map.Entry<String, String> entry : output.entrySet()) {
+ assertTrue(params.containsKey(entry.getKey()));
+ }
+ }
+
+ @Test
+ public void testGrouping() throws SvcLogicException {
+ String uri = "test-yang:cont13";
+ Map<String, String> params = new HashMap<>();
+ params.put("test-yang_cont13.cont12.leaf26", "abc");
+ params.put("test-yang_cont13.list9[0].leaf27", "abc");
+ params.put("test-yang_cont13.leaf28", "abc");
+ params.put("test-yang_cont13.ll9[0]", "abc");
+
+ InstanceIdentifierContext<?> iCtx = ParserIdentifier
+ .toInstanceIdentifier(uri, context, null);
+ PropertiesNodeSerializer ser = new MdsalPropertiesNodeSerializer(
+ iCtx.getSchemaNode(), context, uri);
+ PropertiesNode node = ser.encode(params);
+
+ Map<String, PropertiesNode> childNodes = ((RootNode) node).children();
+
+ assertThat(childNodes.containsKey("cont12"), is(true));
+ SingleInstanceNode cont4 = ((SingleInstanceNode) childNodes.get("cont12"));
+ assertThat(cont4.uri(), is("test-yang:cont13.cont12"));
+ assertThat(cont4.children().containsKey("leaf26"), is(true));
+ LeafNode l = ((LeafNode) cont4.children().get("leaf26"));
+ assertThat(l.uri(), is("test-yang:cont13.cont12.leaf26"));
+
+ assertThat(childNodes.containsKey("list9"), is(true));
+ HolderNode list6Holder = ((ListHolderNode) childNodes.get("list9"));
+ assertThat(list6Holder.uri(), is("test-yang:cont13.list9"));
+ MultiInstanceNode list6 = ((MultiInstanceNode) list6Holder.child("0"));
+ assertThat(list6.uri(), is("test-yang:cont13.list9[0]"));
+ Map<String, DataNodeChild> list6Child = list6.children();
+ assertThat(list6Child.containsKey("leaf27"), is(true));
+ l = ((LeafNode) list6Child.get("leaf27"));
+ assertThat(l.uri(), is("test-yang:cont13.list9[0].leaf27"));
+
+ assertThat(childNodes.containsKey("leaf28"), is(true));
+ LeafNode leaf12 = ((LeafNode) childNodes.get("leaf28"));
+ assertThat(leaf12.name(), is("leaf28"));
+ assertThat(leaf12.uri(), is("test-yang:cont13.leaf28"));
+
+ LeafListHolderNode ll5Holder = ((LeafListHolderNode) childNodes.get("ll9"));
+ assertThat(ll5Holder.children().containsKey("0"), is(true));
+
+ Map<String, String> output = ser.decode(node);
+ assertThat(output.size(), is(params.size()));
+ for (Map.Entry<String, String> entry : output.entrySet()) {
+ assertTrue(params.containsKey(entry.getKey()));
+ }
+ }
+
+ @Test
+ public void testGrouping2() throws SvcLogicException {
+ String uri = "test-yang:cont9/cont11";
+ Map<String, String> params = new HashMap<>();
+ params.put("test-yang_cont9.cont11.leaf25", "abc");
+ params.put("test-yang_cont9.cont11.cont13.cont12.leaf26", "abc");
+ params.put("test-yang_cont9.cont11.cont13.list9[0].leaf27", "abc");
+ params.put("test-yang_cont9.cont11.cont13.leaf28", "abc");
+ params.put("test-yang_cont9.cont11.cont13.ll9[0]", "abc");
+ InstanceIdentifierContext<?> iCtx = ParserIdentifier
+ .toInstanceIdentifier(uri, context, null);
+ PropertiesNodeSerializer ser = new MdsalPropertiesNodeSerializer(
+ iCtx.getSchemaNode(), context, uri);
+ PropertiesNode node = ser.encode(params);
+
+ Map<String, PropertiesNode> childNodes = ((RootNode) node).children();
+
+ assertThat(childNodes.containsKey("cont13"), is(true));
+ SingleInstanceNode cont13 = ((SingleInstanceNode) childNodes.get("cont13"));
+ assertThat(cont13.uri(), is("test-yang:cont9.cont11.cont13"));
+ SingleInstanceNode cont12 = ((SingleInstanceNode) cont13.children().get("cont12"));
+ assertThat(cont12.children().containsKey("leaf26"), is(true));
+ assertThat(cont12.uri(), is("test-yang:cont9.cont11.cont13.cont12"));
+ assertThat(cont12.children().containsKey("leaf26"), is(true));
+ LeafNode l = ((LeafNode) cont12.children().get("leaf26"));
+ assertThat(l.uri(), is("test-yang:cont9.cont11.cont13.cont12.leaf26"));
+
+ assertThat(cont13.children().containsKey("list9"), is(true));
+ HolderNode list6Holder = ((ListHolderNode) cont13.children().get("list9"));
+ assertThat(list6Holder.uri(), is("test-yang:cont9.cont11.cont13.list9"));
+ MultiInstanceNode list6 = ((MultiInstanceNode) list6Holder.child("0"));
+ assertThat(list6.uri(), is("test-yang:cont9.cont11.cont13.list9[0]"));
+ Map<String, DataNodeChild> list6Child = list6.children();
+ assertThat(list6Child.containsKey("leaf27"), is(true));
+ l = ((LeafNode) list6Child.get("leaf27"));
+ assertThat(l.uri(), is("test-yang:cont9.cont11.cont13.list9[0].leaf27"));
+
+ assertThat(cont13.children().containsKey("leaf28"), is(true));
+ LeafNode leaf12 = ((LeafNode) cont13.children().get("leaf28"));
+ assertThat(leaf12.name(), is("leaf28"));
+ assertThat(leaf12.uri(), is("test-yang:cont9.cont11.cont13.leaf28"));
+
+ LeafListHolderNode ll5Holder = ((LeafListHolderNode) cont13.children().get("ll9"));
+ assertThat(ll5Holder.uri(), is("test-yang:cont9.cont11.cont13.ll9"));
+ assertThat(ll5Holder.children().containsKey("0"), is(true));
+ l = ((LeafNode) ll5Holder.children().get("0"));
+ assertThat(l.uri(), is("test-yang:cont9.cont11.cont13.ll9[0]"));
+
+ Map<String, String> output = ser.decode(node);
+ assertThat(output.size(), is(params.size()));
+ for (Map.Entry<String, String> entry : output.entrySet()) {
+ assertTrue(params.containsKey(entry.getKey()));
+ }
+ }
+
+ @Test
+ public void testGrouping3() throws SvcLogicException {
+ String uri = "test-augment:cont13";
+ Map<String, String> params = new HashMap<>();
+ params.put("test-augment_cont13.cont12.leaf26", "abc");
+ params.put("test-augment_cont13.list9[0].leaf27", "abc");
+ params.put("test-augment_cont13.leaf28", "abc");
+ params.put("test-augment_cont13.ll9[0]", "abc");
+ InstanceIdentifierContext<?> iCtx = ParserIdentifier
+ .toInstanceIdentifier(uri, context, null);
+ PropertiesNodeSerializer ser = new MdsalPropertiesNodeSerializer(
+ iCtx.getSchemaNode(), context, uri);
+ PropertiesNode node = ser.encode(params);
+
+ Map<String, PropertiesNode> childNodes = ((RootNode) node).children();
+
+ assertThat(childNodes.containsKey("cont12"), is(true));
+ SingleInstanceNode cont12 = ((SingleInstanceNode) childNodes.get("cont12"));
+ assertThat(cont12.uri(), is("test-augment:cont13.cont12"));
+ assertThat(cont12.children().containsKey("leaf26"), is(true));
+ LeafNode l = ((LeafNode) cont12.children().get("leaf26"));
+ assertThat(l.uri(), is("test-augment:cont13.cont12.leaf26"));
+
+ assertThat(childNodes.containsKey("list9"), is(true));
+ HolderNode list6Holder = ((ListHolderNode) childNodes.get("list9"));
+ assertThat(list6Holder.uri(), is("test-augment:cont13.list9"));
+ MultiInstanceNode list6 = ((MultiInstanceNode) list6Holder.child("0"));
+ assertThat(list6.uri(), is("test-augment:cont13.list9[0]"));
+ Map<String, DataNodeChild> list6Child = list6.children();
+ assertThat(list6Child.containsKey("leaf27"), is(true));
+ l = ((LeafNode) list6Child.get("leaf27"));
+ assertThat(l.uri(), is("test-augment:cont13.list9[0].leaf27"));
+
+ assertThat(childNodes.containsKey("leaf28"), is(true));
+ LeafNode leaf12 = ((LeafNode) childNodes.get("leaf28"));
+ assertThat(leaf12.name(), is("leaf28"));
+ assertThat(leaf12.uri(), is("test-augment:cont13.leaf28"));
+
+ LeafListHolderNode ll5Holder = ((LeafListHolderNode) childNodes.get("ll9"));
+ assertThat(ll5Holder.uri(), is("test-augment:cont13.ll9"));
+ assertThat(ll5Holder.children().containsKey("0"), is(true));
+ l = ((LeafNode) ll5Holder.children().get("0"));
+ assertThat(l.uri(), is("test-augment:cont13.ll9[0]"));
+
+ Map<String, String> output = ser.decode(node);
+ assertThat(output.size(), is(params.size()));
+ for (Map.Entry<String, String> entry : output.entrySet()) {
+ assertTrue(params.containsKey(entry.getKey()));
+ }
+ }
+
+ @Test
+ public void testGrouping4() throws SvcLogicException {
+ String uri = "test-yang:cont1/cont2/cont4";
+ Map<String, String> params = new HashMap<>();
+ params.put("test-yang_cont1.cont2.cont4.test-augment_cont13.cont12.leaf26", "abc");
+ params.put("test-yang_cont1.cont2.cont4.test-augment_cont13.list9[0].leaf27", "abc");
+ params.put("test-yang_cont1.cont2.cont4.test-augment_cont13.leaf28", "abc");
+ params.put("test-yang_cont1.cont2.cont4.test-augment_cont13.ll9[0]", "abc");
+
+ InstanceIdentifierContext<?> iCtx = ParserIdentifier
+ .toInstanceIdentifier(uri, context, null);
+ PropertiesNodeSerializer ser = new MdsalPropertiesNodeSerializer(
+ iCtx.getSchemaNode(), context, uri);
+ PropertiesNode node = ser.encode(params);
+
+ for (Map.Entry<Object, Collection<PropertiesNode>> augToChild
+ : node.augmentations().asMap().entrySet()) {
+ Collection<PropertiesNode> child = augToChild.getValue();
+ if (!child.isEmpty()) {
+ List<String> expectedNodes = new LinkedList<>();
+ expectedNodes.add("test-yang:cont1.cont2.cont4.test-augment:cont13");
+ assertThat(expectedNodes.size(), is(child.size()));
+ for (PropertiesNode pNode : child) {
+ assertThat(expectedNodes.contains(pNode.uri()), is(true));
+ SingleInstanceNode cont13 = ((SingleInstanceNode) pNode);
+ assertThat(cont13.uri(), is("test-yang:cont1.cont2.cont4.test-augment:cont13"));
+ SingleInstanceNode cont12 = ((SingleInstanceNode) cont13.children().get("cont12"));
+ assertThat(cont12.children().containsKey("leaf26"), is(true));
+ LeafNode l = ((LeafNode) cont12.children().get("leaf26"));
+ assertThat(l.uri(), is("test-yang:cont1.cont2.cont4.test-augment:cont13.cont12.leaf26"));
+
+ assertThat(cont13.children().containsKey("list9"), is(true));
+ HolderNode list6Holder = ((ListHolderNode) cont13.children().get("list9"));
+ assertThat(list6Holder.uri(), is("test-yang:cont1.cont2.cont4.test-augment:cont13.list9"));
+ MultiInstanceNode list6 = ((MultiInstanceNode) list6Holder.child("0"));
+ assertThat(list6.uri(), is("test-yang:cont1.cont2.cont4.test-augment:cont13.list9[0]"));
+ Map<String, DataNodeChild> list6Child = list6.children();
+ assertThat(list6Child.containsKey("leaf27"), is(true));
+ l = ((LeafNode) list6Child.get("leaf27"));
+ assertThat(l.uri(), is("test-yang:cont1.cont2.cont4.test-augment:cont13.list9[0].leaf27"));
+
+ assertThat(cont13.children().containsKey("leaf28"), is(true));
+ LeafNode leaf12 = ((LeafNode) cont13.children().get("leaf28"));
+ assertThat(leaf12.name(), is("leaf28"));
+ assertThat(leaf12.uri(), is("test-yang:cont1.cont2.cont4.test-augment:cont13.leaf28"));
+
+ LeafListHolderNode ll5Holder = ((LeafListHolderNode) cont13.children().get("ll9"));
+ assertThat(ll5Holder.uri(), is("test-yang:cont1.cont2.cont4.test-augment:cont13.ll9"));
+ assertThat(ll5Holder.children().containsKey("0"), is(true));
+ l = ((LeafNode) ll5Holder.children().get("0"));
+ assertThat(l.uri(), is("test-yang:cont1.cont2.cont4.test-augment:cont13.ll9[0]"));
+ }
+ }
+ }
+
+ Map<String, String> output = ser.decode(node);
+ assertThat(output.size(), is(params.size()));
+ for (Map.Entry<String, String> entry : output.entrySet()) {
+ assertTrue(params.containsKey(entry.getKey()));
+ }
+ }
+
+ @Test
+ public void testRpcInput() throws SvcLogicException {
+ String uri = "test-yang:create-sfc";
+ Map<String, String> params = new HashMap<>();
+ params.put("test-yang_create-sfc.input.cont14.leaf28", "abc");
+ params.put("test-yang_create-sfc.input.list10[0].leaf29", "abc");
+ params.put("test-yang_create-sfc.input.leaf30", "abc");
+ params.put("test-yang_create-sfc.input.ll10[0]", "abc");
+ params.put("test-yang_create-sfc.input.cont15.leaf31", "abc");
+ params.put("test-yang_create-sfc.input.cont13.cont12.leaf26", "abc");
+ params.put("test-yang_create-sfc.input.cont13.list9[0].leaf27", "abc");
+ params.put("test-yang_create-sfc.input.cont13.leaf28", "abc");
+ params.put("test-yang_create-sfc.input.cont13.ll9[0]", "abc");
+ params.put("test-yang_create-sfc.input.test-augment_leaf36", "abc");
+
+ InstanceIdentifierContext<?> iCtx = ParserIdentifier
+ .toInstanceIdentifier(uri, context, null);
+ PropertiesNodeSerializer ser = new MdsalPropertiesNodeSerializer(
+ iCtx.getSchemaNode(), context, uri);
+ PropertiesNode node = ser.encode(params);
+
+ Map<String, PropertiesNode> childNodes = ((RootNode) node).children();
+
+ PropertiesNode input = childNodes.get("input");
+ assertThat(input.uri(), is("test-yang:create-sfc.input"));
+ for (Map.Entry<Object, Collection<PropertiesNode>> augToChild
+ : node.augmentations().asMap().entrySet()) {
+ Collection<PropertiesNode> child = augToChild.getValue();
+ if (!child.isEmpty()) {
+ List<String> expectedNodes = new LinkedList<>();
+ expectedNodes.add("test-yang:create-sfc.input.test-augment:leaf36");
+ assertThat(expectedNodes.size(), is(child.size()));
+ for (PropertiesNode pNode : child) {
+ assertThat(expectedNodes.contains(pNode.uri()), is(true));
+ LeafNode leaf37 = ((LeafNode) pNode);
+ assertThat(leaf37.name(), is("leaf36"));
+ assertThat(leaf37.uri(), is("test-yang:create-sfc.input.test-augment:leaf36"));
+ }
+ }
+ }
+ childNodes = ((InnerNode) input).children();
+
+ assertThat(childNodes.containsKey("cont14"), is(true));
+ SingleInstanceNode cont14 = ((SingleInstanceNode) childNodes.get("cont14"));
+ assertThat(cont14.uri(), is("test-yang:create-sfc.input.cont14"));
+ assertThat(cont14.children().containsKey("leaf28"), is(true));
+ LeafNode l = ((LeafNode) cont14.children().get("leaf28"));
+ assertThat(l.uri(), is("test-yang:create-sfc.input.cont14.leaf28"));
+
+ assertThat(childNodes.containsKey("list10"), is(true));
+ HolderNode list10Holder = ((ListHolderNode) childNodes.get("list10"));
+ assertThat(list10Holder.uri(), is("test-yang:create-sfc.input.list10"));
+ MultiInstanceNode list10 = ((MultiInstanceNode) list10Holder.child("0"));
+ assertThat(list10.uri(), is("test-yang:create-sfc.input.list10[0]"));
+ Map<String, DataNodeChild> list10Child = list10.children();
+ assertThat(list10Child.containsKey("leaf29"), is(true));
+ l = ((LeafNode) list10Child.get("leaf29"));
+ assertThat(l.uri(), is("test-yang:create-sfc.input.list10[0].leaf29"));
+
+ assertThat(childNodes.containsKey("leaf30"), is(true));
+ LeafNode leaf30 = ((LeafNode) childNodes.get("leaf30"));
+ assertThat(leaf30.name(), is("leaf30"));
+ assertThat(leaf30.uri(), is("test-yang:create-sfc.input.leaf30"));
+
+ LeafListHolderNode ll10Holder = ((LeafListHolderNode) childNodes.get("ll10"));
+ assertThat(ll10Holder.uri(), is("test-yang:create-sfc.input.ll10"));
+ assertThat(ll10Holder.children().containsKey("0"), is(true));
+ l = ((LeafNode) ll10Holder.children().get("0"));
+ assertThat(l.uri(), is("test-yang:create-sfc.input.ll10[0]"));
+
+ assertThat(childNodes.containsKey("cont15"), is(true));
+ SingleInstanceNode cont15 = ((SingleInstanceNode) childNodes.get("cont15"));
+ assertThat(cont15.uri(), is("test-yang:create-sfc.input.cont15"));
+ assertThat(cont15.children().containsKey("leaf31"), is(true));
+ l = ((LeafNode) cont15.children().get("leaf31"));
+ assertThat(l.uri(), is("test-yang:create-sfc.input.cont15.leaf31"));
+
+ assertThat(childNodes.containsKey("cont13"), is(true));
+ SingleInstanceNode cont13 = ((SingleInstanceNode) childNodes.get("cont13"));
+ assertThat(cont13.uri(), is("test-yang:create-sfc.input.cont13"));
+ SingleInstanceNode cont12 = ((SingleInstanceNode) cont13.children().get("cont12"));
+ assertThat(cont12.uri(), is("test-yang:create-sfc.input.cont13.cont12"));
+ assertThat(cont12.children().containsKey("leaf26"), is(true));
+ l = ((LeafNode) cont12.children().get("leaf26"));
+ assertThat(l.uri(), is("test-yang:create-sfc.input.cont13.cont12.leaf26"));
+
+ assertThat(cont13.children().containsKey("list9"), is(true));
+ HolderNode list9Holder = ((ListHolderNode) cont13.children().get("list9"));
+ assertThat(list9Holder.uri(), is("test-yang:create-sfc.input.cont13.list9"));
+ MultiInstanceNode list9 = ((MultiInstanceNode) list9Holder.child("0"));
+ assertThat(list9.uri(), is("test-yang:create-sfc.input.cont13.list9[0]"));
+ Map<String, DataNodeChild> list6Child = list9.children();
+ assertThat(list6Child.containsKey("leaf27"), is(true));
+ l = ((LeafNode) list6Child.get("leaf27"));
+ assertThat(l.uri(), is("test-yang:create-sfc.input.cont13.list9[0].leaf27"));
+
+ assertThat(cont13.children().containsKey("leaf28"), is(true));
+ LeafNode leaf12 = ((LeafNode) cont13.children().get("leaf28"));
+ assertThat(leaf12.name(), is("leaf28"));
+ assertThat(leaf12.uri(), is("test-yang:create-sfc.input.cont13.leaf28"));
+
+ LeafListHolderNode ll5Holder = ((LeafListHolderNode) cont13.children().get("ll9"));
+ assertThat(ll5Holder.uri(), is("test-yang:create-sfc.input.cont13.ll9"));
+ assertThat(ll5Holder.children().containsKey("0"), is(true));
+ l = ((LeafNode) ll5Holder.children().get("0"));
+ assertThat(l.uri(), is("test-yang:create-sfc.input.cont13.ll9[0]"));
+
+ Map<String, String> output = ser.decode(node);
+ assertThat(output.size(), is(params.size()));
+ for (Map.Entry<String, String> entry : output.entrySet()) {
+ assertTrue(params.containsKey(entry.getKey()));
+ }
+ }
+
+ @Test
+ public void testRpcOutput() throws SvcLogicException {
+ String uri = "test-yang:create-sfc";
+ Map<String, String> params = new HashMap<>();
+ params.put("test-yang_create-sfc.output.cont16.leaf32", "abc");
+ params.put("test-yang_create-sfc.output.list11[0].leaf33", "abc");
+ params.put("test-yang_create-sfc.output.leaf34", "abc");
+ params.put("test-yang_create-sfc.output.ll11[0]", "abc");
+ params.put("test-yang_create-sfc.output.cont17.leaf35", "abc");
+ params.put("test-yang_create-sfc.output.cont13.cont12.leaf26", "abc");
+ params.put("test-yang_create-sfc.output.cont13.list9[0].leaf27", "abc");
+ params.put("test-yang_create-sfc.output.cont13.leaf28", "abc");
+ params.put("test-yang_create-sfc.output.cont13.ll9[0]", "abc");
+ params.put("test-yang_create-sfc.output.test-augment_leaf37", "abc");
+
+ InstanceIdentifierContext<?> iCtx = ParserIdentifier
+ .toInstanceIdentifier(uri, context, null);
+ PropertiesNodeSerializer ser = new MdsalPropertiesNodeSerializer(
+ iCtx.getSchemaNode(), context, uri);
+ PropertiesNode node = ser.encode(params);
+
+ Map<String, PropertiesNode> childNodes = ((RootNode) node).children();
+
+ PropertiesNode output = childNodes.get("output");
+ assertThat(output.uri(), is("test-yang:create-sfc.output"));
+ for (Map.Entry<Object, Collection<PropertiesNode>> augmentationToChild :
+ node.augmentations().asMap().entrySet()) {
+ Collection<PropertiesNode> c = augmentationToChild.getValue();
+ if(!c.isEmpty()) {
+ List<String> expectedNodes = new LinkedList<>();
+ expectedNodes.add("test-yang:create-sfc.output.test-augment:leaf37");
+ assertThat(expectedNodes.size(), is(expectedNodes));
+ for (PropertiesNode pNode : c) {
+ assertThat(expectedNodes.contains(pNode.uri()), is(true));
+ LeafNode leaf37 = ((LeafNode) pNode);
+ assertThat(leaf37.name(), is("leaf37"));
+ assertThat(leaf37.uri(), is("test-yang:create-sfc.output.test-augment:leaf37"));
+ }
+ }
+ }
+ childNodes = ((InnerNode) output).children();
+
+ assertThat(childNodes.containsKey("cont16"), is(true));
+ SingleInstanceNode cont16 = ((SingleInstanceNode) childNodes.get("cont16"));
+ assertThat(cont16.uri(), is("test-yang:create-sfc.output.cont16"));
+ assertThat(cont16.children().containsKey("leaf32"), is(true));
+ LeafNode l = ((LeafNode) cont16.children().get("leaf32"));
+ assertThat(l.uri(), is("test-yang:create-sfc.output.cont16.leaf32"));
+
+ assertThat(childNodes.containsKey("list11"), is(true));
+ HolderNode list11Holder = ((ListHolderNode) childNodes.get("list11"));
+ assertThat(list11Holder.uri(), is("test-yang:create-sfc.output.list11"));
+ MultiInstanceNode list11 = ((MultiInstanceNode) list11Holder.child("0"));
+ assertThat(list11.uri(), is("test-yang:create-sfc.output.list11[0]"));
+ Map<String, DataNodeChild> list11Child = list11.children();
+ assertThat(list11Child.containsKey("leaf33"), is(true));
+ l = ((LeafNode) list11Child.get("leaf33"));
+ assertThat(l.uri(), is("test-yang:create-sfc.output.list11[0].leaf33"));
+
+ assertThat(childNodes.containsKey("leaf34"), is(true));
+ LeafNode leaf34 = ((LeafNode) childNodes.get("leaf34"));
+ assertThat(leaf34.name(), is("leaf34"));
+ assertThat(leaf34.uri(), is("test-yang:create-sfc.output.leaf34"));
+
+ LeafListHolderNode ll10Holder = ((LeafListHolderNode) childNodes.get("ll11"));
+ assertThat(ll10Holder.uri(), is("test-yang:create-sfc.output.ll11"));
+ assertThat(ll10Holder.children().containsKey("0"), is(true));
+ l = ((LeafNode) ll10Holder.children().get("0"));
+ assertThat(l.uri(), is("test-yang:create-sfc.output.ll11[0]"));
+
+ assertThat(childNodes.containsKey("cont17"), is(true));
+ SingleInstanceNode cont17 = ((SingleInstanceNode) childNodes.get("cont17"));
+ assertThat(cont17.uri(), is("test-yang:create-sfc.output.cont17"));
+ assertThat(cont17.children().containsKey("leaf35"), is(true));
+ l = ((LeafNode) cont17.children().get("leaf35"));
+ assertThat(l.uri(), is("test-yang:create-sfc.output.cont17.leaf35"));
+
+ assertThat(childNodes.containsKey("cont13"), is(true));
+ SingleInstanceNode cont13 = ((SingleInstanceNode) childNodes.get("cont13"));
+ assertThat(cont13.uri(), is("test-yang:create-sfc.output.cont13"));
+ SingleInstanceNode cont12 = ((SingleInstanceNode) cont13.children().get("cont12"));
+ assertThat(cont12.uri(), is("test-yang:create-sfc.output.cont13.cont12"));
+ assertThat(cont12.children().containsKey("leaf26"), is(true));
+ l = ((LeafNode) cont12.children().get("leaf26"));
+ assertThat(l.uri(), is("test-yang:create-sfc.output.cont13.cont12.leaf26"));
+
+ assertThat(cont13.children().containsKey("list9"), is(true));
+ HolderNode list9Holder = ((ListHolderNode) cont13.children().get("list9"));
+ assertThat(list9Holder.uri(), is("test-yang:create-sfc.output.cont13.list9"));
+ MultiInstanceNode list9 = ((MultiInstanceNode) list9Holder.child("0"));
+ assertThat(list9.uri(), is("test-yang:create-sfc.output.cont13.list9[0]"));
+ Map<String, DataNodeChild> list6Child = list9.children();
+ assertThat(list6Child.containsKey("leaf27"), is(true));
+ l = ((LeafNode) list6Child.get("leaf27"));
+ assertThat(l.uri(), is("test-yang:create-sfc.output.cont13.list9[0].leaf27"));
+
+ assertThat(cont13.children().containsKey("leaf28"), is(true));
+ LeafNode leaf12 = ((LeafNode) cont13.children().get("leaf28"));
+ assertThat(leaf12.name(), is("leaf28"));
+ assertThat(leaf12.uri(), is("test-yang:create-sfc.output.cont13.leaf28"));
+
+ LeafListHolderNode ll5Holder = ((LeafListHolderNode) cont13.children().get("ll9"));
+ assertThat(ll5Holder.uri(), is("test-yang:create-sfc.output.cont13.ll9"));
+ assertThat(ll5Holder.children().containsKey("0"), is(true));
+ l = ((LeafNode) ll5Holder.children().get("0"));
+ assertThat(l.uri(), is("test-yang:create-sfc.output.cont13.ll9[0]"));
+
+ Map<String, String> output1 = ser.decode(node);
+ assertThat(output1.size(), is(params.size()));
+ for (Map.Entry<String, String> entry : output1.entrySet()) {
+ assertTrue(params.containsKey(entry.getKey()));
+ }
+ }
+
+ @Test
+ public void testContainerSameName() throws SvcLogicException {
+ String uri = "test-yang:cont18";
+ Map<String, String> params = new HashMap<>();
+ params.put("test-yang_cont18.cont18.list12[0].list12[0].leaf36", "abc");
+ params.put("test-yang_cont18.cont18.list12[0].leaf36", "hi");
+ params.put("test-yang_cont18.cont18.list12[1].list12[0].leaf36", "xyz");
+ params.put("test-yang_cont18.cont18.list12[1].list12[1].leaf36", "hey!");
+
+ InstanceIdentifierContext<?> iCtx = ParserIdentifier
+ .toInstanceIdentifier(uri, context, null);
+ PropertiesNodeSerializer ser = new MdsalPropertiesNodeSerializer(
+ iCtx.getSchemaNode(), context, uri);
+ PropertiesNode node = ser.encode(params);
+
+ Map<String, PropertiesNode> childNodes = ((RootNode) node).children();
+
+ assertThat(childNodes.containsKey("cont18"), is(true));
+ node = childNodes.get("cont18");
+ assertThat(node.uri(), is("test-yang:cont18.cont18"));
+ childNodes = ((InnerNode) node).children();
+
+ assertThat(childNodes.containsKey("list12"), is(true));
+ HolderNode holder = ((ListHolderNode) childNodes.get("list12"));
+ assertThat(holder.uri(), is("test-yang:cont18.cont18.list12"));
+ MultiInstanceNode node1 = ((MultiInstanceNode) holder.child("0"));
+ assertThat(node1.uri(), is("test-yang:cont18.cont18.list12[0]"));
+ Map<String, DataNodeChild> list12Child = node1.children();
+
+ assertThat(list12Child.containsKey("leaf36"), is(true));
+ LeafNode leaf = ((LeafNode) list12Child.get("leaf36"));
+ assertThat(leaf.value(), is("hi"));
+ assertThat(leaf.uri(), is("test-yang:cont18.cont18.list12[0].leaf36"));
+
+ assertThat(list12Child.containsKey("list12"), is(true));
+ HolderNode holder1 = ((ListHolderNode) list12Child.get("list12"));
+ assertThat(holder1.uri(), is("test-yang:cont18.cont18.list12[0].list12"));
+ node1 = ((MultiInstanceNode) holder1.child("0"));
+ assertThat(node1.uri(), is("test-yang:cont18.cont18.list12[0].list12[0]"));
+ list12Child = node1.children();
+ assertThat(list12Child.containsKey("leaf36"), is(true));
+ leaf = ((LeafNode) list12Child.get("leaf36"));
+ assertThat(leaf.value(), is("abc"));
+ assertThat(leaf.uri(), is("test-yang:cont18.cont18.list12[0].list12[0].leaf36"));
+
+ node1 = ((MultiInstanceNode) holder.child("1"));
+ assertThat(node1.uri(), is("test-yang:cont18.cont18.list12[1]"));
+ list12Child = node1.children();
+ assertThat(list12Child.containsKey("list12"), is(true));
+ holder = ((ListHolderNode) list12Child.get("list12"));
+ assertThat(holder.uri(), is("test-yang:cont18.cont18.list12[1].list12"));
+ node1 = ((MultiInstanceNode) holder.child("0"));
+ assertThat(node1.uri(), is("test-yang:cont18.cont18.list12[1].list12[0]"));
+ assertThat(node1.children().containsKey("leaf36"), is(true));
+ leaf = ((LeafNode) node1.children().get("leaf36"));
+ assertThat(leaf.value(), is("xyz"));
+ assertThat(leaf.uri(), is("test-yang:cont18.cont18.list12[1].list12[0].leaf36"));
+
+ node1 = ((MultiInstanceNode) holder.child("1"));
+ assertThat(node1.uri(), is("test-yang:cont18.cont18.list12[1].list12[1]"));
+ assertThat(node1.children().containsKey("leaf36"), is(true));
+ leaf = ((LeafNode) node1.children().get("leaf36"));
+ assertThat(leaf.value(), is("hey!"));
+ assertThat(leaf.uri(), is("test-yang:cont18.cont18.list12[1].list12[1].leaf36"));
+
+ Map<String, String> output1 = ser.decode(node);
+ assertThat(output1.size(), is(params.size()));
+ for (Map.Entry<String, String> entry : output1.entrySet()) {
+ assertTrue(params.containsKey(entry.getKey()));
+ }
+ }
+
+ @Test
+ public void testPropertiesWithoutSchema() throws SvcLogicException {
+ String uri = "test-yang:cont18";
+ Map<String, String> params = new HashMap<>();
+ params.put("test-yang_cont18.leaf40", "abc");
+ params.put("leaf41", "hi");
+ params.put("test-yang_cont18.leaf41", "abc");
+
+ InstanceIdentifierContext<?> iCtx = ParserIdentifier
+ .toInstanceIdentifier(uri, context, null);
+ PropertiesNodeSerializer ser = new MdsalPropertiesNodeSerializer(
+ iCtx.getSchemaNode(), context, uri);
+ PropertiesNode node = ser.encode(params);
+
+ Map<String, PropertiesNode> childNodes = ((RootNode) node).children();
+ assertThat(childNodes.containsKey("leaf40"), is(true));
+ node = childNodes.get("leaf40");
+ assertThat(node.uri(), is("test-yang:cont18.leaf40"));
+ }
+
+ @Test
+ public void testIdentityRef() throws SvcLogicException {
+ String uri = "identity-test:test";
+ Map<String, String> params = new HashMap<>();
+ params.put("identity-test_test.con1.interface", "identity-types" +
+ ":physical");
+ params.put("identity-test_test.con1.interfaces.int-list[0].iden", "identity-test:Giga");
+ params.put("identity-test_test.con1.interfaces.int-list[0].available.ll[0]", "identity-types:Loopback");
+ params.put("identity-test_test.con1.interfaces.int-list[0].available.leaf1", "identity-types-second:Ethernet");
+ params.put("identity-test_test.con1.interfaces.int-list[0].available.leaf2", "identity-types-second:iden2");
+ InstanceIdentifierContext<?> iCtx = ParserIdentifier
+ .toInstanceIdentifier(uri, context, null);
+
+ PropertiesNodeSerializer ser = new MdsalPropertiesNodeSerializer(
+ iCtx.getSchemaNode(), context, uri);
+ PropertiesNode node = ser.encode(params);
+ Map<String, PropertiesNode> childNodes = ((RootNode) node).children();
+ assertThat(childNodes.containsKey("con1"), is(true));
+ node = childNodes.get("con1");
+ assertThat(node.uri(), is("identity-test:test.con1"));
+ LeafNode l = ((LeafNode) ((SingleInstanceNode) node).children().get("interface"));
+ assertThat(l.uri(), is("identity-test:test.con1.interface"));
+ assertThat(l.valueNs().moduleName(), is("identity-types"));
+ assertThat(l.valueNs().moduleNs().toString(), is("identity:list:ns:test:json:ser"));
+
+ // identity type inside union
+ node = ((SingleInstanceNode) ((SingleInstanceNode) node).children().get("interfaces"));
+ node = ((ListHolderNode) ((SingleInstanceNode) node).children().get("int-list"));
+ node = ((MultiInstanceNode) ((ListHolderNode) node).children().get("0"));
+ l = ((LeafNode) ((MultiInstanceNode) node).children().get("iden"));
+ assertThat(l.uri(), is("identity-test:test.con1.interfaces.int-list[0].iden"));
+ assertThat(l.valueNs().moduleName(), is("identity-test"));
+ assertThat(l.valueNs().moduleNs().toString(), is("identity:ns:test:json:ser"));
+
+ // leaf-list test
+ node = (SingleInstanceNode) ((MultiInstanceNode) node).children().get("available");
+ LeafListHolderNode holder = (LeafListHolderNode) ((SingleInstanceNode) node).children().get("ll");
+ l = ((LeafNode) holder.children().get("0"));
+ assertThat(l.uri(), is("identity-test:test.con1.interfaces.int-list[0].available.ll[0]"));
+ assertThat(l.valueNs().moduleName(), is("identity-types"));
+ assertThat(l.valueNs().moduleNs().toString(), is("identity:list:ns:test:json:ser"));
+
+ // leaf-ref test
+ l = ((LeafNode) ((SingleInstanceNode) node).children().get("leaf1"));
+ assertThat(l.uri(), is("identity-test:test.con1.interfaces.int-list[0].available.leaf1"));
+ assertThat(l.valueNs().moduleName(), is("identity-types-second"));
+ assertThat(l.valueNs().moduleNs().toString(), is("identity:list:second:ns:test:json:ser"));
+
+ // list of base identity test
+ l = ((LeafNode) ((SingleInstanceNode) node).children().get("leaf2"));
+ assertThat(l.uri(), is("identity-test:test.con1.interfaces.int-list[0].available.leaf2"));
+ assertThat(l.valueNs().moduleName(), is("identity-types-second"));
+ assertThat(l.valueNs().moduleNs().toString(), is("identity:list:second:ns:test:json:ser"));
+ }
+
+ public static SchemaContext compileYangFile() throws FileNotFoundException {
+ String path = PropertiesSerializerTest.class.getResource("/yang").getPath();
+ File dir = new File(path);
+ String[] fileList = dir.list();
+ List<File> yangFiles = new ArrayList<File>();
+ if (fileList == null) {
+ throw new FileNotFoundException("/yang");
+ }
+ for (int i = 0; i < fileList.length; i++) {
+ final String fileName = fileList[i];
+ if (new File(dir, fileName).isDirectory() == false) {
+ yangFiles.add(new File(dir, fileName));
+ }
+ }
+ return YangParserTestUtils.parseYangFiles(yangFiles);
+ }
+} \ No newline at end of file
diff --git a/restconf-client/provider/src/test/resources/yang/execution-service.yang b/restconf-client/provider/src/test/resources/yang/execution-service.yang
new file mode 100644
index 000000000..d7cf68f12
--- /dev/null
+++ b/restconf-client/provider/src/test/resources/yang/execution-service.yang
@@ -0,0 +1,43 @@
+module execution-service {
+ yang-version 1.1;
+ namespace "cds:workflow:rest";
+ prefix "cds";
+
+ revision "2019-05-21";
+
+ container process {
+ container commonHeader {
+ leaf originatorId {
+ type string;
+ }
+ leaf requestId {
+ type string;
+ }
+ leaf subRequestId {
+ type string;
+ }
+ }
+ container actionIdentifiers {
+ leaf blueprintName {
+ type string;
+ }
+ leaf blueprintVersion {
+ type string;
+ }
+ leaf actionName {
+ type string;
+ }
+ leaf mode {
+ type string;
+ }
+ }
+ container payload {
+ leaf-list template-prefix {
+ type string;
+ }
+ container resource-assignment-request {
+ anyxml resource-assignment-properties;
+ }
+ }
+ }
+}
diff --git a/restconf-client/provider/src/test/resources/yang/identity-test.yang b/restconf-client/provider/src/test/resources/yang/identity-test.yang
new file mode 100644
index 000000000..12ef717f6
--- /dev/null
+++ b/restconf-client/provider/src/test/resources/yang/identity-test.yang
@@ -0,0 +1,77 @@
+module identity-test {
+ yang-version 1.1;
+ namespace "identity:ns:test:json:ser";
+ prefix "id";
+
+ import identity-types {
+ prefix "type";
+ }
+
+ import identity-types-second {
+ prefix "sec";
+ }
+
+ revision "2013-07-15";
+
+ identity optical {
+ base type:int-type;
+ }
+
+ identity Giga {
+ base type:physical;
+ }
+
+ typedef available {
+ type identityref {
+ base "type:physical";
+ }
+ }
+
+ typedef typed{
+ type union {
+ type int32;
+ type int8;
+ type identityref {
+ base type:int-type;
+ }
+ }
+ }
+
+ container test {
+ leaf l {
+ type string;
+ }
+ container con1 {
+ leaf interface {
+ type identityref {
+ base "type:int-type";
+ }
+ }
+ container interfaces {
+ list int-list {
+ key "iden";
+ leaf iden {
+ type "id:typed";
+ }
+ container available {
+ leaf-list ll {
+ type available;
+ }
+ leaf leaf1 {
+ type leafref {
+ path "../../iden";
+ }
+ }
+
+ leaf leaf2 {
+ type identityref {
+ base type:int-type;
+ base sec:iden1;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/restconf-client/provider/src/test/resources/yang/identity-types-second.yang b/restconf-client/provider/src/test/resources/yang/identity-types-second.yang
new file mode 100644
index 000000000..98d6a6e60
--- /dev/null
+++ b/restconf-client/provider/src/test/resources/yang/identity-types-second.yang
@@ -0,0 +1,25 @@
+module identity-types-second {
+ yang-version 1;
+ namespace "identity:list:second:ns:test:json:ser";
+ prefix "sec";
+
+ import identity-types {
+ prefix "type";
+ }
+
+ revision "2013-07-15";
+
+ identity virtual {
+ base type:int-type;
+ }
+
+ identity Ethernet {
+ base type:physical;
+ }
+
+ identity iden1;
+
+ identity iden2 {
+ base iden1;
+ }
+}
diff --git a/restconf-client/provider/src/test/resources/yang/identity-types.yang b/restconf-client/provider/src/test/resources/yang/identity-types.yang
new file mode 100644
index 000000000..25c8fa54f
--- /dev/null
+++ b/restconf-client/provider/src/test/resources/yang/identity-types.yang
@@ -0,0 +1,17 @@
+module identity-types {
+ yang-version 1;
+ namespace "identity:list:ns:test:json:ser";
+ prefix "type";
+ revision "2013-07-15";
+
+ identity int-type {
+ }
+
+ identity physical {
+ base int-type;
+ }
+
+ identity Loopback {
+ base physical;
+ }
+}
diff --git a/restconf-client/provider/src/test/resources/yang/test-augment.yang b/restconf-client/provider/src/test/resources/yang/test-augment.yang
new file mode 100644
index 000000000..795000d39
--- /dev/null
+++ b/restconf-client/provider/src/test/resources/yang/test-augment.yang
@@ -0,0 +1,106 @@
+module test-augment {
+ yang-version 1;
+ namespace "urn:opendaylight:params:xml:ns:yang:augment";
+ prefix "hello";
+
+ import test-yang {
+ prefix t;
+ }
+
+ revision "2015-01-05" {
+ description "Initial revision of hello model";
+ }
+
+ augment "/t:cont1/t:cont2/t:cont4" {
+ container cont5 {
+ leaf leaf13 {
+ type empty;
+ }
+ }
+ list list7 {
+ leaf leaf14 {
+ type instance-identifier;
+ }
+ }
+ leaf leaf15 {
+ type string;
+ }
+ leaf-list ll6 {
+ type union {
+ type int32;
+ type enumeration {
+ enum "unbounded";
+ }
+ }
+ }
+ uses "t:g1";
+ }
+
+ uses "t:g1";
+ augment "/t:ch1/t:c1/t:cont8/t:cont6" {
+ choice ch2 {
+ case c3 {
+ leaf leaf21 {
+ type string;
+ }
+ }
+ case c4 {
+ leaf leaf22 {
+ type enumeration {
+ enum zero;
+ enum one;
+ enum seven {
+ value 7;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ augment "/t:ch1" {
+ case c5 {
+ container cont10 {
+ leaf leaf23 {
+ type string;
+ }
+ }
+ }
+ }
+
+ augment "/t:ch1/t:c1" {
+ container cont7 {
+ leaf leaf24 {
+ type string;
+ }
+ }
+ }
+
+ augment "/t:cont13/t:cont12" {
+ leaf leaf29 {
+ type string;
+ }
+ }
+
+ augment "/t:create-sfc/t:input" {
+ leaf leaf36 {
+ type bits {
+ bit angle {
+ position 0;
+ }
+ bit degree {
+ position 1;
+ }
+ bit movement {
+ position 2;
+ }
+ }
+ }
+ }
+
+ augment "/t:create-sfc/t:output" {
+ leaf leaf37 {
+ type boolean;
+ }
+ }
+} \ No newline at end of file
diff --git a/restconf-client/provider/src/test/resources/yang/test-yang.yang b/restconf-client/provider/src/test/resources/yang/test-yang.yang
new file mode 100644
index 000000000..b2bf06003
--- /dev/null
+++ b/restconf-client/provider/src/test/resources/yang/test-yang.yang
@@ -0,0 +1,231 @@
+module test-yang {
+ yang-version 1;
+ namespace "urn:opendaylight:params:xml:ns:yang:test";
+ prefix "hello";
+
+ revision "2015-01-05" {
+ description "Initial revision of hello model";
+ }
+
+ container cont1 {
+ container cont2 {
+ container cont3 {
+ leaf leaf10 {
+ type string;
+ }
+ }
+ list list1 {
+ key "leaf1 leaf2";
+ leaf leaf1 {
+ type empty;
+ }
+ leaf leaf2 {
+ type string;
+ }
+ leaf leaf3 {
+ type string;
+ }
+ leaf-list ll1 {
+ type string;
+ }
+ leaf-list ll2 {
+ type string;
+ }
+ container cont4 {
+ leaf leaf11 {
+ type string;
+ }
+ }
+ list list4 {
+ leaf leaf8 {
+ type string;
+ }
+ }
+ list list5 {
+ leaf leaf9 {
+ type string;
+ }
+ }
+ }
+ list list2 {
+ leaf leaf4 {
+ type string;
+ }
+ }
+ leaf leaf5 {
+ type string;
+ }
+ leaf leaf6 {
+ type string;
+ }
+ leaf-list ll3 {
+ type string;
+ }
+ leaf-list ll4 {
+ type string;
+ }
+ }
+ }
+
+ augment "/cont1/cont2" {
+ container cont4 {
+ leaf leaf10 {
+ type string;
+ }
+ }
+ list list6 {
+ leaf leaf11 {
+ type string;
+ }
+ }
+ leaf leaf12 {
+ type string;
+ }
+ leaf-list ll5 {
+ type string;
+ }
+ }
+
+ choice ch1 {
+ case c1 {
+ container cont8 {
+ container cont6 {
+ leaf leaf16 {
+ type string;
+ }
+ }
+ list list8 {
+ leaf leaf18 {
+ type string;
+ }
+ }
+ leaf leaf19 {
+ type string;
+ }
+ leaf-list ll7 {
+ type string;
+ }
+ }
+ }
+ case c2 {
+ container cont9 {
+ leaf leaf20 {
+ type string;
+ }
+ leaf-list ll8 {
+ type string;
+ }
+ container cont11 {
+ choice ch3 {
+ case c1 {
+ leaf leaf25 {
+ type string;
+ }
+ uses g1;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ grouping g1 {
+ container cont13 {
+ container cont12 {
+ leaf leaf26 {
+ type string;
+ }
+ }
+ list list9 {
+ leaf leaf27 {
+ type string;
+ }
+ }
+ leaf leaf28 {
+ type string;
+ }
+ leaf-list ll9 {
+ type string;
+ }
+ }
+ }
+
+ uses g1;
+
+ rpc create-sfc {
+ input {
+ container cont14 {
+ leaf leaf28 {
+ type string;
+ }
+ }
+ list list10 {
+ leaf leaf29 {
+ type string;
+ }
+ }
+ leaf leaf30 {
+ type string;
+ }
+ leaf-list ll10 {
+ type string;
+ }
+ choice ch3 {
+ case c1 {
+ container cont15 {
+ leaf leaf31 {
+ type string;
+ }
+ }
+ }
+ }
+ uses g1;
+ }
+ output {
+ container cont16 {
+ leaf leaf32 {
+ type string;
+ }
+ }
+ list list11 {
+ leaf leaf33 {
+ type string;
+ }
+ }
+ leaf leaf34 {
+ type string;
+ }
+ leaf-list ll11 {
+ type string;
+ }
+ choice ch4 {
+ case c1 {
+ container cont17 {
+ leaf leaf35 {
+ type string;
+ }
+ }
+ }
+ }
+ uses g1;
+ }
+ }
+
+ container cont18 {
+ container cont18 {
+ list list12 {
+ list list12 {
+ leaf leaf36 {
+ type string;
+ }
+ }
+ leaf leaf36 {
+ type string;
+ }
+ }
+ }
+ leaf leaf40 {
+ type string;
+ }
+ }
+} \ No newline at end of file
diff --git a/restconf-client/provider/src/test/resources/yang/test_augment_1_for_module.yang b/restconf-client/provider/src/test/resources/yang/test_augment_1_for_module.yang
new file mode 100644
index 000000000..d2eeea7d1
--- /dev/null
+++ b/restconf-client/provider/src/test/resources/yang/test_augment_1_for_module.yang
@@ -0,0 +1,108 @@
+module test_augment_1_for_module {
+ yang-version 1;
+ namespace "urn:opendaylight:params:xml:ns:yang:test:augment:name";
+ prefix "augment-name";
+
+ import test_name_of_the_module {
+ prefix aug;
+ }
+
+ revision "2015-01-05" {
+ description "Initial revision of hello model";
+ }
+
+ augment "/aug:name_of_the_cont1/aug:name_of_the_cont2/aug:name_of_the_cont4" {
+ container name_of_the_cont5 {
+ leaf name_of_the_leaf13 {
+ type empty;
+ }
+ }
+ list name_of_the_list7 {
+ leaf name_of_the_leaf14 {
+ type instance-identifier;
+ }
+ }
+ leaf name_of_the_leaf15 {
+ type string;
+ }
+ leaf-list name_of_the_ll6 {
+ type union {
+ type int32;
+ type enumeration {
+ enum "unbounded";
+ }
+ }
+ }
+ uses "aug:name_of_the_g1";
+ }
+
+ uses "aug:name_of_the_g1";
+
+ augment "/aug:name_of_the_cont1/aug:name_of_the_cont2/aug:name_of_the_cont3" {
+ choice name_of_the_ch2 {
+ case name_of_the_c3 {
+ leaf name_of_the_leaf21 {
+ type string;
+ }
+ }
+ case name_of_the_c4 {
+ leaf name_of_the_leaf22 {
+ type enumeration {
+ enum zero;
+ enum one;
+ enum seven {
+ value 7;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ augment "/aug:name_of_the_ch1" {
+ case name_of_the_c5 {
+ container name_of_the_cont10 {
+ leaf name_of_the_leaf23 {
+ type string;
+ }
+ }
+ }
+ }
+
+ augment "/aug:name_of_the_ch1/aug:name_of_the_c1" {
+ container name_of_the_cont7 {
+ leaf name_of_the_leaf24 {
+ type string;
+ }
+ }
+ }
+
+ augment "/aug:name_of_the_cont13/aug:name_of_the_cont12" {
+ leaf name_of_the_leaf29 {
+ type string;
+ }
+ }
+
+ augment "/aug:name_of_the_create-sfc/aug:input" {
+ leaf name_of_the_leaf36 {
+ type bits {
+ bit angle {
+ position 0;
+ }
+ bit degree {
+ position 1;
+ }
+ bit movement {
+ position 2;
+ }
+ }
+ }
+ }
+
+ augment "/aug:name_of_the_create-sfc/aug:output" {
+ leaf leaf37 {
+ type boolean;
+ }
+ }
+
+} \ No newline at end of file
diff --git a/restconf-client/provider/src/test/resources/yang/test_name_of_the_module.yang b/restconf-client/provider/src/test/resources/yang/test_name_of_the_module.yang
new file mode 100644
index 000000000..973475ee7
--- /dev/null
+++ b/restconf-client/provider/src/test/resources/yang/test_name_of_the_module.yang
@@ -0,0 +1,231 @@
+module test_name_of_the_module {
+ yang-version 1;
+ namespace "urn:opendaylight:params:xml:ns:yang:test:name";
+ prefix "name";
+
+ revision "2015-01-05" {
+ description "Initial revision of hello model";
+ }
+
+ container name_of_the_cont1 {
+ container name_of_the_cont2 {
+ container name_of_the_cont3 {
+ leaf name_of_the_leaf10 {
+ type string;
+ }
+ }
+ list name_of_the_list1 {
+ key "name_of_the_leaf1 name_of_the_leaf2";
+ leaf name_of_the_leaf1 {
+ type empty;
+ }
+ leaf name_of_the_leaf2 {
+ type string;
+ }
+ leaf name_of_the_leaf3 {
+ type string;
+ }
+ leaf-list name_of_the_ll1 {
+ type string;
+ }
+ leaf-list name_of_the_ll2 {
+ type string;
+ }
+ container name_of_the_cont4 {
+ leaf name_of_the_leaf11 {
+ type string;
+ }
+ }
+ list name_of_the_list4 {
+ leaf name_of_the_leaf8 {
+ type string;
+ }
+ }
+ list name_of_the_list5 {
+ leaf name_of_the_leaf9 {
+ type string;
+ }
+ }
+ }
+ list name_of_the_list2 {
+ leaf name_of_the_leaf4 {
+ type string;
+ }
+ }
+ leaf name_of_the_leaf5 {
+ type string;
+ }
+ leaf name_of_the_leaf6 {
+ type string;
+ }
+ leaf-list name_of_the_ll3 {
+ type string;
+ }
+ leaf-list name_of_the_ll4 {
+ type string;
+ }
+ }
+ }
+
+ augment "/name_of_the_cont1/name_of_the_cont2" {
+ container name_of_the_cont4 {
+ leaf name_of_the_leaf10 {
+ type string;
+ }
+ }
+ list name_of_the_list6 {
+ leaf name_of_the_leaf11 {
+ type string;
+ }
+ }
+ leaf name_of_the_leaf12 {
+ type string;
+ }
+ leaf-list name_of_the_ll5 {
+ type string;
+ }
+ }
+
+ choice name_of_the_ch1 {
+ case name_of_the_c1 {
+ container name_of_the_cont8 {
+ container name_of_the_cont6 {
+ leaf name_of_the_leaf16 {
+ type string;
+ }
+ }
+ list name_of_the_list8 {
+ leaf name_of_the_leaf18 {
+ type string;
+ }
+ }
+ leaf name_of_the_leaf19 {
+ type string;
+ }
+ leaf-list name_of_the_ll7 {
+ type string;
+ }
+ }
+ }
+ case name_of_the_c2 {
+ container name_of_the_cont9 {
+ leaf name_of_the_leaf20 {
+ type string;
+ }
+ leaf-list name_of_the_ll8 {
+ type string;
+ }
+ container name_of_the_cont11 {
+ choice name_of_the_ch3 {
+ case name_of_the_c1 {
+ leaf name_of_the_leaf25 {
+ type string;
+ }
+ uses name_of_the_g1;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ grouping name_of_the_g1 {
+ container name_of_the_cont13 {
+ container name_of_the_cont12 {
+ leaf name_of_the_leaf26 {
+ type string;
+ }
+ }
+ list name_of_the_list9 {
+ leaf name_of_the_leaf27 {
+ type string;
+ }
+ }
+ leaf name_of_the_leaf28 {
+ type string;
+ }
+ leaf-list name_of_the_ll9 {
+ type string;
+ }
+ }
+ }
+
+ uses name_of_the_g1;
+
+ rpc name_of_the_create-sfc {
+ input {
+ container name_of_the_cont14 {
+ leaf name_of_the_leaf28 {
+ type string;
+ }
+ }
+ list name_of_the_list10 {
+ leaf name_of_the_leaf29 {
+ type string;
+ }
+ }
+ leaf name_of_the_leaf30 {
+ type string;
+ }
+ leaf-list name_of_the_ll10 {
+ type string;
+ }
+ choice name_of_the_ch3 {
+ case name_of_the_c1 {
+ container name_of_the_cont15 {
+ leaf name_of_the_leaf31 {
+ type string;
+ }
+ }
+ }
+ }
+ uses name_of_the_g1;
+ }
+ output {
+ container name_of_the_cont16 {
+ leaf name_of_the_leaf32 {
+ type string;
+ }
+ }
+ list name_of_the_list11 {
+ leaf name_of_the_leaf33 {
+ type string;
+ }
+ }
+ leaf name_of_the_leaf34 {
+ type string;
+ }
+ leaf-list name_of_the_ll11 {
+ type string;
+ }
+ choice name_of_the_ch4 {
+ case name_of_the_c1 {
+ container name_of_the_cont17 {
+ leaf name_of_the_leaf35 {
+ type string;
+ }
+ }
+ }
+ }
+ uses name_of_the_g1;
+ }
+ }
+
+ container name_of_the_cont18 {
+ container name_of_the_cont18 {
+ list name_of_the_list12 {
+ list name_of_the_list12 {
+ leaf name_of_the_leaf36 {
+ type string;
+ }
+ }
+ leaf name_of_the_leaf36 {
+ type string;
+ }
+ }
+ }
+ leaf name_of_the_leaf40 {
+ type string;
+ }
+ }
+} \ No newline at end of file