2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2019 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 java.util.HashMap;
26 import org.junit.Before;
27 import org.junit.Test;
28 import org.mockito.invocation.InvocationOnMock;
29 import org.mockito.stubbing.Answer;
30 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
31 import org.onap.ccsdk.sli.core.sli.SvcLogicException;
32 import org.onap.ccsdk.sli.plugins.restapicall.HttpResponse;
33 import org.onap.ccsdk.sli.plugins.restapicall.RestapiCallNode;
34 import org.onap.ccsdk.sli.plugins.restconfapicall.RestconfApiCallNode;
35 import org.opendaylight.restconf.common.context.InstanceIdentifierContext;
36 import org.opendaylight.yangtools.yang.model.parser.api.YangParserFactory;
37 import org.opendaylight.yangtools.yang.parser.impl.YangParserFactoryImpl;
39 import static org.hamcrest.MatcherAssert.assertThat;
40 import static org.hamcrest.core.Is.is;
41 import static org.mockito.Matchers.any;
42 import static org.mockito.Mockito.doAnswer;
43 import static org.mockito.Mockito.doCallRealMethod;
44 import static org.mockito.Mockito.doReturn;
45 import static org.mockito.Mockito.mock;
46 import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.IdentifierValidationUtilsTest.DECODE_FROM_JSON_RPC_ID;
47 import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.IdentifierValidationUtilsTest.DECODE_FROM_XML_RPC_ID;
48 import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.IdentifierValidationUtilsTest.ENCODE_TO_JSON_RPC_ID;
49 import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.IdentifierValidationUtilsTest.ENCODE_TO_JSON_WITH_AUG_PATH;
50 import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.IdentifierValidationUtilsTest.ENCODE_TO_JSON_YANG_AUG_POST_ID;
51 import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.IdentifierValidationUtilsTest.ENCODE_TO_JSON_YANG_ID;
52 import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.IdentifierValidationUtilsTest.ENCODE_TO_JSON_YANG_PUT_ID;
53 import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.IdentifierValidationUtilsTest.ENCODE_TO_XML_RPC_ID;
54 import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.IdentifierValidationUtilsTest.ENCODE_TO_XML_YANG_AUG_POST_ID;
55 import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.IdentifierValidationUtilsTest.ENCODE_TO_XML_YANG_ID;
56 import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.IdentifierValidationUtilsTest.ENCODE_TO_XML_YANG_PUT_ID;
59 * Unit test cases for identifier validation test.
61 public class IdentifierValidationTest {
63 private Map<String, String> p;
65 private RestconfApiCallNode restconf;
67 private RestapiCallNode restApi;
69 private YangParserFactory parserFactory;
71 private DfCaptor dfCaptor;
74 * Sets up the pre-requisite for each test case.
76 * @throws SvcLogicException when test case fails
79 public void setUp() throws SvcLogicException {
81 p.put("restapiUser", "user1");
82 p.put("restapiPassword", "abc123");
83 p.put("responsePrefix", "response");
84 p.put("skipSending", "true");
85 restApi = new RestapiCallNode();
86 parserFactory = new YangParserFactoryImpl();
87 restconf = mock(RestconfApiCallNode.class);
88 dfCaptor = new DfCaptor();
93 * Creates method mocks using mockito for RestconfApiCallNode class.
95 * @throws SvcLogicException when test case fails
97 private void createMethodMocks() throws SvcLogicException {
98 doReturn(restApi).when(restconf).getRestapiCallNode();
99 doReturn(parserFactory).when(restconf).getParserFactory();
100 doCallRealMethod().when(restconf).sendRequest(
101 any(Map.class), any(SvcLogicContext.class));
102 doCallRealMethod().when(restconf).sendRequest(
103 any(Map.class), any(SvcLogicContext.class), any(Integer.class));
104 doAnswer(dfCaptor).when(restconf).serializeRequest(
105 any(Map.class), any(YangParameters.class), any(String.class),
106 any(InstanceIdentifierContext.class));
107 doAnswer(dfCaptor).when(restconf).updateReq(
108 any(String.class), any(YangParameters.class),
109 any(InstanceIdentifierContext.class));
113 * Creates mock using mockito with input data for decoding.
115 * @param decodeData input data
116 * @throws SvcLogicException when test case fails
118 private void createMockForDecode(String decodeData)
119 throws SvcLogicException {
120 doReturn(decodeData).when(restconf).getResponse(
121 any(SvcLogicContext.class), any(YangParameters.class),
122 any(String.class), any(HttpResponse.class));
123 doCallRealMethod().when(restconf).serializeResponse(
124 any(YangParameters.class), any(String.class), any(String.class),
125 any(InstanceIdentifierContext.class));
129 * Verifies encoding of parameters to JSON data format with containers,
130 * grouping and augment.
132 * @throws SvcLogicException when test case fails
135 public void encodeToJsonYang() throws SvcLogicException {
136 String pre = "test_name_of_the_module_name_of_the_cont1.name_" +
138 SvcLogicContext ctx = createAttListYang(pre);
139 p.put("dirPath", "src/test/resources");
140 p.put("format", "json");
141 p.put("httpMethod", "post");
142 p.put("restapiUrl", "http://echo.getpostman.com/restconf/operati" +
143 "ons/test_name_of_the_module:name_of_the_cont1");
144 restconf.sendRequest(p, ctx);
145 assertThat(dfCaptor.getResult(), is(ENCODE_TO_JSON_YANG_ID));
149 * Verifies encoding of parameters with augment in the URL.
151 * @throws SvcLogicException when test case fails
154 public void encodeToJsonYangWithAugUrl() throws SvcLogicException {
155 String pre = "test_name_of_the_module_name_of_the_cont1.name_" +
157 SvcLogicContext ctx = createAttListYang(pre);
158 p.put("dirPath", "src/test/resources");
159 p.put("format", "json");
160 p.put("httpMethod", "post");
161 p.put("restapiUrl", "http://echo.getpostman.com/restconf/operati" +
162 "ons/test_name_of_the_module:name_of_the_cont1/name_of_t" +
163 "he_cont2/name_of_the_cont4/test_augment_1_for_module:na" +
165 restconf.sendRequest(p, ctx);
166 assertThat(dfCaptor.getResult(), is(ENCODE_TO_JSON_WITH_AUG_PATH));
170 * Verifies encoding of parameters to JSON data format with containers,
171 * grouping and augment for put operation-type.
173 * @throws SvcLogicException when test case fails
176 public void encodeToJsonYangWithPut() throws SvcLogicException {
177 String pre = "test_name_of_the_module_name_of_the_cont1.name_of_the_cont2.";
178 SvcLogicContext ctx = createAttListYang(pre);
179 p.put("dirPath", "src/test/resources");
180 p.put("format", "json");
181 p.put("httpMethod", "put");
182 p.put("restapiUrl", "http://echo.getpostman" +
183 ".com/restconf/operations/test_name_of_the_module:name_of" +
184 "_the_cont1/name_of_the_cont2/name_of_the_cont4");
185 restconf.sendRequest(p, ctx);
186 assertThat(dfCaptor.getResult(), is(ENCODE_TO_JSON_YANG_PUT_ID));
190 * Verifies encoding of parameters to JSON data format with containers,
191 * grouping and augment for patch operation-type.
193 * @throws SvcLogicException when test case fails
196 public void encodeToJsonYangWithPatch() throws SvcLogicException {
197 String pre = "test_name_of_the_module_name_of_the_cont1.name_o" +
199 SvcLogicContext ctx = createAttListYang(pre);
200 p.put("dirPath", "src/test/resources");
201 p.put("format", "json");
202 p.put("httpMethod", "patch");
203 p.put("restapiUrl", "http://echo.getpostman" +
204 ".com/restconf/operations/test_name_of_the_module:name_of_" +
205 "the_cont1/name_of_the_cont2/name_of_the_cont4");
206 restconf.sendRequest(p, ctx);
207 assertThat(dfCaptor.getResult(), is(ENCODE_TO_JSON_YANG_PUT_ID));
211 * Verifies encoding of parameters to JSON data format with augment as
214 * @throws SvcLogicException when test case fails
217 public void encodeToJsonWithAugAsRootChild() throws SvcLogicException {
218 String pre = "test_name_of_the_module_name_of_the_cont1.name_of_" +
220 SvcLogicContext ctx = createAttListYang(pre);
221 p.put("dirPath", "src/test/resources");
222 p.put("format", "json");
223 p.put("httpMethod", "post");
224 p.put("restapiUrl", "http://echo.getpostman" +
225 ".com/restconf/operations/test_name_of_the_module:name_of_" +
226 "the_cont1/name_of_the_cont2/name_of_the_cont4");
227 restconf.sendRequest(p, ctx);
228 assertThat(dfCaptor.getResult(), is(ENCODE_TO_JSON_YANG_AUG_POST_ID));
232 * Verifies decoding of parameters from JSON data format with containers,
233 * grouping and augment.
235 * @throws SvcLogicException when test case fails
238 public void decodeToJsonYang() throws SvcLogicException {
239 createMockForDecode(ENCODE_TO_JSON_YANG_ID);
240 SvcLogicContext ctx = new SvcLogicContext();
241 String pre = "test_name_of_the_module_name_of_the_cont1.name_" +
243 p.put("dirPath", "src/test/resources");
244 p.put("format", "json");
245 p.put("httpMethod", "get");
246 p.put("restapiUrl", "http://echo.getpostman" +
247 ".com/restconf/operations/test_name_of_the_module:name" +
249 restconf.sendRequest(p, ctx);
250 verifyAttListYang(ctx, pre);
254 * Verifies encoding of parameters to XML data format with containers,
255 * grouping and augment.
257 * @throws SvcLogicException when test case fails
260 public void encodeToXmlYang() throws SvcLogicException {
261 String pre = "test_name_of_the_module_name_of_the_cont1.name_of" +
263 SvcLogicContext ctx = createAttListYang(pre);
264 p.put("dirPath", "src/test/resources");
265 p.put("format", "xml");
266 p.put("httpMethod", "post");
267 p.put("restapiUrl", "http://echo.getpostman.com/restconf/operations/" +
268 "test_name_of_the_module:name_of_the_cont1");
269 restconf.sendRequest(p, ctx);
270 assertThat(dfCaptor.getResult(), is(ENCODE_TO_XML_YANG_ID));
274 * Verifies encoding of parameters to XML data format with containers,
275 * grouping and augment for put operation-type
277 * @throws SvcLogicException when test case fails
280 public void encodeToXmlYangWithPut() throws SvcLogicException {
281 String pre = "test_name_of_the_module_name_of_the_cont1.name_" +
283 SvcLogicContext ctx = createAttListYang(pre);
284 p.put("dirPath", "src/test/resources");
285 p.put("format", "xml");
286 p.put("httpMethod", "put");
287 p.put("restapiUrl", "http://echo.getpostman.com/restconf/operations/" +
288 "test_name_of_the_module:name_of_the_cont1/name_of_the_cont2" +
289 "/name_of_the_cont4");
290 restconf.sendRequest(p, ctx);
291 assertThat(dfCaptor.getResult(), is(ENCODE_TO_XML_YANG_PUT_ID));
295 * Verifies encoding of parameters to XML data format with containers,
296 * grouping and augment for patch operation-type
298 * @throws SvcLogicException when test case fails
301 public void encodeToXmlYangWithPatch() throws SvcLogicException {
302 String pre = "test_name_of_the_module_name_of_the_cont1.name_of" +
304 SvcLogicContext ctx = createAttListYang(pre);
305 p.put("dirPath", "src/test/resources");
306 p.put("format", "xml");
307 p.put("httpMethod", "put");
308 p.put("restapiUrl", "http://echo.getpostman.com/restconf/operation" +
309 "s/test_name_of_the_module:name_of_the_cont1/name_of_the_c" +
310 "ont2/name_of_the_cont4");
311 restconf.sendRequest(p, ctx);
312 assertThat(dfCaptor.getResult(), is(ENCODE_TO_XML_YANG_PUT_ID));
316 * Verifies encoding of parameters to XML data format with augment as
319 * @throws SvcLogicException when test case fails
322 public void encodeToXmlWithAugAsRootChild() throws SvcLogicException {
323 String pre = "test_name_of_the_module_name_of_the_cont1.name_of_the" +
325 SvcLogicContext ctx = createAttListYang(pre);
326 p.put("dirPath", "src/test/resources");
327 p.put("format", "xml");
328 p.put("httpMethod", "post");
329 p.put("restapiUrl", "http://echo.getpostman.com/restconf/operations/" +
330 "test_name_of_the_module:name_of_the_cont1/name_of_the_cont2" +
331 "/name_of_the_cont4");
332 restconf.sendRequest(p, ctx);
333 assertThat(dfCaptor.getResult(), is(ENCODE_TO_XML_YANG_AUG_POST_ID));
337 * Verifies decoding of parameters from XML data format with containers,
338 * grouping and augment.
340 * @throws SvcLogicException when test case fails
343 public void decodeToXmlYang() throws SvcLogicException {
344 createMockForDecode(ENCODE_TO_XML_YANG_ID);
345 SvcLogicContext ctx = new SvcLogicContext();
346 String pre = "test_name_of_the_module_name_of_the_cont1.name_of_" +
348 p.put("dirPath", "src/test/resources");
349 p.put("format", "xml");
350 p.put("httpMethod", "get");
351 p.put("restapiUrl", "http://echo.getpostman.com/restconf/operation" +
352 "s/test_name_of_the_module:name_of_the_cont1");
353 restconf.sendRequest(p, ctx);
354 verifyAttListYang(ctx, pre);
358 * Verifies encoding of and decoding from, JSON respectively for data
359 * format with containers, grouping and augment.
361 * @throws SvcLogicException when test case fails
364 public void codecToJsonRpc() throws SvcLogicException {
365 createMockForDecode(DECODE_FROM_JSON_RPC_ID);
366 String inPre = "test_name_of_the_module_name_of_the_create-sfc.input.";
367 String outPre = "test_name_of_the_module_name_of_the_create-sfc" +
369 SvcLogicContext ctx = createAttListRpc(inPre);
370 p.put("dirPath", "src/test/resources");
371 p.put("format", "json");
372 p.put("httpMethod", "post");
373 p.put("restapiUrl", "http://echo.getpostman.com/restconf/operations" +
374 "/test_name_of_the_module:name_of_the_create-sfc");
375 restconf.sendRequest(p, ctx);
376 assertThat(dfCaptor.getResult(), is(ENCODE_TO_JSON_RPC_ID));
377 verifyAttListRpc(ctx, outPre);
381 * Verifies encoding of and decoding from, XML respectively for data
382 * format with containers, grouping and augment.
384 * @throws SvcLogicException when test case fails
387 public void codecToXmlRpc() throws SvcLogicException {
388 createMockForDecode(DECODE_FROM_XML_RPC_ID);
389 String inPre = "test_name_of_the_module_name_of_the_create-sfc.input.";
390 String outPre = "test_name_of_the_module_name_of_the_create-sfc.output.";
391 SvcLogicContext ctx = createAttListRpc(inPre);
392 p.put("dirPath", "src/test/resources");
393 p.put("format", "xml");
394 p.put("httpMethod", "post");
395 p.put("restapiUrl", "http://echo.getpostman" +
396 ".com/restconf/operations/test_name_of_the_module" +
397 ":name_of_the_create-sfc");
398 restconf.sendRequest(p, ctx);
399 assertThat(dfCaptor.getResult(), is(ENCODE_TO_XML_RPC_ID));
400 verifyAttListRpc(ctx, outPre);
404 * Creates attribute list for encoding JSON or XML with container,
405 * grouping and augmented YANG file.
408 * @return service logic context
410 private SvcLogicContext createAttListYang(String pre) {
411 SvcLogicContext ctx = new SvcLogicContext();
412 ctx.setAttribute(pre + "name_of_the_cont3.name_of_the_leaf" +
414 ctx.setAttribute(pre + "name_of_the_list1[0].name_of_the_leaf1" +
416 ctx.setAttribute(pre + "name_of_the_list1[0].name_of_the_leaf2" +
418 ctx.setAttribute(pre + "name_of_the_list1[0].name_of_the_leaf3" +
420 ctx.setAttribute(pre + "name_of_the_list1[0].name_of_the_" +
422 ctx.setAttribute(pre + "name_of_the_list1[0].name_of_the_" +
424 ctx.setAttribute(pre + "name_of_the_list1[0].name_of_the_" +
426 ctx.setAttribute(pre + "name_of_the_list1[0].name_of_the_" +
428 ctx.setAttribute(pre + "name_of_the_list1[0].name_of_the_" +
429 "cont4.name_of_the_leaf11", "abc");
430 ctx.setAttribute(pre + "name_of_the_list1[0].name_of_the_" +
431 "list4[0].name_of_the_leaf8", "abc");
432 ctx.setAttribute(pre + "name_of_the_list1[0].name_of_the_" +
433 "list4[1].name_of_the_leaf8", "abc");
434 ctx.setAttribute(pre + "name_of_the_list1[0].name_of_the_" +
435 "list5[0].name_of_the_leaf9", "abc");
436 ctx.setAttribute(pre + "name_of_the_list1[0].name_of_the_" +
437 "list5[1].name_of_the_leaf9", "abc");
438 ctx.setAttribute(pre + "name_of_the_list1[1].name_of_the_" +
440 ctx.setAttribute(pre + "name_of_the_list1[1].name_of_the_" +
442 ctx.setAttribute(pre + "name_of_the_list1[1].name_of_the_" +
444 ctx.setAttribute(pre + "name_of_the_list1[1].name_of_the_" +
446 ctx.setAttribute(pre + "name_of_the_list1[1].name_of_the_" +
448 ctx.setAttribute(pre + "name_of_the_list1[1].name_of_the_" +
450 ctx.setAttribute(pre + "name_of_the_list1[1].name_of_the_" +
452 ctx.setAttribute(pre + "name_of_the_list1[1].name_of_the_" +
453 "cont4.name_of_the_leaf11", "abc");
454 ctx.setAttribute(pre + "name_of_the_list1[1].name_of_the_" +
455 "list4[0].name_of_the_leaf8", "abc");
456 ctx.setAttribute(pre + "name_of_the_list1[1].name_of_the_" +
457 "list4[1].name_of_the_leaf8", "abc");
458 ctx.setAttribute(pre + "name_of_the_list1[1].name_of_the_" +
459 "list5[0].name_of_the_leaf9", "abc");
460 ctx.setAttribute(pre + "name_of_the_list1[1].name_of_the_" +
461 "list5[1].name_of_the_leaf9", "abc");
462 ctx.setAttribute(pre + "name_of_the_list2[0].name_of_the_" +
464 ctx.setAttribute(pre + "name_of_the_list2[1].name_of_the_" +
466 ctx.setAttribute(pre + "name_of_the_leaf5", "abc");
467 ctx.setAttribute(pre + "name_of_the_leaf6", "abc");
468 ctx.setAttribute(pre + "name_of_the_ll3[0]", "abc");
469 ctx.setAttribute(pre + "name_of_the_ll3[1]", "abc");
470 ctx.setAttribute(pre + "name_of_the_ll4[0]", "abc");
471 ctx.setAttribute(pre + "name_of_the_ll4[1]", "abc");
472 ctx.setAttribute(pre + "name_of_the_cont4.name_of_the_leaf10",
474 ctx.setAttribute(pre + "name_of_the_list6[0].name_of_the_leaf11",
476 ctx.setAttribute(pre + "name_of_the_list6[1].name_of_the_leaf11",
478 ctx.setAttribute(pre + "name_of_the_leaf12", "abc");
479 ctx.setAttribute(pre + "name_of_the_ll5[0]", "abc");
480 ctx.setAttribute(pre + "name_of_the_ll5[1]", "abc");
481 ctx.setAttribute(pre + "name_of_the_cont4.test_augment_1_for_" +
482 "module_name_of_the_cont5.name_of_the_leaf13",
484 ctx.setAttribute(pre + "name_of_the_cont4.test_augment_1_for_" +
485 "module_name_of_the_list7[0].name_of_the" +
487 ctx.setAttribute(pre + "name_of_the_cont4.test_augment_1_for_" +
488 "module_name_of_the_list7[1].name_of_the" +
489 "_leaf14", "create");
490 ctx.setAttribute(pre + "name_of_the_cont4.test_augment_1_for_" +
491 "module_name_of_the_leaf15", "abc");
492 ctx.setAttribute(pre + "name_of_the_cont4.test_augment_1_for_" +
493 "module_name_of_the_ll6[0]",
495 ctx.setAttribute(pre + "name_of_the_cont4.test_augment_1_for" +
496 "_module_name_of_the_ll6[1]", "8");
497 ctx.setAttribute(pre + "name_of_the_cont4.test_augment_1_for" +
498 "_module_name_of_the_cont13.name_of_the_" +
499 "cont12.name_of_the_leaf26",
501 ctx.setAttribute(pre + "name_of_the_cont4.test_augment_1_for_" +
502 "module_name_of_the_cont13.name_of_the_" +
503 "list9[0].name_of_the_leaf27",
505 ctx.setAttribute(pre + "name_of_the_cont4.test_augment_1_for" +
506 "_module_name_of_the_cont13.name_of_the_" +
507 "list9[1].name_of_the_leaf27",
509 ctx.setAttribute(pre + "name_of_the_cont4.test_augment_1_for" +
510 "_module_name_of_the_cont13.name_of_the_" +
512 ctx.setAttribute(pre + "name_of_the_cont4.test_augment_1_for" +
513 "_module_name_of_the_cont13.name_of_the_" +
515 ctx.setAttribute(pre + "name_of_the_cont4.test_augment_1_for" +
516 "_module_name_of_the_cont13.name_of_the_" +
522 * Creates attribute list for encoding JSON or XML with RPC YANG file.
525 * @return service logic context
527 private SvcLogicContext createAttListRpc(String pre) {
528 SvcLogicContext ctx = new SvcLogicContext();
529 ctx.setAttribute(pre + "name_of_the_cont14.name_of_the_leaf28",
531 ctx.setAttribute(pre + "name_of_the_list10[0].name_of_the_leaf29",
533 ctx.setAttribute(pre + "name_of_the_list10[1].name_of_the_leaf29",
535 ctx.setAttribute(pre + "name_of_the_leaf30", "abc");
536 ctx.setAttribute(pre + "name_of_the_ll10[0]", "abc");
537 ctx.setAttribute(pre + "name_of_the_ll10[1]", "abc");
538 ctx.setAttribute(pre + "name_of_the_cont15.name_of_the_leaf31",
540 ctx.setAttribute(pre + "name_of_the_cont13.name_of_the_list9[0]" +
541 ".name_of_the_leaf27", "abc");
542 ctx.setAttribute(pre + "name_of_the_cont13.name_of_the_list9[1]" +
543 ".name_of_the_leaf27", "abc");
544 ctx.setAttribute(pre + "name_of_the_cont13.name_of_the_leaf28",
546 ctx.setAttribute(pre + "name_of_the_cont13.name_of_the_ll9[0]",
548 ctx.setAttribute(pre + "name_of_the_cont13.name_of_the_ll9[1]",
554 * Verifies the attribute list for decoding from JSON or XML with
555 * container, grouping and augmented file.
557 * @param ctx service logic context
560 private void verifyAttListYang(SvcLogicContext ctx, String pre) {
561 assertThat(ctx.getAttribute(pre + "name_of_the_cont3.name_of" +
562 "_the_leaf10"), is("abc"));
563 assertThat(ctx.getAttribute(pre + "name_of_the_list1[0].name" +
564 "_of_the_leaf1"), is("true"));
565 assertThat(ctx.getAttribute(pre + "name_of_the_list1[0].name" +
566 "_of_the_leaf2"), is("abc"));
567 assertThat(ctx.getAttribute(pre + "name_of_the_list1[0].name" +
568 "_of_the_leaf3"), is("abc"));
569 assertThat(ctx.getAttribute(pre + "name_of_the_list1[0].name" +
570 "_of_the_ll1[0]"), is("abc"));
571 assertThat(ctx.getAttribute(pre + "name_of_the_list1[0].name" +
572 "_of_the_ll1[1]"), is("abc"));
573 assertThat(ctx.getAttribute(pre + "name_of_the_list1[0].name" +
574 "_of_the_ll2[0]"), is("abc"));
575 assertThat(ctx.getAttribute(pre + "name_of_the_list1[0].name" +
576 "_of_the_ll2[1]"), is("abc"));
577 assertThat(ctx.getAttribute(pre + "name_of_the_list1[0].name" +
578 "_of_the_cont4.name_of_the_leaf11"),
580 assertThat(ctx.getAttribute(pre + "name_of_the_list1[0].name_of" +
581 "_the_list4[0].name_of_the_leaf8"),
583 assertThat(ctx.getAttribute(pre + "name_of_the_list1[0].name_of" +
584 "_the_list4[1].name_of_the_leaf8"),
586 assertThat(ctx.getAttribute(pre + "name_of_the_list1[0].name_of" +
587 "_the_list5[0].name_of_the_leaf9"),
589 assertThat(ctx.getAttribute(pre + "name_of_the_list1[0].name_of" +
590 "_the_list5[1].name_of_the_leaf9"),
592 assertThat(ctx.getAttribute(pre + "name_of_the_list1[1].name_of" +
593 "_the_leaf1"), is("true"));
594 assertThat(ctx.getAttribute(pre + "name_of_the_list1[1].name_of" +
595 "_the_leaf2"), is("abc"));
596 assertThat(ctx.getAttribute(pre + "name_of_the_list1[1].name_of" +
597 "_the_leaf3"), is("abc"));
598 assertThat(ctx.getAttribute(pre + "name_of_the_list1[1].name_of" +
599 "_the_ll1[0]"), is("abc"));
600 assertThat(ctx.getAttribute(pre + "name_of_the_list1[1].name_of" +
601 "_the_ll1[1]"), is("abc"));
602 assertThat(ctx.getAttribute(pre + "name_of_the_list1[1].name_of" +
603 "_the_ll2[0]"), is("abc"));
604 assertThat(ctx.getAttribute(pre + "name_of_the_list1[1].name_of" +
605 "_the_ll2[1]"), is("abc"));
606 assertThat(ctx.getAttribute(pre + "name_of_the_list1[1].name_of" +
607 "_the_cont4.name_of_the_leaf11"),
609 assertThat(ctx.getAttribute(pre + "name_of_the_list1[1].name_of" +
610 "_the_list4[0].name_of_the_leaf8"),
612 assertThat(ctx.getAttribute(pre + "name_of_the_list1[1].name_of" +
613 "_the_list4[1].name_of_the_leaf8"),
615 assertThat(ctx.getAttribute(pre + "name_of_the_list1[1].name_of" +
616 "_the_list5[0].name_of_the_leaf9"),
618 assertThat(ctx.getAttribute(pre + "name_of_the_list1[1].name_of" +
619 "_the_list5[1].name_of_the_leaf9"),
621 assertThat(ctx.getAttribute(pre + "name_of_the_list2[0].name_of" +
622 "_the_leaf4"), is("abc"));
623 assertThat(ctx.getAttribute(pre + "name_of_the_list2[1].name_of" +
624 "_the_leaf4"), is("abc"));
625 assertThat(ctx.getAttribute(pre + "name_of_the_leaf5"),
627 assertThat(ctx.getAttribute(pre + "name_of_the_leaf6"),
629 assertThat(ctx.getAttribute(pre + "name_of_the_ll3[0]"),
631 assertThat(ctx.getAttribute(pre + "name_of_the_ll3[1]"),
633 assertThat(ctx.getAttribute(pre + "name_of_the_ll4[0]"),
635 assertThat(ctx.getAttribute(pre + "name_of_the_ll4[1]"),
637 assertThat(ctx.getAttribute(pre + "name_of_the_cont4.name_of" +
638 "_the_leaf10"), is( "abc"));
639 assertThat(ctx.getAttribute(pre + "name_of_the_list6[0].name_of" +
640 "_the_leaf11"), is("abc"));
641 assertThat(ctx.getAttribute(pre + "name_of_the_list6[1].name_of" +
642 "_the_leaf11"), is("abc"));
643 assertThat(ctx.getAttribute(pre + "name_of_the_leaf12"),
645 assertThat(ctx.getAttribute(pre + "name_of_the_ll5[0]"),
647 assertThat(ctx.getAttribute(pre + "name_of_the_ll5[1]"),
649 assertThat(ctx.getAttribute(pre + "name_of_the_cont4.test_" +
650 "augment_1_for_module_name_of_" +
651 "the_cont5.name_of_the_leaf13"),
653 assertThat(ctx.getAttribute(pre + "name_of_the_cont4.test_" +
654 "augment_1_for_module_name_of_" +
655 "the_list7[0].name_of_the_leaf14"),
657 assertThat(ctx.getAttribute(pre + "name_of_the_cont4.test_" +
658 "augment_1_for_module_name_of_" +
659 "the_list7[1].name_of_the_leaf14"),
661 assertThat(ctx.getAttribute(pre + "name_of_the_cont4.test_" +
662 "augment_1_for_module_name_of_" +
665 assertThat(ctx.getAttribute(pre + "name_of_the_cont4.test_" +
666 "augment_1_for_module_name_of_" +
669 assertThat(ctx.getAttribute(pre + "name_of_the_cont4.test_" +
670 "augment_1_for_module_name_of_" +
673 assertThat(ctx.getAttribute(pre + "name_of_the_cont4.test_" +
674 "augment_1_for_module_name_of_" +
676 ".name_of_the_cont12.name_of_" +
677 "the_leaf26"), is("abc"));
678 assertThat(ctx.getAttribute(pre + "name_of_the_cont4.test_" +
679 "augment_1_for_module_name_of_" +
680 "the_cont13.name_of_the_list9[0]" +
681 ".name_of_the_leaf27"),
683 assertThat(ctx.getAttribute(pre + "name_of_the_cont4.test_" +
684 "augment_1_for_module_name_of_" +
685 "the_cont13.name_of_the_list9[1]" +
686 ".name_of_the_leaf27"),
688 assertThat(ctx.getAttribute(pre + "name_of_the_cont4.test_" +
689 "augment_1_for_module_name_of_" +
690 "the_cont13.name_of_the_leaf28"),
692 assertThat(ctx.getAttribute(pre + "name_of_the_cont4.test_" +
693 "augment_1_for_module_name_of_" +
694 "the_cont13.name_of_the_ll9[0]"),
696 assertThat(ctx.getAttribute(pre + "name_of_the_cont4.test_" +
697 "augment_1_for_module_name_of_" +
698 "the_cont13.name_of_the_ll9[1]"),
703 * Verifies the attribute list for decoding from JSON or XML with
706 * @param ctx service logic context
709 private void verifyAttListRpc(SvcLogicContext ctx, String pre) {
710 assertThat(ctx.getAttribute(pre + "name_of_the_cont16.name_of_" +
711 "the_leaf32"), is("abc"));
712 assertThat(ctx.getAttribute(pre + "name_of_the_list11[0].name" +
713 "_of_the_leaf33"), is("abc"));
714 assertThat(ctx.getAttribute(pre + "name_of_the_list11[1].name" +
715 "_of_the_leaf33"), is("abc"));
716 assertThat(ctx.getAttribute(pre + "name_of_the_leaf34"),
718 assertThat(ctx.getAttribute(pre + "name_of_the_ll11[0]"),
720 assertThat(ctx.getAttribute(pre + "name_of_the_ll11[1]"),
722 assertThat(ctx.getAttribute(pre + "name_of_the_cont17.name_of_" +
723 "the_leaf35"), is("abc"));
724 assertThat(ctx.getAttribute(pre + "name_of_the_cont13.name_of_" +
725 "the_cont12.name_of_the_leaf26"),
727 assertThat(ctx.getAttribute(pre + "name_of_the_cont13.name_of_" +
728 "the_list9[0].name_of_the_leaf27"),
730 assertThat(ctx.getAttribute(pre + "name_of_the_cont13.name_of_" +
731 "the_list9[1].name_of_the_leaf27"),
733 assertThat(ctx.getAttribute(pre + "name_of_the_cont13.name_of_" +
734 "the_ll9[0]"), is("abc"));
735 assertThat(ctx.getAttribute(pre + "name_of_the_cont13.name_of_" +
736 "the_ll9[1]"), is("abc"));
737 assertThat(ctx.getAttribute(pre + "name_of_the_cont13.name_of_" +
738 "the_leaf28"), is("abc"));
742 * Captures the data format messages by mocking it, which can be used in
745 * @param <String> capturing data format
747 public class DfCaptor<String> implements Answer {
749 private String result;
752 * Returns the captured data format message.
754 * @return data format message.
756 public String getResult() {
761 public String answer(InvocationOnMock invocationOnMock)
763 result = (String) invocationOnMock.callRealMethod();