2  * ============LICENSE_START=======================================================
 
   4  * ================================================================================
 
   5  * Copyright (C) 2018 Huawei Technologies Co., Ltd. All rights reserved.
 
   6  * ================================================================================
 
   7  * Licensed under the Apache License, Version 2.0 (the "License");
 
   8  * you may not use this file except in compliance with the License.
 
   9  * You may obtain a copy of the License at
 
  11  *      http://www.apache.org/licenses/LICENSE-2.0
 
  13  * Unless required by applicable law or agreed to in writing, software
 
  14  * distributed under the License is distributed on an "AS IS" BASIS,
 
  15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
  16  * See the License for the specific language governing permissions and
 
  17  * limitations under the License.
 
  18  * ============LICENSE_END=========================================================
 
  21 package org.onap.ccsdk.sli.plugins.yangserializers.dfserializer;
 
  23 import org.junit.Before;
 
  24 import org.junit.Test;
 
  25 import org.mockito.invocation.InvocationOnMock;
 
  26 import org.mockito.stubbing.Answer;
 
  27 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
 
  28 import org.onap.ccsdk.sli.core.sli.SvcLogicException;
 
  29 import org.onap.ccsdk.sli.plugins.restapicall.HttpResponse;
 
  30 import org.onap.ccsdk.sli.plugins.restapicall.RestapiCallNode;
 
  31 import org.onap.ccsdk.sli.plugins.restconfapicall.RestconfApiCallNode;
 
  32 import org.opendaylight.restconf.common.context.InstanceIdentifierContext;
 
  34 import java.util.HashMap;
 
  37 import static org.hamcrest.MatcherAssert.assertThat;
 
  38 import static org.hamcrest.core.Is.is;
 
  39 import static org.mockito.Matchers.any;
 
  40 import static org.mockito.Mockito.doAnswer;
 
  41 import static org.mockito.Mockito.doCallRealMethod;
 
  42 import static org.mockito.Mockito.doReturn;
 
  43 import static org.mockito.Mockito.mock;
 
  44 import static org.onap.ccsdk.sli.plugins.restapicall.HttpMethod.GET;
 
  45 import static org.onap.ccsdk.sli.plugins.restapicall.HttpMethod.POST;
 
  46 import static org.onap.ccsdk.sli.plugins.restapicall.HttpMethod.PUT;
 
  47 import static org.onap.ccsdk.sli.plugins.restconfapicall.RestconfApiUtils.parseUrl;
 
  48 import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DataFormatUtilsTest.DECODE_FROM_JSON_RPC;
 
  49 import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DataFormatUtilsTest.DECODE_FROM_XML_RPC;
 
  50 import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DataFormatUtilsTest.ENCODE_TO_JSON_ID;
 
  51 import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DataFormatUtilsTest.ENCODE_TO_JSON_RPC;
 
  52 import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DataFormatUtilsTest.ENCODE_TO_JSON_YANG;
 
  53 import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DataFormatUtilsTest.ENCODE_TO_JSON_YANG_AUG_POST;
 
  54 import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DataFormatUtilsTest.ENCODE_TO_XML_ID;
 
  55 import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DataFormatUtilsTest.ENCODE_TO_XML_RPC;
 
  56 import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DataFormatUtilsTest.ENCODE_TO_XML_YANG;
 
  60  * Unit test cases for data format serialization and restconf api call node.
 
  62 public class DataFormatSerializerTest {
 
  64     private Map<String, String> p;
 
  66     private RestconfApiCallNode restconf;
 
  68     private RestapiCallNode restApi;
 
  70     private DfCaptor dfCaptor;
 
  73      * Sets up the pre-requisite for each test case.
 
  75      * @throws SvcLogicException when test case fails
 
  78     public void setUp() throws SvcLogicException {
 
  80         p.put("restapiUser", "user1");
 
  81         p.put("restapiPassword", "abc123");
 
  82         p.put("responsePrefix", "response");
 
  83         p.put("skipSending", "true");
 
  84         restApi = new RestapiCallNode();
 
  85         restconf = mock(RestconfApiCallNode.class);
 
  86         dfCaptor = new DfCaptor();
 
  91      * Creates method mocks using mockito for RestconfApiCallNode class.
 
  93      * @throws SvcLogicException when test case fails
 
  95     private void createMethodMocks() throws SvcLogicException {
 
  96         doReturn(restApi).when(restconf).getRestapiCallNode();
 
  97         doCallRealMethod().when(restconf).sendRequest(
 
  98                 any(Map.class), any(SvcLogicContext.class));
 
  99         doCallRealMethod().when(restconf).sendRequest(
 
 100                 any(Map.class), any(SvcLogicContext.class), any(Integer.class));
 
 101         doAnswer(dfCaptor).when(restconf).serializeRequest(
 
 102                 any(Map.class), any(YangParameters.class), any(String.class),
 
 103                 any(InstanceIdentifierContext.class));
 
 107      * Creates mock using mockito with input data for decoding.
 
 109      * @param decodeData input data
 
 110      * @throws SvcLogicException when test case fails
 
 112     private void createMockForDecode(String decodeData)
 
 113             throws SvcLogicException {
 
 114         doReturn(decodeData).when(restconf).getResponse(
 
 115                 any(SvcLogicContext.class), any(YangParameters.class),
 
 116                 any(String.class), any(HttpResponse.class));
 
 117         doCallRealMethod().when(restconf).serializeResponse(
 
 118                 any(YangParameters.class), any(String.class), any(String.class),
 
 119                 any(InstanceIdentifierContext.class));
 
 123      * Verifies encoding of parameters to JSON data format with identity-ref
 
 124      * and inter-file linking.
 
 126      * @throws SvcLogicException when test case fails
 
 129     public void encodeToJsonId() throws SvcLogicException {
 
 130         String pre = "identity-test:test.";
 
 131         SvcLogicContext ctx = createAttList(pre);
 
 132         ctx.setAttribute(pre + "l", "abc");
 
 133         p.put("dirPath", "src/test/resources");
 
 134         p.put("format", "json");
 
 135         p.put("httpMethod", "post");
 
 136         p.put("restapiUrl", "http://echo.getpostman" +
 
 137                 ".com/restconf/operations/identity-test:test");
 
 138         restconf.sendRequest(p, ctx);
 
 139         assertThat(dfCaptor.getResult(), is(ENCODE_TO_JSON_ID));
 
 143      * Verifies encoding of parameters to XML data format with identity-ref
 
 144      * and inter-file linking.
 
 146      * @throws SvcLogicException when test case fails
 
 149     public void encodeToXmlId() throws SvcLogicException {
 
 150         String pre = "identity-test:test.";
 
 151         SvcLogicContext ctx = createAttList(pre);
 
 152         p.put("dirPath", "src/test/resources");
 
 153         p.put("format", "xml");
 
 154         p.put("httpMethod", "post");
 
 155         p.put("restapiUrl", "http://echo.getpostman" +
 
 156                 ".com/restconf/operations/identity-test:test");
 
 157         restconf.sendRequest(p, ctx);
 
 158         assertThat(dfCaptor.getResult(), is(ENCODE_TO_XML_ID));
 
 162      * Verifies decoding of parameters from JSON data format with identity-ref
 
 163      * and inter-file linking.
 
 165      * @throws SvcLogicException when test case fails
 
 168     public void decodeToJsonId() throws SvcLogicException {
 
 169         createMockForDecode(ENCODE_TO_JSON_ID);
 
 170         SvcLogicContext ctx = new SvcLogicContext();
 
 171         String pre = "identity-test:test.";
 
 172         p.put("dirPath", "src/test/resources");
 
 173         p.put("format", "json");
 
 174         p.put("httpMethod", "get");
 
 175         p.put("restapiUrl", "http://echo.getpostman" +
 
 176                 ".com/restconf/operations/identity-test:test");
 
 177         restconf.sendRequest(p, ctx);
 
 178         assertThat(ctx.getAttribute(pre + "l"), is("abc"));
 
 179         verifyAttList(ctx, pre);
 
 183      * Verifies decoding of parameters from XML data format with identity-ref
 
 184      * and inter-file linking.
 
 186      * @throws SvcLogicException when test case fails
 
 189     public void decodeToXmlId() throws SvcLogicException {
 
 190         createMockForDecode(ENCODE_TO_XML_ID);
 
 191         SvcLogicContext ctx = new SvcLogicContext();
 
 192         String pre = "identity-test:test.";
 
 193         p.put("dirPath", "src/test/resources");
 
 194         p.put("format", "xml");
 
 195         p.put("httpMethod", "get");
 
 196         p.put("restapiUrl", "http://echo.getpostman" +
 
 197                 ".com/restconf/operations/identity-test:test");
 
 198         restconf.sendRequest(p, ctx);
 
 199         verifyAttList(ctx, pre);
 
 203      * Verifies encoding of parameters to JSON data format with containers,
 
 204      * grouping and augment.
 
 206      * @throws SvcLogicException when test case fails
 
 209     public void encodeToJsonYang() throws SvcLogicException {
 
 210         String pre = "test-yang:cont1.cont2.";
 
 211         SvcLogicContext ctx = createAttListYang(pre);
 
 212         p.put("dirPath", "src/test/resources");
 
 213         p.put("format", "json");
 
 214         p.put("httpMethod", "post");
 
 215         p.put("restapiUrl", "http://echo.getpostman" +
 
 216                 ".com/restconf/operations/test-yang:cont1");
 
 217         restconf.sendRequest(p, ctx);
 
 218         assertThat(dfCaptor.getResult(), is(ENCODE_TO_JSON_YANG));
 
 222      * Verifies encoding of parameters to JSON data format with augment as
 
 225      * @throws SvcLogicException when test case fails
 
 228     public void encodeToJsonWithAugAsRootChild() throws SvcLogicException {
 
 229         String pre = "test-yang:cont1.cont2.";
 
 230         SvcLogicContext ctx = createAttListYang(pre);
 
 231         p.put("dirPath", "src/test/resources");
 
 232         p.put("format", "json");
 
 233         p.put("httpMethod", "post");
 
 234         p.put("restapiUrl", "http://echo.getpostman" +
 
 235                 ".com/restconf/operations/test-yang:cont1/cont2/cont4");
 
 236         restconf.sendRequest(p, ctx);
 
 237         assertThat(dfCaptor.getResult(), is(ENCODE_TO_JSON_YANG_AUG_POST));
 
 241      * Verifies decoding of parameters from JSON data format with containers,
 
 242      * grouping and augment.
 
 244      * @throws SvcLogicException when test case fails
 
 247     public void decodeToJsonYang() throws SvcLogicException {
 
 248         createMockForDecode(ENCODE_TO_JSON_YANG);
 
 249         SvcLogicContext ctx = new SvcLogicContext();
 
 250         String pre = "test-yang:cont1.cont2.";
 
 251         p.put("dirPath", "src/test/resources");
 
 252         p.put("format", "json");
 
 253         p.put("httpMethod", "get");
 
 254         p.put("restapiUrl", "http://echo.getpostman" +
 
 255                 ".com/restconf/operations/test-yang:cont1");
 
 256         restconf.sendRequest(p, ctx);
 
 257         verifyAttListYang(ctx, pre);
 
 261      * Verifies encoding of parameters to XML data format with containers,
 
 262      * grouping and augment.
 
 264      * @throws SvcLogicException when test case fails
 
 267     public void encodeToXmlYang() throws SvcLogicException {
 
 268         String pre = "test-yang:cont1.cont2.";
 
 269         SvcLogicContext ctx = createAttListYang(pre);
 
 270         p.put("dirPath", "src/test/resources");
 
 271         p.put("format", "xml");
 
 272         p.put("httpMethod", "post");
 
 273         p.put("restapiUrl", "http://echo.getpostman" +
 
 274                 ".com/restconf/operations/test-yang:cont1");
 
 275         restconf.sendRequest(p, ctx);
 
 276         assertThat(dfCaptor.getResult(), is(ENCODE_TO_XML_YANG));
 
 280      * Verifies decoding of parameters from XML data format with containers,
 
 281      * grouping and augment.
 
 283      * @throws SvcLogicException when test case fails
 
 286     public void decodeToXmlYang() throws SvcLogicException {
 
 287         createMockForDecode(ENCODE_TO_XML_YANG);
 
 288         SvcLogicContext ctx = new SvcLogicContext();
 
 289         String pre = "test-yang:cont1.cont2.";
 
 290         p.put("dirPath", "src/test/resources");
 
 291         p.put("format", "xml");
 
 292         p.put("httpMethod", "get");
 
 293         p.put("restapiUrl", "http://echo.getpostman" +
 
 294                 ".com/restconf/operations/test-yang:cont1");
 
 295         restconf.sendRequest(p, ctx);
 
 296         verifyAttListYang(ctx, pre);
 
 300      * Verifies encoding of and decoding from, JSON respectively for data
 
 301      * format with containers, grouping and augment.
 
 303      * @throws SvcLogicException when test case fails
 
 306     public void codecToJsonRpc() throws SvcLogicException {
 
 307         createMockForDecode(DECODE_FROM_JSON_RPC);
 
 308         String inPre = "test-yang:create-sfc.input.";
 
 309         String outPre = "test-yang:create-sfc.output.";
 
 310         SvcLogicContext ctx = createAttListRpc(inPre);
 
 311         p.put("dirPath", "src/test/resources");
 
 312         p.put("format", "json");
 
 313         p.put("httpMethod", "post");
 
 314         p.put("restapiUrl", "http://echo.getpostman" +
 
 315                 ".com/restconf/operations/test-yang:create-sfc");
 
 316         restconf.sendRequest(p, ctx);
 
 317         assertThat(dfCaptor.getResult(), is(ENCODE_TO_JSON_RPC));
 
 318         verifyAttListRpc(ctx, outPre);
 
 322      * Verifies encoding of and decoding from, XML respectively for data
 
 323      * format with containers, grouping and augment.
 
 325      * @throws SvcLogicException when test case fails
 
 328     public void codecToXmlRpc() throws SvcLogicException {
 
 329         createMockForDecode(DECODE_FROM_XML_RPC);
 
 330         String inPre = "test-yang:create-sfc.input.";
 
 331         String outPre = "test-yang:create-sfc.output.";
 
 332         SvcLogicContext ctx = createAttListRpc(inPre);
 
 333         p.put("dirPath", "src/test/resources");
 
 334         p.put("format", "xml");
 
 335         p.put("httpMethod", "post");
 
 336         p.put("restapiUrl", "http://echo.getpostman" +
 
 337                 ".com/restconf/operations/test-yang:create-sfc");
 
 338         restconf.sendRequest(p, ctx);
 
 339         assertThat(dfCaptor.getResult(), is(ENCODE_TO_XML_RPC));
 
 340         verifyAttListRpc(ctx, outPre);
 
 344      * Verifies URL parser returning path with only schema information for all
 
 347      * @throws SvcLogicException when test case fails
 
 350     public void validateUrlParser() throws SvcLogicException {
 
 351         String actVal = "identity-test:test";
 
 352         String url1 = "http://echo.getpostman.com/restconf/operations/" +
 
 354         String url2 = "http://echo.getpostman.com/restconf/data/" + actVal;
 
 355         String url3 = "https://echo.getpostman.com/restconf/operations/" +
 
 357         String url4 = "https://echo.getpostman.com/restconf/data/" + actVal +
 
 359         String url5 = "http://localhost:8282/restconf/operations/" + actVal;
 
 360         String url6 = "https://localhost:8282/restconf/operations/" + actVal;
 
 361         String url7 = "http://localhost:8282/restconf/data/" + actVal +
 
 363         String url8 = "https://localhost:8282/restconf/data/" + actVal;
 
 364         String url9 = "http://182.2.61.24:2250/restconf/data/" + actVal;
 
 365         String url10 = "https://182.2.61.24:2250/restconf/operations/" + actVal;
 
 366         String val1 = parseUrl(url1, POST);
 
 367         String val2 = parseUrl(url2, GET);
 
 368         String val3 = parseUrl(url3, POST);
 
 369         String val4 = parseUrl(url4, PUT);
 
 370         String val5 = parseUrl(url5, GET);
 
 371         String val6 = parseUrl(url6, POST);
 
 372         String val7 = parseUrl(url7, PUT);
 
 373         String val8 = parseUrl(url8, POST);
 
 374         String val9 = parseUrl(url9, GET);
 
 375         String val10 = parseUrl(url10, POST);
 
 376         assertThat(val1, is(actVal));
 
 377         assertThat(val2, is(actVal));
 
 378         assertThat(val3, is(actVal));
 
 379         assertThat(val4, is(actVal));
 
 380         assertThat(val5, is(actVal));
 
 381         assertThat(val6, is(actVal));
 
 382         assertThat(val7, is(actVal));
 
 383         assertThat(val8, is(actVal));
 
 384         assertThat(val9, is(actVal));
 
 385         assertThat(val10, is(actVal));
 
 389      * Creates attribute list for encoding JSON or XML with identity-ref YANG
 
 393      * @return service logic context
 
 395     private SvcLogicContext createAttList(String pre) {
 
 396         SvcLogicContext ctx = new SvcLogicContext();
 
 397         String pre1 = pre + "con1.interfaces.";
 
 398         ctx.setAttribute(pre + "con1.interface", "identity-types:physical");
 
 399         ctx.setAttribute(pre1 + "int-list[0].iden", "optical");
 
 400         ctx.setAttribute(pre1 + "int-list[0].available.ll[0]", "Giga");
 
 401         ctx.setAttribute(pre1 + "int-list[0].available.ll[1]",
 
 402                          "identity-types:Loopback");
 
 403         ctx.setAttribute(pre1 + "int-list[0].available.ll[2]",
 
 404                          "identity-types-second:Ethernet");
 
 405         ctx.setAttribute(pre1 + "int-list[0].available.leaf1", "58");
 
 406         ctx.setAttribute(pre1 + "int-list[0].available.leaf2",
 
 407                          "identity-types-second:iden2");
 
 409         ctx.setAttribute(pre1 + "int-list[1].iden", "214748364");
 
 410         ctx.setAttribute(pre1 + "int-list[1].available.ll[0]", "Giga");
 
 411         ctx.setAttribute(pre1 + "int-list[1].available.ll[1]",
 
 412                          "identity-types:Loopback");
 
 413         ctx.setAttribute(pre1 + "int-list[1].available.ll[2]",
 
 414                          "identity-types-second:Ethernet");
 
 415         ctx.setAttribute(pre1 + "int-list[1].available.leaf1",
 
 417         ctx.setAttribute(pre1 + "int-list[1].available.leaf2",
 
 418                          "identity-types-second:iden2");
 
 423      * Creates attribute list for encoding JSON or XML with container,
 
 424      * grouping and augmented YANG file.
 
 427      * @return service logic context
 
 429     private SvcLogicContext createAttListYang(String pre) {
 
 430         SvcLogicContext ctx = new SvcLogicContext();
 
 431         ctx.setAttribute(pre + "cont3.leaf10", "abc");
 
 432         ctx.setAttribute(pre + "list1[0].leaf1", "true");
 
 433         ctx.setAttribute(pre + "list1[0].leaf2", "abc");
 
 434         ctx.setAttribute(pre + "list1[0].leaf3", "abc");
 
 435         ctx.setAttribute(pre + "list1[0].ll1[0]", "abc");
 
 436         ctx.setAttribute(pre + "list1[0].ll1[1]", "abc");
 
 437         ctx.setAttribute(pre + "list1[0].ll2[0]", "abc");
 
 438         ctx.setAttribute(pre + "list1[0].ll2[1]", "abc");
 
 439         ctx.setAttribute(pre + "list1[0].cont4.leaf11", "abc");
 
 440         ctx.setAttribute(pre + "list1[0].list4[0].leaf8", "abc");
 
 441         ctx.setAttribute(pre + "list1[0].list4[1].leaf8", "abc");
 
 442         ctx.setAttribute(pre + "list1[0].list5[0].leaf9", "abc");
 
 443         ctx.setAttribute(pre + "list1[0].list5[1].leaf9", "abc");
 
 444         ctx.setAttribute(pre + "list1[1].leaf1", "true");
 
 445         ctx.setAttribute(pre + "list1[1].leaf2", "abc");
 
 446         ctx.setAttribute(pre + "list1[1].leaf3", "abc");
 
 447         ctx.setAttribute(pre + "list1[1].ll1[0]", "abc");
 
 448         ctx.setAttribute(pre + "list1[1].ll1[1]", "abc");
 
 449         ctx.setAttribute(pre + "list1[1].ll2[0]", "abc");
 
 450         ctx.setAttribute(pre + "list1[1].ll2[1]", "abc");
 
 451         ctx.setAttribute(pre + "list1[1].cont4.leaf11", "abc");
 
 452         ctx.setAttribute(pre + "list1[1].list4[0].leaf8", "abc");
 
 453         ctx.setAttribute(pre + "list1[1].list4[1].leaf8", "abc");
 
 454         ctx.setAttribute(pre + "list1[1].list5[0].leaf9", "abc");
 
 455         ctx.setAttribute(pre + "list1[1].list5[1].leaf9", "abc");
 
 456         ctx.setAttribute(pre + "list2[0].leaf4", "abc");
 
 457         ctx.setAttribute(pre + "list2[1].leaf4", "abc");
 
 458         ctx.setAttribute(pre + "leaf5", "abc");
 
 459         ctx.setAttribute(pre + "leaf6", "abc");
 
 460         ctx.setAttribute(pre + "ll3[0]", "abc");
 
 461         ctx.setAttribute(pre + "ll3[1]", "abc");
 
 462         ctx.setAttribute(pre + "ll4[0]", "abc");
 
 463         ctx.setAttribute(pre + "ll4[1]", "abc");
 
 464         ctx.setAttribute(pre + "cont4.leaf10", "abc");
 
 465         ctx.setAttribute(pre + "list6[0].leaf11", "abc");
 
 466         ctx.setAttribute(pre + "list6[1].leaf11", "abc");
 
 467         ctx.setAttribute(pre + "leaf12", "abc");
 
 468         ctx.setAttribute(pre + "ll5[0]", "abc");
 
 469         ctx.setAttribute(pre + "ll5[1]", "abc");
 
 470         ctx.setAttribute(pre + "cont4.test-augment:cont5.leaf13", "true");
 
 471         ctx.setAttribute(pre + "cont4.test-augment:list7[0].leaf14", "test");
 
 472         ctx.setAttribute(pre + "cont4.test-augment:list7[1].leaf14", "create");
 
 473         ctx.setAttribute(pre + "cont4.test-augment:leaf15", "abc");
 
 474         ctx.setAttribute(pre + "cont4.test-augment:ll6[0]", "unbounded");
 
 475         ctx.setAttribute(pre + "cont4.test-augment:ll6[1]", "8");
 
 476         ctx.setAttribute(pre + "cont4.test-augment:cont13.cont12.leaf26",
 
 478         ctx.setAttribute(pre + "cont4.test-augment:cont13.list9[0].leaf27",
 
 480         ctx.setAttribute(pre + "cont4.test-augment:cont13.list9[1].leaf27",
 
 482         ctx.setAttribute(pre + "cont4.test-augment:cont13.leaf28", "abc");
 
 483         ctx.setAttribute(pre + "cont4.test-augment:cont13.ll9[0]", "abc");
 
 484         ctx.setAttribute(pre + "cont4.test-augment:cont13.ll9[1]", "abc");
 
 489      * Creates attribute list for encoding JSON or XML with RPC YANG file.
 
 492      * @return service logic context
 
 494     private SvcLogicContext createAttListRpc(String pre) {
 
 495         SvcLogicContext ctx = new SvcLogicContext();
 
 496         ctx.setAttribute(pre + "cont14.leaf28", "abc");
 
 497         ctx.setAttribute(pre + "list10[0].leaf29", "abc");
 
 498         ctx.setAttribute(pre + "list10[1].leaf29", "abc");
 
 499         ctx.setAttribute(pre + "leaf30", "abc");
 
 500         ctx.setAttribute(pre + "ll10[0]", "abc");
 
 501         ctx.setAttribute(pre + "ll10[1]", "abc");
 
 502         ctx.setAttribute(pre + "cont15.leaf31", "abc");
 
 503         ctx.setAttribute(pre + "cont13.list9[0].leaf27", "abc");
 
 504         ctx.setAttribute(pre + "cont13.list9[1].leaf27", "abc");
 
 505         ctx.setAttribute(pre + "cont13.leaf28", "abc");
 
 506         ctx.setAttribute(pre + "cont13.ll9[0]", "abc");
 
 507         ctx.setAttribute(pre + "cont13.ll9[1]", "abc");
 
 512      * Verifies the attribute list for decoding from JSON or XML with
 
 513      * identity-ref YANG file.
 
 515      * @param ctx service logic context
 
 518     private void verifyAttList(SvcLogicContext ctx, String pre) {
 
 519         String pre1 = pre + "con1.interfaces.";
 
 520         assertThat(ctx.getAttribute(pre + "con1.interface"), is(
 
 521                 "identity-types:physical"));
 
 522         assertThat(ctx.getAttribute(pre + "con1.interface"), is(
 
 523                 "identity-types:physical"));
 
 524         assertThat(ctx.getAttribute(pre1 + "int-list[0].iden"), is("optical"));
 
 525         assertThat(ctx.getAttribute(pre1 + "int-list[0].available.ll[0]"), is(
 
 527         assertThat(ctx.getAttribute(pre1 + "int-list[0].available.ll[1]"), is(
 
 528                 "identity-types:Loopback"));
 
 529         assertThat(ctx.getAttribute(pre1 + "int-list[0].available.ll[2]"), is(
 
 530                 "identity-types-second:Ethernet"));
 
 531         assertThat(ctx.getAttribute(pre1 + "int-list[0].available.leaf1"), is(
 
 533         assertThat(ctx.getAttribute(pre1 + "int-list[0].available.leaf2"), is(
 
 534                 "identity-types-second:iden2"));
 
 536         assertThat(ctx.getAttribute(pre1 + "int-list[1].iden"), is(
 
 538         assertThat(ctx.getAttribute(pre1 + "int-list[1].available.ll[0]"), is(
 
 540         assertThat(ctx.getAttribute(pre1 + "int-list[1].available.ll[1]"), is(
 
 541                 "identity-types:Loopback"));
 
 542         assertThat(ctx.getAttribute(pre1 + "int-list[1].available.ll[2]"), is(
 
 543                 "identity-types-second:Ethernet"));
 
 544         assertThat(ctx.getAttribute(pre1 + "int-list[1].available.leaf1"), is(
 
 546         assertThat(ctx.getAttribute(pre1 + "int-list[1].available.leaf2"), is(
 
 547                 "identity-types-second:iden2"));
 
 551      * Verifies the attribute list for decoding from JSON or XML with
 
 552      * container, grouping and augmented file.
 
 554      * @param ctx service logic context
 
 557     private void verifyAttListYang(SvcLogicContext ctx, String pre) {
 
 558         assertThat(ctx.getAttribute(pre + "cont3.leaf10"), is("abc"));
 
 559         assertThat(ctx.getAttribute(pre + "list1[0].leaf1"), is("true"));
 
 560         assertThat(ctx.getAttribute(pre + "list1[0].leaf2"), is("abc"));
 
 561         assertThat(ctx.getAttribute(pre + "list1[0].leaf3"), is("abc"));
 
 562         assertThat(ctx.getAttribute(pre + "list1[0].ll1[0]"), is("abc"));
 
 563         assertThat(ctx.getAttribute(pre + "list1[0].ll1[1]"), is("abc"));
 
 564         assertThat(ctx.getAttribute(pre + "list1[0].ll2[0]"), is("abc"));
 
 565         assertThat(ctx.getAttribute(pre + "list1[0].ll2[1]"), is("abc"));
 
 566         assertThat(ctx.getAttribute(pre + "list1[0].cont4.leaf11"), is("abc"));
 
 567         assertThat(ctx.getAttribute(pre + "list1[0].list4[0].leaf8"),
 
 569         assertThat(ctx.getAttribute(pre + "list1[0].list4[1].leaf8"),
 
 571         assertThat(ctx.getAttribute(pre + "list1[0].list5[0].leaf9"),
 
 573         assertThat(ctx.getAttribute(pre + "list1[0].list5[1].leaf9"),
 
 575         assertThat(ctx.getAttribute(pre + "list1[1].leaf1"), is("true"));
 
 576         assertThat(ctx.getAttribute(pre + "list1[1].leaf2"), is("abc"));
 
 577         assertThat(ctx.getAttribute(pre + "list1[1].leaf3"), is("abc"));
 
 578         assertThat(ctx.getAttribute(pre + "list1[1].ll1[0]"), is("abc"));
 
 579         assertThat(ctx.getAttribute(pre + "list1[1].ll1[1]"), is("abc"));
 
 580         assertThat(ctx.getAttribute(pre + "list1[1].ll2[0]"), is("abc"));
 
 581         assertThat(ctx.getAttribute(pre + "list1[1].ll2[1]"), is("abc"));
 
 582         assertThat(ctx.getAttribute(pre + "list1[1].cont4.leaf11"), is("abc"));
 
 583         assertThat(ctx.getAttribute(pre + "list1[1].list4[0].leaf8"),
 
 585         assertThat(ctx.getAttribute(pre + "list1[1].list4[1].leaf8"),
 
 587         assertThat(ctx.getAttribute(pre + "list1[1].list5[0].leaf9"),
 
 589         assertThat(ctx.getAttribute(pre + "list1[1].list5[1].leaf9"),
 
 591         assertThat(ctx.getAttribute(pre + "list2[0].leaf4"), is("abc"));
 
 592         assertThat(ctx.getAttribute(pre + "list2[1].leaf4"), is("abc"));
 
 593         assertThat(ctx.getAttribute(pre + "leaf5"), is("abc"));
 
 594         assertThat(ctx.getAttribute(pre + "leaf6"), is("abc"));
 
 595         assertThat(ctx.getAttribute(pre + "ll3[0]"), is("abc"));
 
 596         assertThat(ctx.getAttribute(pre + "ll3[1]"), is("abc"));
 
 597         assertThat(ctx.getAttribute(pre + "ll4[0]"), is("abc"));
 
 598         assertThat(ctx.getAttribute(pre + "ll4[1]"), is("abc"));
 
 599         assertThat(ctx.getAttribute(pre + "cont4.leaf10"), is( "abc"));
 
 600         assertThat(ctx.getAttribute(pre + "list6[0].leaf11"), is("abc"));
 
 601         assertThat(ctx.getAttribute(pre + "list6[1].leaf11"), is("abc"));
 
 602         assertThat(ctx.getAttribute(pre + "leaf12"), is("abc"));
 
 603         assertThat(ctx.getAttribute(pre + "ll5[0]"), is("abc"));
 
 604         assertThat(ctx.getAttribute(pre + "ll5[1]"), is("abc"));
 
 605         assertThat(ctx.getAttribute(pre + "cont4.test-augment:cont5.leaf13"),
 
 607         assertThat(ctx.getAttribute(pre + "cont4.test-augment:list7[0].leaf14"),
 
 609         assertThat(ctx.getAttribute(pre + "cont4.test-augment:list7[1].leaf14"),
 
 611         assertThat(ctx.getAttribute(pre + "cont4.test-augment:leaf15"),
 
 613         assertThat(ctx.getAttribute(pre + "cont4.test-augment:ll6[0]"),
 
 615         assertThat(ctx.getAttribute(pre + "cont4.test-augment:ll6[1]"),
 
 617         assertThat(ctx.getAttribute(pre + "cont4.test-augment:cont13" +
 
 618                                             ".cont12.leaf26"), is("abc"));
 
 619         assertThat(ctx.getAttribute(pre + "cont4.test-augment:cont13.list9[0]" +
 
 620                                             ".leaf27"), is("abc"));
 
 621         assertThat(ctx.getAttribute(pre + "cont4.test-augment:cont13.list9[1]" +
 
 622                                             ".leaf27"), is("abc"));
 
 623         assertThat(ctx.getAttribute(pre + "cont4.test-augment:cont13.leaf28"),
 
 625         assertThat(ctx.getAttribute(pre + "cont4.test-augment:cont13.ll9[0]"),
 
 627         assertThat(ctx.getAttribute(pre + "cont4.test-augment:cont13.ll9[1]"),
 
 632      * Verifies the attribute list for decoding from JSON or XML with
 
 635      * @param ctx service logic context
 
 638     private void verifyAttListRpc(SvcLogicContext ctx, String pre) {
 
 639         assertThat(ctx.getAttribute(pre + "cont16.leaf32"), is("abc"));
 
 640         assertThat(ctx.getAttribute(pre + "list11[0].leaf33"), is("abc"));
 
 641         assertThat(ctx.getAttribute(pre + "list11[1].leaf33"), is("abc"));
 
 642         assertThat(ctx.getAttribute(pre + "leaf34"), is("abc"));
 
 643         assertThat(ctx.getAttribute(pre + "ll11[0]"), is("abc"));
 
 644         assertThat(ctx.getAttribute(pre + "ll11[1]"), is("abc"));
 
 645         assertThat(ctx.getAttribute(pre + "cont17.leaf35"), is("abc"));
 
 646         assertThat(ctx.getAttribute(pre + "cont13.cont12.leaf26"), is("abc"));
 
 647         assertThat(ctx.getAttribute(pre + "cont13.list9[0].leaf27"), is("abc"));
 
 648         assertThat(ctx.getAttribute(pre + "cont13.list9[1].leaf27"), is("abc"));
 
 649         assertThat(ctx.getAttribute(pre + "cont13.ll9[0]"), is("abc"));
 
 650         assertThat(ctx.getAttribute(pre + "cont13.ll9[1]"), is("abc"));
 
 651         assertThat(ctx.getAttribute(pre + "cont13.leaf28"), is("abc"));
 
 655      * Captures the data format messages by mocking it, which can be used in
 
 658      * @param <String> capturing data format
 
 660     public class DfCaptor<String> implements Answer {
 
 662         private String result;
 
 665          * Returns the captured data format message.
 
 667          * @return data format message.
 
 669         public String getResult() {
 
 674         public String answer(InvocationOnMock invocationOnMock)
 
 676             result = (String) invocationOnMock.callRealMethod();