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;
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.yangserializers.dfserializer.IdentifierValidationUtilsTest.DECODE_FROM_JSON_RPC_ID;
45 import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.IdentifierValidationUtilsTest.DECODE_FROM_XML_RPC_ID;
46 import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.IdentifierValidationUtilsTest.ENCODE_TO_JSON_RPC_ID;
47 import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.IdentifierValidationUtilsTest.ENCODE_TO_JSON_WITH_AUG_PATH;
48 import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.IdentifierValidationUtilsTest.ENCODE_TO_JSON_YANG_AUG_POST_ID;
49 import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.IdentifierValidationUtilsTest.ENCODE_TO_JSON_YANG_ID;
50 import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.IdentifierValidationUtilsTest.ENCODE_TO_JSON_YANG_PUT_ID;
51 import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.IdentifierValidationUtilsTest.ENCODE_TO_XML_RPC_ID;
52 import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.IdentifierValidationUtilsTest.ENCODE_TO_XML_YANG_AUG_POST_ID;
53 import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.IdentifierValidationUtilsTest.ENCODE_TO_XML_YANG_ID;
54 import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.IdentifierValidationUtilsTest.ENCODE_TO_XML_YANG_PUT_ID;
57 * Unit test cases for identifier validation test.
59 public class IdentifierValidationTest {
61 private Map<String, String> p;
63 private RestconfApiCallNode restconf;
65 private RestapiCallNode restApi;
67 private DfCaptor dfCaptor;
70 * Sets up the pre-requisite for each test case.
72 * @throws SvcLogicException when test case fails
75 public void setUp() throws SvcLogicException {
77 p.put("restapiUser", "user1");
78 p.put("restapiPassword", "abc123");
79 p.put("responsePrefix", "response");
80 p.put("skipSending", "true");
81 restApi = new RestapiCallNode();
82 restconf = mock(RestconfApiCallNode.class);
83 dfCaptor = new DfCaptor();
88 * Creates method mocks using mockito for RestconfApiCallNode class.
90 * @throws SvcLogicException when test case fails
92 private void createMethodMocks() throws SvcLogicException {
93 doReturn(restApi).when(restconf).getRestapiCallNode();
94 doCallRealMethod().when(restconf).sendRequest(
95 any(Map.class), any(SvcLogicContext.class));
96 doCallRealMethod().when(restconf).sendRequest(
97 any(Map.class), any(SvcLogicContext.class), any(Integer.class));
98 doAnswer(dfCaptor).when(restconf).serializeRequest(
99 any(Map.class), any(YangParameters.class), any(String.class),
100 any(InstanceIdentifierContext.class));
101 doAnswer(dfCaptor).when(restconf).updateReq(
102 any(String.class), any(YangParameters.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 containers,
124 * grouping and augment.
126 * @throws SvcLogicException when test case fails
129 public void encodeToJsonYang() throws SvcLogicException {
130 String pre = "test_name_of_the_module_name_of_the_cont1.name_" +
132 SvcLogicContext ctx = createAttListYang(pre);
133 p.put("dirPath", "src/test/resources");
134 p.put("format", "json");
135 p.put("httpMethod", "post");
136 p.put("restapiUrl", "http://echo.getpostman.com/restconf/operati" +
137 "ons/test_name_of_the_module:name_of_the_cont1");
138 restconf.sendRequest(p, ctx);
139 assertThat(dfCaptor.getResult(), is(ENCODE_TO_JSON_YANG_ID));
143 * Verifies encoding of parameters with augment in the URL.
145 * @throws SvcLogicException when test case fails
148 public void encodeToJsonYangWithAugUrl() throws SvcLogicException {
149 String pre = "test_name_of_the_module_name_of_the_cont1.name_" +
151 SvcLogicContext ctx = createAttListYang(pre);
152 p.put("dirPath", "src/test/resources");
153 p.put("format", "json");
154 p.put("httpMethod", "post");
155 p.put("restapiUrl", "http://echo.getpostman.com/restconf/operati" +
156 "ons/test_name_of_the_module:name_of_the_cont1/name_of_t" +
157 "he_cont2/name_of_the_cont4/test_augment_1_for_module:na" +
159 restconf.sendRequest(p, ctx);
160 assertThat(dfCaptor.getResult(), is(ENCODE_TO_JSON_WITH_AUG_PATH));
164 * Verifies encoding of parameters to JSON data format with containers,
165 * grouping and augment for put operation-type.
167 * @throws SvcLogicException when test case fails
170 public void encodeToJsonYangWithPut() throws SvcLogicException {
171 String pre = "test_name_of_the_module_name_of_the_cont1.name_of_the_cont2.";
172 SvcLogicContext ctx = createAttListYang(pre);
173 p.put("dirPath", "src/test/resources");
174 p.put("format", "json");
175 p.put("httpMethod", "put");
176 p.put("restapiUrl", "http://echo.getpostman" +
177 ".com/restconf/operations/test_name_of_the_module:name_of" +
178 "_the_cont1/name_of_the_cont2/name_of_the_cont4");
179 restconf.sendRequest(p, ctx);
180 assertThat(dfCaptor.getResult(), is(ENCODE_TO_JSON_YANG_PUT_ID));
184 * Verifies encoding of parameters to JSON data format with containers,
185 * grouping and augment for patch operation-type.
187 * @throws SvcLogicException when test case fails
190 public void encodeToJsonYangWithPatch() throws SvcLogicException {
191 String pre = "test_name_of_the_module_name_of_the_cont1.name_o" +
193 SvcLogicContext ctx = createAttListYang(pre);
194 p.put("dirPath", "src/test/resources");
195 p.put("format", "json");
196 p.put("httpMethod", "patch");
197 p.put("restapiUrl", "http://echo.getpostman" +
198 ".com/restconf/operations/test_name_of_the_module:name_of_" +
199 "the_cont1/name_of_the_cont2/name_of_the_cont4");
200 restconf.sendRequest(p, ctx);
201 assertThat(dfCaptor.getResult(), is(ENCODE_TO_JSON_YANG_PUT_ID));
205 * Verifies encoding of parameters to JSON data format with augment as
208 * @throws SvcLogicException when test case fails
211 public void encodeToJsonWithAugAsRootChild() throws SvcLogicException {
212 String pre = "test_name_of_the_module_name_of_the_cont1.name_of_" +
214 SvcLogicContext ctx = createAttListYang(pre);
215 p.put("dirPath", "src/test/resources");
216 p.put("format", "json");
217 p.put("httpMethod", "post");
218 p.put("restapiUrl", "http://echo.getpostman" +
219 ".com/restconf/operations/test_name_of_the_module:name_of_" +
220 "the_cont1/name_of_the_cont2/name_of_the_cont4");
221 restconf.sendRequest(p, ctx);
222 assertThat(dfCaptor.getResult(), is(ENCODE_TO_JSON_YANG_AUG_POST_ID));
226 * Verifies decoding of parameters from JSON data format with containers,
227 * grouping and augment.
229 * @throws SvcLogicException when test case fails
232 public void decodeToJsonYang() throws SvcLogicException {
233 createMockForDecode(ENCODE_TO_JSON_YANG_ID);
234 SvcLogicContext ctx = new SvcLogicContext();
235 String pre = "test_name_of_the_module_name_of_the_cont1.name_" +
237 p.put("dirPath", "src/test/resources");
238 p.put("format", "json");
239 p.put("httpMethod", "get");
240 p.put("restapiUrl", "http://echo.getpostman" +
241 ".com/restconf/operations/test_name_of_the_module:name" +
243 restconf.sendRequest(p, ctx);
244 verifyAttListYang(ctx, pre);
248 * Verifies encoding of parameters to XML data format with containers,
249 * grouping and augment.
251 * @throws SvcLogicException when test case fails
254 public void encodeToXmlYang() throws SvcLogicException {
255 String pre = "test_name_of_the_module_name_of_the_cont1.name_of" +
257 SvcLogicContext ctx = createAttListYang(pre);
258 p.put("dirPath", "src/test/resources");
259 p.put("format", "xml");
260 p.put("httpMethod", "post");
261 p.put("restapiUrl", "http://echo.getpostman.com/restconf/operations/" +
262 "test_name_of_the_module:name_of_the_cont1");
263 restconf.sendRequest(p, ctx);
264 assertThat(dfCaptor.getResult(), is(ENCODE_TO_XML_YANG_ID));
268 * Verifies encoding of parameters to XML data format with containers,
269 * grouping and augment for put operation-type
271 * @throws SvcLogicException when test case fails
274 public void encodeToXmlYangWithPut() throws SvcLogicException {
275 String pre = "test_name_of_the_module_name_of_the_cont1.name_" +
277 SvcLogicContext ctx = createAttListYang(pre);
278 p.put("dirPath", "src/test/resources");
279 p.put("format", "xml");
280 p.put("httpMethod", "put");
281 p.put("restapiUrl", "http://echo.getpostman.com/restconf/operations/" +
282 "test_name_of_the_module:name_of_the_cont1/name_of_the_cont2" +
283 "/name_of_the_cont4");
284 restconf.sendRequest(p, ctx);
285 assertThat(dfCaptor.getResult(), is(ENCODE_TO_XML_YANG_PUT_ID));
289 * Verifies encoding of parameters to XML data format with containers,
290 * grouping and augment for patch operation-type
292 * @throws SvcLogicException when test case fails
295 public void encodeToXmlYangWithPatch() throws SvcLogicException {
296 String pre = "test_name_of_the_module_name_of_the_cont1.name_of" +
298 SvcLogicContext ctx = createAttListYang(pre);
299 p.put("dirPath", "src/test/resources");
300 p.put("format", "xml");
301 p.put("httpMethod", "put");
302 p.put("restapiUrl", "http://echo.getpostman.com/restconf/operation" +
303 "s/test_name_of_the_module:name_of_the_cont1/name_of_the_c" +
304 "ont2/name_of_the_cont4");
305 restconf.sendRequest(p, ctx);
306 assertThat(dfCaptor.getResult(), is(ENCODE_TO_XML_YANG_PUT_ID));
310 * Verifies encoding of parameters to XML data format with augment as
313 * @throws SvcLogicException when test case fails
316 public void encodeToXmlWithAugAsRootChild() throws SvcLogicException {
317 String pre = "test_name_of_the_module_name_of_the_cont1.name_of_the" +
319 SvcLogicContext ctx = createAttListYang(pre);
320 p.put("dirPath", "src/test/resources");
321 p.put("format", "xml");
322 p.put("httpMethod", "post");
323 p.put("restapiUrl", "http://echo.getpostman.com/restconf/operations/" +
324 "test_name_of_the_module:name_of_the_cont1/name_of_the_cont2" +
325 "/name_of_the_cont4");
326 restconf.sendRequest(p, ctx);
327 assertThat(dfCaptor.getResult(), is(ENCODE_TO_XML_YANG_AUG_POST_ID));
331 * Verifies decoding of parameters from XML data format with containers,
332 * grouping and augment.
334 * @throws SvcLogicException when test case fails
337 public void decodeToXmlYang() throws SvcLogicException {
338 createMockForDecode(ENCODE_TO_XML_YANG_ID);
339 SvcLogicContext ctx = new SvcLogicContext();
340 String pre = "test_name_of_the_module_name_of_the_cont1.name_of_" +
342 p.put("dirPath", "src/test/resources");
343 p.put("format", "xml");
344 p.put("httpMethod", "get");
345 p.put("restapiUrl", "http://echo.getpostman.com/restconf/operation" +
346 "s/test_name_of_the_module:name_of_the_cont1");
347 restconf.sendRequest(p, ctx);
348 verifyAttListYang(ctx, pre);
352 * Verifies encoding of and decoding from, JSON respectively for data
353 * format with containers, grouping and augment.
355 * @throws SvcLogicException when test case fails
358 public void codecToJsonRpc() throws SvcLogicException {
359 createMockForDecode(DECODE_FROM_JSON_RPC_ID);
360 String inPre = "test_name_of_the_module_name_of_the_create-sfc.input.";
361 String outPre = "test_name_of_the_module_name_of_the_create-sfc" +
363 SvcLogicContext ctx = createAttListRpc(inPre);
364 p.put("dirPath", "src/test/resources");
365 p.put("format", "json");
366 p.put("httpMethod", "post");
367 p.put("restapiUrl", "http://echo.getpostman.com/restconf/operations" +
368 "/test_name_of_the_module:name_of_the_create-sfc");
369 restconf.sendRequest(p, ctx);
370 assertThat(dfCaptor.getResult(), is(ENCODE_TO_JSON_RPC_ID));
371 verifyAttListRpc(ctx, outPre);
375 * Verifies encoding of and decoding from, XML respectively for data
376 * format with containers, grouping and augment.
378 * @throws SvcLogicException when test case fails
381 public void codecToXmlRpc() throws SvcLogicException {
382 createMockForDecode(DECODE_FROM_XML_RPC_ID);
383 String inPre = "test_name_of_the_module_name_of_the_create-sfc.input.";
384 String outPre = "test_name_of_the_module_name_of_the_create-sfc.output.";
385 SvcLogicContext ctx = createAttListRpc(inPre);
386 p.put("dirPath", "src/test/resources");
387 p.put("format", "xml");
388 p.put("httpMethod", "post");
389 p.put("restapiUrl", "http://echo.getpostman" +
390 ".com/restconf/operations/test_name_of_the_module" +
391 ":name_of_the_create-sfc");
392 restconf.sendRequest(p, ctx);
393 assertThat(dfCaptor.getResult(), is(ENCODE_TO_XML_RPC_ID));
394 verifyAttListRpc(ctx, outPre);
398 * Creates attribute list for encoding JSON or XML with container,
399 * grouping and augmented YANG file.
402 * @return service logic context
404 private SvcLogicContext createAttListYang(String pre) {
405 SvcLogicContext ctx = new SvcLogicContext();
406 ctx.setAttribute(pre + "name_of_the_cont3.name_of_the_leaf" +
408 ctx.setAttribute(pre + "name_of_the_list1[0].name_of_the_leaf1" +
410 ctx.setAttribute(pre + "name_of_the_list1[0].name_of_the_leaf2" +
412 ctx.setAttribute(pre + "name_of_the_list1[0].name_of_the_leaf3" +
414 ctx.setAttribute(pre + "name_of_the_list1[0].name_of_the_" +
416 ctx.setAttribute(pre + "name_of_the_list1[0].name_of_the_" +
418 ctx.setAttribute(pre + "name_of_the_list1[0].name_of_the_" +
420 ctx.setAttribute(pre + "name_of_the_list1[0].name_of_the_" +
422 ctx.setAttribute(pre + "name_of_the_list1[0].name_of_the_" +
423 "cont4.name_of_the_leaf11", "abc");
424 ctx.setAttribute(pre + "name_of_the_list1[0].name_of_the_" +
425 "list4[0].name_of_the_leaf8", "abc");
426 ctx.setAttribute(pre + "name_of_the_list1[0].name_of_the_" +
427 "list4[1].name_of_the_leaf8", "abc");
428 ctx.setAttribute(pre + "name_of_the_list1[0].name_of_the_" +
429 "list5[0].name_of_the_leaf9", "abc");
430 ctx.setAttribute(pre + "name_of_the_list1[0].name_of_the_" +
431 "list5[1].name_of_the_leaf9", "abc");
432 ctx.setAttribute(pre + "name_of_the_list1[1].name_of_the_" +
434 ctx.setAttribute(pre + "name_of_the_list1[1].name_of_the_" +
436 ctx.setAttribute(pre + "name_of_the_list1[1].name_of_the_" +
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_" +
447 "cont4.name_of_the_leaf11", "abc");
448 ctx.setAttribute(pre + "name_of_the_list1[1].name_of_the_" +
449 "list4[0].name_of_the_leaf8", "abc");
450 ctx.setAttribute(pre + "name_of_the_list1[1].name_of_the_" +
451 "list4[1].name_of_the_leaf8", "abc");
452 ctx.setAttribute(pre + "name_of_the_list1[1].name_of_the_" +
453 "list5[0].name_of_the_leaf9", "abc");
454 ctx.setAttribute(pre + "name_of_the_list1[1].name_of_the_" +
455 "list5[1].name_of_the_leaf9", "abc");
456 ctx.setAttribute(pre + "name_of_the_list2[0].name_of_the_" +
458 ctx.setAttribute(pre + "name_of_the_list2[1].name_of_the_" +
460 ctx.setAttribute(pre + "name_of_the_leaf5", "abc");
461 ctx.setAttribute(pre + "name_of_the_leaf6", "abc");
462 ctx.setAttribute(pre + "name_of_the_ll3[0]", "abc");
463 ctx.setAttribute(pre + "name_of_the_ll3[1]", "abc");
464 ctx.setAttribute(pre + "name_of_the_ll4[0]", "abc");
465 ctx.setAttribute(pre + "name_of_the_ll4[1]", "abc");
466 ctx.setAttribute(pre + "name_of_the_cont4.name_of_the_leaf10",
468 ctx.setAttribute(pre + "name_of_the_list6[0].name_of_the_leaf11",
470 ctx.setAttribute(pre + "name_of_the_list6[1].name_of_the_leaf11",
472 ctx.setAttribute(pre + "name_of_the_leaf12", "abc");
473 ctx.setAttribute(pre + "name_of_the_ll5[0]", "abc");
474 ctx.setAttribute(pre + "name_of_the_ll5[1]", "abc");
475 ctx.setAttribute(pre + "name_of_the_cont4.test_augment_1_for_" +
476 "module_name_of_the_cont5.name_of_the_leaf13",
478 ctx.setAttribute(pre + "name_of_the_cont4.test_augment_1_for_" +
479 "module_name_of_the_list7[0].name_of_the" +
481 ctx.setAttribute(pre + "name_of_the_cont4.test_augment_1_for_" +
482 "module_name_of_the_list7[1].name_of_the" +
483 "_leaf14", "create");
484 ctx.setAttribute(pre + "name_of_the_cont4.test_augment_1_for_" +
485 "module_name_of_the_leaf15", "abc");
486 ctx.setAttribute(pre + "name_of_the_cont4.test_augment_1_for_" +
487 "module_name_of_the_ll6[0]",
489 ctx.setAttribute(pre + "name_of_the_cont4.test_augment_1_for" +
490 "_module_name_of_the_ll6[1]", "8");
491 ctx.setAttribute(pre + "name_of_the_cont4.test_augment_1_for" +
492 "_module_name_of_the_cont13.name_of_the_" +
493 "cont12.name_of_the_leaf26",
495 ctx.setAttribute(pre + "name_of_the_cont4.test_augment_1_for_" +
496 "module_name_of_the_cont13.name_of_the_" +
497 "list9[0].name_of_the_leaf27",
499 ctx.setAttribute(pre + "name_of_the_cont4.test_augment_1_for" +
500 "_module_name_of_the_cont13.name_of_the_" +
501 "list9[1].name_of_the_leaf27",
503 ctx.setAttribute(pre + "name_of_the_cont4.test_augment_1_for" +
504 "_module_name_of_the_cont13.name_of_the_" +
506 ctx.setAttribute(pre + "name_of_the_cont4.test_augment_1_for" +
507 "_module_name_of_the_cont13.name_of_the_" +
509 ctx.setAttribute(pre + "name_of_the_cont4.test_augment_1_for" +
510 "_module_name_of_the_cont13.name_of_the_" +
516 * Creates attribute list for encoding JSON or XML with RPC YANG file.
519 * @return service logic context
521 private SvcLogicContext createAttListRpc(String pre) {
522 SvcLogicContext ctx = new SvcLogicContext();
523 ctx.setAttribute(pre + "name_of_the_cont14.name_of_the_leaf28",
525 ctx.setAttribute(pre + "name_of_the_list10[0].name_of_the_leaf29",
527 ctx.setAttribute(pre + "name_of_the_list10[1].name_of_the_leaf29",
529 ctx.setAttribute(pre + "name_of_the_leaf30", "abc");
530 ctx.setAttribute(pre + "name_of_the_ll10[0]", "abc");
531 ctx.setAttribute(pre + "name_of_the_ll10[1]", "abc");
532 ctx.setAttribute(pre + "name_of_the_cont15.name_of_the_leaf31",
534 ctx.setAttribute(pre + "name_of_the_cont13.name_of_the_list9[0]" +
535 ".name_of_the_leaf27", "abc");
536 ctx.setAttribute(pre + "name_of_the_cont13.name_of_the_list9[1]" +
537 ".name_of_the_leaf27", "abc");
538 ctx.setAttribute(pre + "name_of_the_cont13.name_of_the_leaf28",
540 ctx.setAttribute(pre + "name_of_the_cont13.name_of_the_ll9[0]",
542 ctx.setAttribute(pre + "name_of_the_cont13.name_of_the_ll9[1]",
548 * Verifies the attribute list for decoding from JSON or XML with
549 * container, grouping and augmented file.
551 * @param ctx service logic context
554 private void verifyAttListYang(SvcLogicContext ctx, String pre) {
555 assertThat(ctx.getAttribute(pre + "name_of_the_cont3.name_of" +
556 "_the_leaf10"), is("abc"));
557 assertThat(ctx.getAttribute(pre + "name_of_the_list1[0].name" +
558 "_of_the_leaf1"), is("true"));
559 assertThat(ctx.getAttribute(pre + "name_of_the_list1[0].name" +
560 "_of_the_leaf2"), is("abc"));
561 assertThat(ctx.getAttribute(pre + "name_of_the_list1[0].name" +
562 "_of_the_leaf3"), is("abc"));
563 assertThat(ctx.getAttribute(pre + "name_of_the_list1[0].name" +
564 "_of_the_ll1[0]"), is("abc"));
565 assertThat(ctx.getAttribute(pre + "name_of_the_list1[0].name" +
566 "_of_the_ll1[1]"), is("abc"));
567 assertThat(ctx.getAttribute(pre + "name_of_the_list1[0].name" +
568 "_of_the_ll2[0]"), is("abc"));
569 assertThat(ctx.getAttribute(pre + "name_of_the_list1[0].name" +
570 "_of_the_ll2[1]"), is("abc"));
571 assertThat(ctx.getAttribute(pre + "name_of_the_list1[0].name" +
572 "_of_the_cont4.name_of_the_leaf11"),
574 assertThat(ctx.getAttribute(pre + "name_of_the_list1[0].name_of" +
575 "_the_list4[0].name_of_the_leaf8"),
577 assertThat(ctx.getAttribute(pre + "name_of_the_list1[0].name_of" +
578 "_the_list4[1].name_of_the_leaf8"),
580 assertThat(ctx.getAttribute(pre + "name_of_the_list1[0].name_of" +
581 "_the_list5[0].name_of_the_leaf9"),
583 assertThat(ctx.getAttribute(pre + "name_of_the_list1[0].name_of" +
584 "_the_list5[1].name_of_the_leaf9"),
586 assertThat(ctx.getAttribute(pre + "name_of_the_list1[1].name_of" +
587 "_the_leaf1"), is("true"));
588 assertThat(ctx.getAttribute(pre + "name_of_the_list1[1].name_of" +
589 "_the_leaf2"), is("abc"));
590 assertThat(ctx.getAttribute(pre + "name_of_the_list1[1].name_of" +
591 "_the_leaf3"), is("abc"));
592 assertThat(ctx.getAttribute(pre + "name_of_the_list1[1].name_of" +
593 "_the_ll1[0]"), is("abc"));
594 assertThat(ctx.getAttribute(pre + "name_of_the_list1[1].name_of" +
595 "_the_ll1[1]"), is("abc"));
596 assertThat(ctx.getAttribute(pre + "name_of_the_list1[1].name_of" +
597 "_the_ll2[0]"), is("abc"));
598 assertThat(ctx.getAttribute(pre + "name_of_the_list1[1].name_of" +
599 "_the_ll2[1]"), is("abc"));
600 assertThat(ctx.getAttribute(pre + "name_of_the_list1[1].name_of" +
601 "_the_cont4.name_of_the_leaf11"),
603 assertThat(ctx.getAttribute(pre + "name_of_the_list1[1].name_of" +
604 "_the_list4[0].name_of_the_leaf8"),
606 assertThat(ctx.getAttribute(pre + "name_of_the_list1[1].name_of" +
607 "_the_list4[1].name_of_the_leaf8"),
609 assertThat(ctx.getAttribute(pre + "name_of_the_list1[1].name_of" +
610 "_the_list5[0].name_of_the_leaf9"),
612 assertThat(ctx.getAttribute(pre + "name_of_the_list1[1].name_of" +
613 "_the_list5[1].name_of_the_leaf9"),
615 assertThat(ctx.getAttribute(pre + "name_of_the_list2[0].name_of" +
616 "_the_leaf4"), is("abc"));
617 assertThat(ctx.getAttribute(pre + "name_of_the_list2[1].name_of" +
618 "_the_leaf4"), is("abc"));
619 assertThat(ctx.getAttribute(pre + "name_of_the_leaf5"),
621 assertThat(ctx.getAttribute(pre + "name_of_the_leaf6"),
623 assertThat(ctx.getAttribute(pre + "name_of_the_ll3[0]"),
625 assertThat(ctx.getAttribute(pre + "name_of_the_ll3[1]"),
627 assertThat(ctx.getAttribute(pre + "name_of_the_ll4[0]"),
629 assertThat(ctx.getAttribute(pre + "name_of_the_ll4[1]"),
631 assertThat(ctx.getAttribute(pre + "name_of_the_cont4.name_of" +
632 "_the_leaf10"), is( "abc"));
633 assertThat(ctx.getAttribute(pre + "name_of_the_list6[0].name_of" +
634 "_the_leaf11"), is("abc"));
635 assertThat(ctx.getAttribute(pre + "name_of_the_list6[1].name_of" +
636 "_the_leaf11"), is("abc"));
637 assertThat(ctx.getAttribute(pre + "name_of_the_leaf12"),
639 assertThat(ctx.getAttribute(pre + "name_of_the_ll5[0]"),
641 assertThat(ctx.getAttribute(pre + "name_of_the_ll5[1]"),
643 assertThat(ctx.getAttribute(pre + "name_of_the_cont4.test_" +
644 "augment_1_for_module_name_of_" +
645 "the_cont5.name_of_the_leaf13"),
647 assertThat(ctx.getAttribute(pre + "name_of_the_cont4.test_" +
648 "augment_1_for_module_name_of_" +
649 "the_list7[0].name_of_the_leaf14"),
651 assertThat(ctx.getAttribute(pre + "name_of_the_cont4.test_" +
652 "augment_1_for_module_name_of_" +
653 "the_list7[1].name_of_the_leaf14"),
655 assertThat(ctx.getAttribute(pre + "name_of_the_cont4.test_" +
656 "augment_1_for_module_name_of_" +
659 assertThat(ctx.getAttribute(pre + "name_of_the_cont4.test_" +
660 "augment_1_for_module_name_of_" +
663 assertThat(ctx.getAttribute(pre + "name_of_the_cont4.test_" +
664 "augment_1_for_module_name_of_" +
667 assertThat(ctx.getAttribute(pre + "name_of_the_cont4.test_" +
668 "augment_1_for_module_name_of_" +
670 ".name_of_the_cont12.name_of_" +
671 "the_leaf26"), is("abc"));
672 assertThat(ctx.getAttribute(pre + "name_of_the_cont4.test_" +
673 "augment_1_for_module_name_of_" +
674 "the_cont13.name_of_the_list9[0]" +
675 ".name_of_the_leaf27"),
677 assertThat(ctx.getAttribute(pre + "name_of_the_cont4.test_" +
678 "augment_1_for_module_name_of_" +
679 "the_cont13.name_of_the_list9[1]" +
680 ".name_of_the_leaf27"),
682 assertThat(ctx.getAttribute(pre + "name_of_the_cont4.test_" +
683 "augment_1_for_module_name_of_" +
684 "the_cont13.name_of_the_leaf28"),
686 assertThat(ctx.getAttribute(pre + "name_of_the_cont4.test_" +
687 "augment_1_for_module_name_of_" +
688 "the_cont13.name_of_the_ll9[0]"),
690 assertThat(ctx.getAttribute(pre + "name_of_the_cont4.test_" +
691 "augment_1_for_module_name_of_" +
692 "the_cont13.name_of_the_ll9[1]"),
697 * Verifies the attribute list for decoding from JSON or XML with
700 * @param ctx service logic context
703 private void verifyAttListRpc(SvcLogicContext ctx, String pre) {
704 assertThat(ctx.getAttribute(pre + "name_of_the_cont16.name_of_" +
705 "the_leaf32"), is("abc"));
706 assertThat(ctx.getAttribute(pre + "name_of_the_list11[0].name" +
707 "_of_the_leaf33"), is("abc"));
708 assertThat(ctx.getAttribute(pre + "name_of_the_list11[1].name" +
709 "_of_the_leaf33"), is("abc"));
710 assertThat(ctx.getAttribute(pre + "name_of_the_leaf34"),
712 assertThat(ctx.getAttribute(pre + "name_of_the_ll11[0]"),
714 assertThat(ctx.getAttribute(pre + "name_of_the_ll11[1]"),
716 assertThat(ctx.getAttribute(pre + "name_of_the_cont17.name_of_" +
717 "the_leaf35"), is("abc"));
718 assertThat(ctx.getAttribute(pre + "name_of_the_cont13.name_of_" +
719 "the_cont12.name_of_the_leaf26"),
721 assertThat(ctx.getAttribute(pre + "name_of_the_cont13.name_of_" +
722 "the_list9[0].name_of_the_leaf27"),
724 assertThat(ctx.getAttribute(pre + "name_of_the_cont13.name_of_" +
725 "the_list9[1].name_of_the_leaf27"),
727 assertThat(ctx.getAttribute(pre + "name_of_the_cont13.name_of_" +
728 "the_ll9[0]"), is("abc"));
729 assertThat(ctx.getAttribute(pre + "name_of_the_cont13.name_of_" +
730 "the_ll9[1]"), is("abc"));
731 assertThat(ctx.getAttribute(pre + "name_of_the_cont13.name_of_" +
732 "the_leaf28"), is("abc"));
736 * Captures the data format messages by mocking it, which can be used in
739 * @param <String> capturing data format
741 public class DfCaptor<String> implements Answer {
743 private String result;
746 * Returns the captured data format message.
748 * @return data format message.
750 public String getResult() {
755 public String answer(InvocationOnMock invocationOnMock)
757 result = (String) invocationOnMock.callRealMethod();