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_XML_ID;
 
  54 import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DataFormatUtilsTest.ENCODE_TO_XML_RPC;
 
  55 import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DataFormatUtilsTest.ENCODE_TO_XML_YANG;
 
  59  * Unit test cases for data format serialization and restconf api call node.
 
  61 public class DataFormatSerializerTest {
 
  63     private Map<String, String> p;
 
  65     private RestconfApiCallNode restconf;
 
  67     private RestapiCallNode restApi;
 
  69     private DfCaptor dfCaptor;
 
  72      * Sets up the pre-requisite for each test case.
 
  74      * @throws SvcLogicException when test case fails
 
  77     public void setUp() throws SvcLogicException {
 
  79         p.put("restapiUser", "user1");
 
  80         p.put("restapiPassword", "abc123");
 
  81         p.put("responsePrefix", "response");
 
  82         p.put("skipSending", "true");
 
  83         restApi = new RestapiCallNode();
 
  84         restconf = mock(RestconfApiCallNode.class);
 
  85         dfCaptor = new DfCaptor();
 
  90      * Creates method mocks using mockito for RestconfApiCallNode class.
 
  92      * @throws SvcLogicException when test case fails
 
  94     private void createMethodMocks() throws SvcLogicException {
 
  95         doReturn(restApi).when(restconf).getRestapiCallNode();
 
  96         doCallRealMethod().when(restconf).sendRequest(
 
  97                 any(Map.class), any(SvcLogicContext.class));
 
  98         doCallRealMethod().when(restconf).sendRequest(
 
  99                 any(Map.class), any(SvcLogicContext.class), any(Integer.class));
 
 100         doAnswer(dfCaptor).when(restconf).serializeRequest(
 
 101                 any(Map.class), any(YangParameters.class), any(String.class),
 
 102                 any(InstanceIdentifierContext.class));
 
 106      * Creates mock using mockito with input data for decoding.
 
 108      * @param decodeData input data
 
 109      * @throws SvcLogicException when test case fails
 
 111     private void createMockForDecode(String decodeData)
 
 112             throws SvcLogicException {
 
 113         doReturn(decodeData).when(restconf).getResponse(
 
 114                 any(SvcLogicContext.class), any(YangParameters.class),
 
 115                 any(String.class), any(HttpResponse.class));
 
 116         doCallRealMethod().when(restconf).serializeResponse(
 
 117                 any(YangParameters.class), any(String.class), any(String.class),
 
 118                 any(InstanceIdentifierContext.class));
 
 122      * Verifies encoding of parameters to JSON data format with identity-ref
 
 123      * and inter-file linking.
 
 125      * @throws SvcLogicException when test case fails
 
 128     public void encodeToJsonId() throws SvcLogicException {
 
 129         String pre = "identity-test:test.";
 
 130         SvcLogicContext ctx = createAttList(pre);
 
 131         ctx.setAttribute(pre + "l", "abc");
 
 132         p.put("dirPath", "src/test/resources");
 
 133         p.put("format", "json");
 
 134         p.put("httpMethod", "post");
 
 135         p.put("restapiUrl", "http://echo.getpostman" +
 
 136                 ".com/restconf/operations/identity-test:test");
 
 137         restconf.sendRequest(p, ctx);
 
 138         assertThat(dfCaptor.getResult(), is(ENCODE_TO_JSON_ID));
 
 142      * Verifies encoding of parameters to XML data format with identity-ref
 
 143      * and inter-file linking.
 
 145      * @throws SvcLogicException when test case fails
 
 148     public void encodeToXmlId() throws SvcLogicException {
 
 149         String pre = "identity-test:test.";
 
 150         SvcLogicContext ctx = createAttList(pre);
 
 151         p.put("dirPath", "src/test/resources");
 
 152         p.put("format", "xml");
 
 153         p.put("httpMethod", "post");
 
 154         p.put("restapiUrl", "http://echo.getpostman" +
 
 155                 ".com/restconf/operations/identity-test:test");
 
 156         restconf.sendRequest(p, ctx);
 
 157         assertThat(dfCaptor.getResult(), is(ENCODE_TO_XML_ID));
 
 161      * Verifies decoding of parameters from JSON data format with identity-ref
 
 162      * and inter-file linking.
 
 164      * @throws SvcLogicException when test case fails
 
 167     public void decodeToJsonId() throws SvcLogicException {
 
 168         createMockForDecode(ENCODE_TO_JSON_ID);
 
 169         SvcLogicContext ctx = new SvcLogicContext();
 
 170         String pre = "identity-test:test.";
 
 171         p.put("dirPath", "src/test/resources");
 
 172         p.put("format", "json");
 
 173         p.put("httpMethod", "get");
 
 174         p.put("restapiUrl", "http://echo.getpostman" +
 
 175                 ".com/restconf/operations/identity-test:test");
 
 176         restconf.sendRequest(p, ctx);
 
 177         assertThat(ctx.getAttribute(pre + "l"), is("abc"));
 
 178         verifyAttList(ctx, pre);
 
 182      * Verifies decoding of parameters from XML data format with identity-ref
 
 183      * and inter-file linking.
 
 185      * @throws SvcLogicException when test case fails
 
 188     public void decodeToXmlId() throws SvcLogicException {
 
 189         createMockForDecode(ENCODE_TO_XML_ID);
 
 190         SvcLogicContext ctx = new SvcLogicContext();
 
 191         String pre = "identity-test:test.";
 
 192         p.put("dirPath", "src/test/resources");
 
 193         p.put("format", "xml");
 
 194         p.put("httpMethod", "get");
 
 195         p.put("restapiUrl", "http://echo.getpostman" +
 
 196                 ".com/restconf/operations/identity-test:test");
 
 197         restconf.sendRequest(p, ctx);
 
 198         verifyAttList(ctx, pre);
 
 202      * Verifies encoding of parameters to JSON data format with containers,
 
 203      * grouping and augment.
 
 205      * @throws SvcLogicException when test case fails
 
 208     public void encodeToJsonYang() throws SvcLogicException {
 
 209         String pre = "test-yang:cont1.cont2.";
 
 210         SvcLogicContext ctx = createAttListYang(pre);
 
 211         p.put("dirPath", "src/test/resources");
 
 212         p.put("format", "json");
 
 213         p.put("httpMethod", "post");
 
 214         p.put("restapiUrl", "http://echo.getpostman" +
 
 215                 ".com/restconf/operations/test-yang:cont1");
 
 216         restconf.sendRequest(p, ctx);
 
 217         assertThat(dfCaptor.getResult(), is(ENCODE_TO_JSON_YANG));
 
 221      * Verifies decoding of parameters from JSON data format with containers,
 
 222      * grouping and augment.
 
 224      * @throws SvcLogicException when test case fails
 
 227     public void decodeToJsonYang() throws SvcLogicException {
 
 228         createMockForDecode(ENCODE_TO_JSON_YANG);
 
 229         SvcLogicContext ctx = new SvcLogicContext();
 
 230         String pre = "test-yang:cont1.cont2.";
 
 231         p.put("dirPath", "src/test/resources");
 
 232         p.put("format", "json");
 
 233         p.put("httpMethod", "get");
 
 234         p.put("restapiUrl", "http://echo.getpostman" +
 
 235                 ".com/restconf/operations/test-yang:cont1");
 
 236         restconf.sendRequest(p, ctx);
 
 237         verifyAttListYang(ctx, pre);
 
 241      * Verifies encoding of parameters to XML data format with containers,
 
 242      * grouping and augment.
 
 244      * @throws SvcLogicException when test case fails
 
 247     public void encodeToXmlYang() throws SvcLogicException {
 
 248         String pre = "test-yang:cont1.cont2.";
 
 249         SvcLogicContext ctx = createAttListYang(pre);
 
 250         p.put("dirPath", "src/test/resources");
 
 251         p.put("format", "xml");
 
 252         p.put("httpMethod", "post");
 
 253         p.put("restapiUrl", "http://echo.getpostman" +
 
 254                 ".com/restconf/operations/test-yang:cont1");
 
 255         restconf.sendRequest(p, ctx);
 
 256         assertThat(dfCaptor.getResult(), is(ENCODE_TO_XML_YANG));
 
 260      * Verifies decoding of parameters from XML data format with containers,
 
 261      * grouping and augment.
 
 263      * @throws SvcLogicException when test case fails
 
 266     public void decodeToXmlYang() throws SvcLogicException {
 
 267         createMockForDecode(ENCODE_TO_XML_YANG);
 
 268         SvcLogicContext ctx = new SvcLogicContext();
 
 269         String pre = "test-yang:cont1.cont2.";
 
 270         p.put("dirPath", "src/test/resources");
 
 271         p.put("format", "xml");
 
 272         p.put("httpMethod", "get");
 
 273         p.put("restapiUrl", "http://echo.getpostman" +
 
 274                 ".com/restconf/operations/test-yang:cont1");
 
 275         restconf.sendRequest(p, ctx);
 
 276         verifyAttListYang(ctx, pre);
 
 280      * Verifies encoding of and decoding from, JSON respectively for data
 
 281      * format with containers, grouping and augment.
 
 283      * @throws SvcLogicException when test case fails
 
 286     public void codecToJsonRpc() throws SvcLogicException {
 
 287         createMockForDecode(DECODE_FROM_JSON_RPC);
 
 288         String inPre = "test-yang:create-sfc.input.";
 
 289         String outPre = "test-yang:create-sfc.output.";
 
 290         SvcLogicContext ctx = createAttListRpc(inPre);
 
 291         p.put("dirPath", "src/test/resources");
 
 292         p.put("format", "json");
 
 293         p.put("httpMethod", "post");
 
 294         p.put("restapiUrl", "http://echo.getpostman" +
 
 295                 ".com/restconf/operations/test-yang:create-sfc");
 
 296         restconf.sendRequest(p, ctx);
 
 297         assertThat(dfCaptor.getResult(), is(ENCODE_TO_JSON_RPC));
 
 298         verifyAttListRpc(ctx, outPre);
 
 302      * Verifies encoding of and decoding from, XML respectively for data
 
 303      * format with containers, grouping and augment.
 
 305      * @throws SvcLogicException when test case fails
 
 308     public void codecToXmlRpc() throws SvcLogicException {
 
 309         createMockForDecode(DECODE_FROM_XML_RPC);
 
 310         String inPre = "test-yang:create-sfc.input.";
 
 311         String outPre = "test-yang:create-sfc.output.";
 
 312         SvcLogicContext ctx = createAttListRpc(inPre);
 
 313         p.put("dirPath", "src/test/resources");
 
 314         p.put("format", "xml");
 
 315         p.put("httpMethod", "post");
 
 316         p.put("restapiUrl", "http://echo.getpostman" +
 
 317                 ".com/restconf/operations/test-yang:create-sfc");
 
 318         restconf.sendRequest(p, ctx);
 
 319         assertThat(dfCaptor.getResult(), is(ENCODE_TO_XML_RPC));
 
 320         verifyAttListRpc(ctx, outPre);
 
 324      * Verifies URL parser returning path with only schema information for all
 
 327      * @throws SvcLogicException when test case fails
 
 330     public void validateUrlParser() throws SvcLogicException {
 
 331         String actVal = "identity-test:test";
 
 332         String url1 = "http://echo.getpostman.com/restconf/operations/" +
 
 334         String url2 = "http://echo.getpostman.com/restconf/data/" + actVal;
 
 335         String url3 = "https://echo.getpostman.com/restconf/operations/" +
 
 337         String url4 = "https://echo.getpostman.com/restconf/data/" + actVal +
 
 339         String url5 = "http://localhost:8282/restconf/operations/" + actVal;
 
 340         String url6 = "https://localhost:8282/restconf/operations/" + actVal;
 
 341         String url7 = "http://localhost:8282/restconf/data/" + actVal +
 
 343         String url8 = "https://localhost:8282/restconf/data/" + actVal;
 
 344         String url9 = "http://182.2.61.24:2250/restconf/data/" + actVal;
 
 345         String url10 = "https://182.2.61.24:2250/restconf/operations/" + actVal;
 
 346         String val1 = parseUrl(url1, POST);
 
 347         String val2 = parseUrl(url2, GET);
 
 348         String val3 = parseUrl(url3, POST);
 
 349         String val4 = parseUrl(url4, PUT);
 
 350         String val5 = parseUrl(url5, GET);
 
 351         String val6 = parseUrl(url6, POST);
 
 352         String val7 = parseUrl(url7, PUT);
 
 353         String val8 = parseUrl(url8, POST);
 
 354         String val9 = parseUrl(url9, GET);
 
 355         String val10 = parseUrl(url10, POST);
 
 356         assertThat(val1, is(actVal));
 
 357         assertThat(val2, is(actVal));
 
 358         assertThat(val3, is(actVal));
 
 359         assertThat(val4, is(actVal));
 
 360         assertThat(val5, is(actVal));
 
 361         assertThat(val6, is(actVal));
 
 362         assertThat(val7, is(actVal));
 
 363         assertThat(val8, is(actVal));
 
 364         assertThat(val9, is(actVal));
 
 365         assertThat(val10, is(actVal));
 
 369      * Creates attribute list for encoding JSON or XML with identity-ref YANG
 
 373      * @return service logic context
 
 375     private SvcLogicContext createAttList(String pre) {
 
 376         SvcLogicContext ctx = new SvcLogicContext();
 
 377         String pre1 = pre + "con1.interfaces.";
 
 378         ctx.setAttribute(pre + "con1.interface", "identity-types:physical");
 
 379         ctx.setAttribute(pre1 + "int-list[0].iden", "optical");
 
 380         ctx.setAttribute(pre1 + "int-list[0].available.ll[0]", "Giga");
 
 381         ctx.setAttribute(pre1 + "int-list[0].available.ll[1]",
 
 382                          "identity-types:Loopback");
 
 383         ctx.setAttribute(pre1 + "int-list[0].available.ll[2]",
 
 384                          "identity-types-second:Ethernet");
 
 385         ctx.setAttribute(pre1 + "int-list[0].available.leaf1", "58");
 
 386         ctx.setAttribute(pre1 + "int-list[0].available.leaf2",
 
 387                          "identity-types-second:iden2");
 
 389         ctx.setAttribute(pre1 + "int-list[1].iden", "214748364");
 
 390         ctx.setAttribute(pre1 + "int-list[1].available.ll[0]", "Giga");
 
 391         ctx.setAttribute(pre1 + "int-list[1].available.ll[1]",
 
 392                          "identity-types:Loopback");
 
 393         ctx.setAttribute(pre1 + "int-list[1].available.ll[2]",
 
 394                          "identity-types-second:Ethernet");
 
 395         ctx.setAttribute(pre1 + "int-list[1].available.leaf1",
 
 397         ctx.setAttribute(pre1 + "int-list[1].available.leaf2",
 
 398                          "identity-types-second:iden2");
 
 403      * Creates attribute list for encoding JSON or XML with container,
 
 404      * grouping and augmented YANG file.
 
 407      * @return service logic context
 
 409     private SvcLogicContext createAttListYang(String pre) {
 
 410         SvcLogicContext ctx = new SvcLogicContext();
 
 411         ctx.setAttribute(pre + "cont3.leaf10", "abc");
 
 412         ctx.setAttribute(pre + "list1[0].leaf1", "true");
 
 413         ctx.setAttribute(pre + "list1[0].leaf2", "abc");
 
 414         ctx.setAttribute(pre + "list1[0].leaf3", "abc");
 
 415         ctx.setAttribute(pre + "list1[0].ll1[0]", "abc");
 
 416         ctx.setAttribute(pre + "list1[0].ll1[1]", "abc");
 
 417         ctx.setAttribute(pre + "list1[0].ll2[0]", "abc");
 
 418         ctx.setAttribute(pre + "list1[0].ll2[1]", "abc");
 
 419         ctx.setAttribute(pre + "list1[0].cont4.leaf11", "abc");
 
 420         ctx.setAttribute(pre + "list1[0].list4[0].leaf8", "abc");
 
 421         ctx.setAttribute(pre + "list1[0].list4[1].leaf8", "abc");
 
 422         ctx.setAttribute(pre + "list1[0].list5[0].leaf9", "abc");
 
 423         ctx.setAttribute(pre + "list1[0].list5[1].leaf9", "abc");
 
 424         ctx.setAttribute(pre + "list1[1].leaf1", "true");
 
 425         ctx.setAttribute(pre + "list1[1].leaf2", "abc");
 
 426         ctx.setAttribute(pre + "list1[1].leaf3", "abc");
 
 427         ctx.setAttribute(pre + "list1[1].ll1[0]", "abc");
 
 428         ctx.setAttribute(pre + "list1[1].ll1[1]", "abc");
 
 429         ctx.setAttribute(pre + "list1[1].ll2[0]", "abc");
 
 430         ctx.setAttribute(pre + "list1[1].ll2[1]", "abc");
 
 431         ctx.setAttribute(pre + "list1[1].cont4.leaf11", "abc");
 
 432         ctx.setAttribute(pre + "list1[1].list4[0].leaf8", "abc");
 
 433         ctx.setAttribute(pre + "list1[1].list4[1].leaf8", "abc");
 
 434         ctx.setAttribute(pre + "list1[1].list5[0].leaf9", "abc");
 
 435         ctx.setAttribute(pre + "list1[1].list5[1].leaf9", "abc");
 
 436         ctx.setAttribute(pre + "list2[0].leaf4", "abc");
 
 437         ctx.setAttribute(pre + "list2[1].leaf4", "abc");
 
 438         ctx.setAttribute(pre + "leaf5", "abc");
 
 439         ctx.setAttribute(pre + "leaf6", "abc");
 
 440         ctx.setAttribute(pre + "ll3[0]", "abc");
 
 441         ctx.setAttribute(pre + "ll3[1]", "abc");
 
 442         ctx.setAttribute(pre + "ll4[0]", "abc");
 
 443         ctx.setAttribute(pre + "ll4[1]", "abc");
 
 444         ctx.setAttribute(pre + "cont4.leaf10", "abc");
 
 445         ctx.setAttribute(pre + "list6[0].leaf11", "abc");
 
 446         ctx.setAttribute(pre + "list6[1].leaf11", "abc");
 
 447         ctx.setAttribute(pre + "leaf12", "abc");
 
 448         ctx.setAttribute(pre + "ll5[0]", "abc");
 
 449         ctx.setAttribute(pre + "ll5[1]", "abc");
 
 450         ctx.setAttribute(pre + "cont4.test-augment:cont5.leaf13", "true");
 
 451         ctx.setAttribute(pre + "cont4.test-augment:list7[0].leaf14", "test");
 
 452         ctx.setAttribute(pre + "cont4.test-augment:list7[1].leaf14", "create");
 
 453         ctx.setAttribute(pre + "cont4.test-augment:leaf15", "abc");
 
 454         ctx.setAttribute(pre + "cont4.test-augment:ll6[0]", "unbounded");
 
 455         ctx.setAttribute(pre + "cont4.test-augment:ll6[1]", "8");
 
 456         ctx.setAttribute(pre + "cont4.test-augment:cont13.cont12.leaf26",
 
 458         ctx.setAttribute(pre + "cont4.test-augment:cont13.list9[0].leaf27",
 
 460         ctx.setAttribute(pre + "cont4.test-augment:cont13.list9[1].leaf27",
 
 462         ctx.setAttribute(pre + "cont4.test-augment:cont13.leaf28", "abc");
 
 463         ctx.setAttribute(pre + "cont4.test-augment:cont13.ll9[0]", "abc");
 
 464         ctx.setAttribute(pre + "cont4.test-augment:cont13.ll9[1]", "abc");
 
 469      * Creates attribute list for encoding JSON or XML with RPC YANG file.
 
 472      * @return service logic context
 
 474     private SvcLogicContext createAttListRpc(String pre) {
 
 475         SvcLogicContext ctx = new SvcLogicContext();
 
 476         ctx.setAttribute(pre + "cont14.leaf28", "abc");
 
 477         ctx.setAttribute(pre + "list10[0].leaf29", "abc");
 
 478         ctx.setAttribute(pre + "list10[1].leaf29", "abc");
 
 479         ctx.setAttribute(pre + "leaf30", "abc");
 
 480         ctx.setAttribute(pre + "ll10[0]", "abc");
 
 481         ctx.setAttribute(pre + "ll10[1]", "abc");
 
 482         ctx.setAttribute(pre + "cont15.leaf31", "abc");
 
 483         ctx.setAttribute(pre + "cont13.list9[0].leaf27", "abc");
 
 484         ctx.setAttribute(pre + "cont13.list9[1].leaf27", "abc");
 
 485         ctx.setAttribute(pre + "cont13.leaf28", "abc");
 
 486         ctx.setAttribute(pre + "cont13.ll9[0]", "abc");
 
 487         ctx.setAttribute(pre + "cont13.ll9[1]", "abc");
 
 492      * Verifies the attribute list for decoding from JSON or XML with
 
 493      * identity-ref YANG file.
 
 495      * @param ctx service logic context
 
 498     private void verifyAttList(SvcLogicContext ctx, String pre) {
 
 499         String pre1 = pre + "con1.interfaces.";
 
 500         assertThat(ctx.getAttribute(pre + "con1.interface"), is(
 
 501                 "identity-types:physical"));
 
 502         assertThat(ctx.getAttribute(pre + "con1.interface"), is(
 
 503                 "identity-types:physical"));
 
 504         assertThat(ctx.getAttribute(pre1 + "int-list[0].iden"), is("optical"));
 
 505         assertThat(ctx.getAttribute(pre1 + "int-list[0].available.ll[0]"), is(
 
 507         assertThat(ctx.getAttribute(pre1 + "int-list[0].available.ll[1]"), is(
 
 508                 "identity-types:Loopback"));
 
 509         assertThat(ctx.getAttribute(pre1 + "int-list[0].available.ll[2]"), is(
 
 510                 "identity-types-second:Ethernet"));
 
 511         assertThat(ctx.getAttribute(pre1 + "int-list[0].available.leaf1"), is(
 
 513         assertThat(ctx.getAttribute(pre1 + "int-list[0].available.leaf2"), is(
 
 514                 "identity-types-second:iden2"));
 
 516         assertThat(ctx.getAttribute(pre1 + "int-list[1].iden"), is(
 
 518         assertThat(ctx.getAttribute(pre1 + "int-list[1].available.ll[0]"), is(
 
 520         assertThat(ctx.getAttribute(pre1 + "int-list[1].available.ll[1]"), is(
 
 521                 "identity-types:Loopback"));
 
 522         assertThat(ctx.getAttribute(pre1 + "int-list[1].available.ll[2]"), is(
 
 523                 "identity-types-second:Ethernet"));
 
 524         assertThat(ctx.getAttribute(pre1 + "int-list[1].available.leaf1"), is(
 
 526         assertThat(ctx.getAttribute(pre1 + "int-list[1].available.leaf2"), is(
 
 527                 "identity-types-second:iden2"));
 
 531      * Verifies the attribute list for decoding from JSON or XML with
 
 532      * container, grouping and augmented file.
 
 534      * @param ctx service logic context
 
 537     private void verifyAttListYang(SvcLogicContext ctx, String pre) {
 
 538         assertThat(ctx.getAttribute(pre + "cont3.leaf10"), is("abc"));
 
 539         assertThat(ctx.getAttribute(pre + "list1[0].leaf1"), is("true"));
 
 540         assertThat(ctx.getAttribute(pre + "list1[0].leaf2"), is("abc"));
 
 541         assertThat(ctx.getAttribute(pre + "list1[0].leaf3"), is("abc"));
 
 542         assertThat(ctx.getAttribute(pre + "list1[0].ll1[0]"), is("abc"));
 
 543         assertThat(ctx.getAttribute(pre + "list1[0].ll1[1]"), is("abc"));
 
 544         assertThat(ctx.getAttribute(pre + "list1[0].ll2[0]"), is("abc"));
 
 545         assertThat(ctx.getAttribute(pre + "list1[0].ll2[1]"), is("abc"));
 
 546         assertThat(ctx.getAttribute(pre + "list1[0].cont4.leaf11"), is("abc"));
 
 547         assertThat(ctx.getAttribute(pre + "list1[0].list4[0].leaf8"),
 
 549         assertThat(ctx.getAttribute(pre + "list1[0].list4[1].leaf8"),
 
 551         assertThat(ctx.getAttribute(pre + "list1[0].list5[0].leaf9"),
 
 553         assertThat(ctx.getAttribute(pre + "list1[0].list5[1].leaf9"),
 
 555         assertThat(ctx.getAttribute(pre + "list1[1].leaf1"), is("true"));
 
 556         assertThat(ctx.getAttribute(pre + "list1[1].leaf2"), is("abc"));
 
 557         assertThat(ctx.getAttribute(pre + "list1[1].leaf3"), is("abc"));
 
 558         assertThat(ctx.getAttribute(pre + "list1[1].ll1[0]"), is("abc"));
 
 559         assertThat(ctx.getAttribute(pre + "list1[1].ll1[1]"), is("abc"));
 
 560         assertThat(ctx.getAttribute(pre + "list1[1].ll2[0]"), is("abc"));
 
 561         assertThat(ctx.getAttribute(pre + "list1[1].ll2[1]"), is("abc"));
 
 562         assertThat(ctx.getAttribute(pre + "list1[1].cont4.leaf11"), is("abc"));
 
 563         assertThat(ctx.getAttribute(pre + "list1[1].list4[0].leaf8"),
 
 565         assertThat(ctx.getAttribute(pre + "list1[1].list4[1].leaf8"),
 
 567         assertThat(ctx.getAttribute(pre + "list1[1].list5[0].leaf9"),
 
 569         assertThat(ctx.getAttribute(pre + "list1[1].list5[1].leaf9"),
 
 571         assertThat(ctx.getAttribute(pre + "list2[0].leaf4"), is("abc"));
 
 572         assertThat(ctx.getAttribute(pre + "list2[1].leaf4"), is("abc"));
 
 573         assertThat(ctx.getAttribute(pre + "leaf5"), is("abc"));
 
 574         assertThat(ctx.getAttribute(pre + "leaf6"), is("abc"));
 
 575         assertThat(ctx.getAttribute(pre + "ll3[0]"), is("abc"));
 
 576         assertThat(ctx.getAttribute(pre + "ll3[1]"), is("abc"));
 
 577         assertThat(ctx.getAttribute(pre + "ll4[0]"), is("abc"));
 
 578         assertThat(ctx.getAttribute(pre + "ll4[1]"), is("abc"));
 
 579         assertThat(ctx.getAttribute(pre + "cont4.leaf10"), is( "abc"));
 
 580         assertThat(ctx.getAttribute(pre + "list6[0].leaf11"), is("abc"));
 
 581         assertThat(ctx.getAttribute(pre + "list6[1].leaf11"), is("abc"));
 
 582         assertThat(ctx.getAttribute(pre + "leaf12"), is("abc"));
 
 583         assertThat(ctx.getAttribute(pre + "ll5[0]"), is("abc"));
 
 584         assertThat(ctx.getAttribute(pre + "ll5[1]"), is("abc"));
 
 585         assertThat(ctx.getAttribute(pre + "cont4.test-augment:cont5.leaf13"),
 
 587         assertThat(ctx.getAttribute(pre + "cont4.test-augment:list7[0].leaf14"),
 
 589         assertThat(ctx.getAttribute(pre + "cont4.test-augment:list7[1].leaf14"),
 
 591         assertThat(ctx.getAttribute(pre + "cont4.test-augment:leaf15"),
 
 593         assertThat(ctx.getAttribute(pre + "cont4.test-augment:ll6[0]"),
 
 595         assertThat(ctx.getAttribute(pre + "cont4.test-augment:ll6[1]"),
 
 597         assertThat(ctx.getAttribute(pre + "cont4.test-augment:cont13" +
 
 598                                             ".cont12.leaf26"), is("abc"));
 
 599         assertThat(ctx.getAttribute(pre + "cont4.test-augment:cont13.list9[0]" +
 
 600                                             ".leaf27"), is("abc"));
 
 601         assertThat(ctx.getAttribute(pre + "cont4.test-augment:cont13.list9[1]" +
 
 602                                             ".leaf27"), is("abc"));
 
 603         assertThat(ctx.getAttribute(pre + "cont4.test-augment:cont13.leaf28"),
 
 605         assertThat(ctx.getAttribute(pre + "cont4.test-augment:cont13.ll9[0]"),
 
 607         assertThat(ctx.getAttribute(pre + "cont4.test-augment:cont13.ll9[1]"),
 
 612      * Verifies the attribute list for decoding from JSON or XML with
 
 615      * @param ctx service logic context
 
 618     private void verifyAttListRpc(SvcLogicContext ctx, String pre) {
 
 619         assertThat(ctx.getAttribute(pre + "cont16.leaf32"), is("abc"));
 
 620         assertThat(ctx.getAttribute(pre + "list11[0].leaf33"), is("abc"));
 
 621         assertThat(ctx.getAttribute(pre + "list11[1].leaf33"), is("abc"));
 
 622         assertThat(ctx.getAttribute(pre + "leaf34"), is("abc"));
 
 623         assertThat(ctx.getAttribute(pre + "ll11[0]"), is("abc"));
 
 624         assertThat(ctx.getAttribute(pre + "ll11[1]"), is("abc"));
 
 625         assertThat(ctx.getAttribute(pre + "cont17.leaf35"), is("abc"));
 
 626         assertThat(ctx.getAttribute(pre + "cont13.cont12.leaf26"), is("abc"));
 
 627         assertThat(ctx.getAttribute(pre + "cont13.list9[0].leaf27"), is("abc"));
 
 628         assertThat(ctx.getAttribute(pre + "cont13.list9[1].leaf27"), is("abc"));
 
 629         assertThat(ctx.getAttribute(pre + "cont13.ll9[0]"), is("abc"));
 
 630         assertThat(ctx.getAttribute(pre + "cont13.ll9[1]"), is("abc"));
 
 631         assertThat(ctx.getAttribute(pre + "cont13.leaf28"), is("abc"));
 
 635      * Captures the data format messages by mocking it, which can be used in
 
 638      * @param <String> capturing data format
 
 640     public class DfCaptor<String> implements Answer {
 
 642         private String result;
 
 645          * Returns the captured data format message.
 
 647          * @return data format message.
 
 649         public String getResult() {
 
 654         public String answer(InvocationOnMock invocationOnMock)
 
 656             result = (String) invocationOnMock.callRealMethod();