summaryrefslogtreecommitdiffstats
path: root/plugins/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormatSerializerTest.java
blob: a5353fad4307c4508ea22b6773913237a73421f5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
/*-
 * ============LICENSE_START=======================================================
 * ONAP - CCSDK
 * ================================================================================
 * Copyright (C) 2018 Huawei Technologies Co., Ltd. All rights reserved.
 * ================================================================================
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * ============LICENSE_END=========================================================
 */

package org.onap.ccsdk.sli.plugins.yangserializers.dfserializer;

import java.util.HashMap;
import java.util.Map;

import org.junit.Before;
import org.junit.Test;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
import org.onap.ccsdk.sli.core.sli.SvcLogicException;
import org.onap.ccsdk.sli.plugins.restapicall.HttpResponse;
import org.onap.ccsdk.sli.plugins.restapicall.RestapiCallNode;
import org.onap.ccsdk.sli.plugins.restconfapicall.RestconfApiCallNode;
import org.opendaylight.restconf.common.context.InstanceIdentifierContext;
import org.opendaylight.yangtools.yang.model.parser.api.YangParserFactory;
import org.opendaylight.yangtools.yang.parser.impl.YangParserFactoryImpl;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.doCallRealMethod;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.onap.ccsdk.sli.plugins.restapicall.HttpMethod.GET;
import static org.onap.ccsdk.sli.plugins.restapicall.HttpMethod.PATCH;
import static org.onap.ccsdk.sli.plugins.restapicall.HttpMethod.POST;
import static org.onap.ccsdk.sli.plugins.restapicall.HttpMethod.PUT;
import static org.onap.ccsdk.sli.plugins.restconfapicall.RestconfApiUtils.parseUrl;
import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DataFormatUtilsTest.DECODE_ANYXML_RESPONSE;
import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DataFormatUtilsTest.DECODE_FROM_JSON_RPC;
import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DataFormatUtilsTest.DECODE_FROM_XML_RPC;
import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DataFormatUtilsTest.ENCODE_TO_ANYXML;
import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DataFormatUtilsTest.ENCODE_TO_JSON_ID;
import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DataFormatUtilsTest.ENCODE_TO_JSON_ID_PUT;
import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DataFormatUtilsTest.ENCODE_TO_JSON_RPC;
import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DataFormatUtilsTest.ENCODE_TO_JSON_YANG;
import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DataFormatUtilsTest.ENCODE_TO_JSON_YANG_AUG_POST;
import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DataFormatUtilsTest.ENCODE_TO_JSON_YANG_PUT;
import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DataFormatUtilsTest.ENCODE_TO_XML_ID;
import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DataFormatUtilsTest.ENCODE_TO_XML_ID_PUT;
import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DataFormatUtilsTest.ENCODE_TO_XML_RPC;
import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DataFormatUtilsTest.ENCODE_TO_XML_YANG;
import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DataFormatUtilsTest.ENCODE_TO_XML_YANG_AUG_POST;
import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DataFormatUtilsTest.ENCODE_TO_XML_YANG_PUT;


/**
 * Unit test cases for data format serialization and restconf api call node.
 */
public class DataFormatSerializerTest {

    private Map<String, String> p;

    private RestconfApiCallNode restconf;

    private RestapiCallNode restApi;

    private YangParserFactory parserFactory;

    private DfCaptor dfCaptor;

    /**
     * Sets up the pre-requisite for each test case.
     *
     * @throws SvcLogicException when test case fails
     */
    @Before
    public void setUp() throws SvcLogicException {
        p = new HashMap<>();
        p.put("restapiUser", "user1");
        p.put("restapiPassword", "abc123");
        p.put("responsePrefix", "response");
        p.put("skipSending", "true");
        restApi = new RestapiCallNode();
        parserFactory = new YangParserFactoryImpl();
        restconf = mock(RestconfApiCallNode.class);
        dfCaptor = new DfCaptor();
        createMethodMocks();
    }

    /**
     * Creates method mocks using mockito for RestconfApiCallNode class.
     *
     * @throws SvcLogicException when test case fails
     */
    private void createMethodMocks() throws SvcLogicException {
        doReturn(restApi).when(restconf).getRestapiCallNode();
        doReturn(parserFactory).when(restconf).getParserFactory();
        doCallRealMethod().when(restconf).sendRequest(
                any(Map.class), any(SvcLogicContext.class));
        doCallRealMethod().when(restconf).sendRequest(
                any(Map.class), any(SvcLogicContext.class), any(Integer.class));
        doAnswer(dfCaptor).when(restconf).serializeRequest(
                any(Map.class), any(YangParameters.class), any(String.class),
                any(InstanceIdentifierContext.class));
        doAnswer(dfCaptor).when(restconf).updateReq(
                any(String.class), any(YangParameters.class),
                any(InstanceIdentifierContext.class));
    }

    /**
     * Creates mock using mockito with input data for decoding.
     *
     * @param decodeData input data
     * @throws SvcLogicException when test case fails
     */
    private void createMockForDecode(String decodeData)
            throws SvcLogicException {
        doReturn(decodeData).when(restconf).getResponse(
                any(SvcLogicContext.class), any(YangParameters.class),
                any(String.class), any(HttpResponse.class));
        doCallRealMethod().when(restconf).serializeResponse(
                any(YangParameters.class), any(String.class), any(String.class),
                any(InstanceIdentifierContext.class));
    }

    /**
     * Verifies encoding of parameters to JSON data format with identity-ref
     * and inter-file linking.
     *
     * @throws SvcLogicException when test case fails
     */
    @Test
    public void encodeToJsonId() throws SvcLogicException {
        String pre = "identity-test_test.";
        SvcLogicContext ctx = createAttList(pre);
        ctx.setAttribute(pre + "l", "abc");
        p.put("dirPath", "src/test/resources");
        p.put("format", "json");
        p.put("httpMethod", "post");
        p.put("restapiUrl", "http://echo.getpostman" +
                ".com/restconf/operations/identity-test:test");
        restconf.sendRequest(p, ctx);
        assertThat(dfCaptor.getResult(), is(ENCODE_TO_JSON_ID));
    }

    /**
     * Verifies encoding of parameters to JSON data format any xml in it.
     *
     * @throws SvcLogicException when test case fails
     */
    @Test
    public void encodeForAnyXml() throws SvcLogicException {
        String pre = "execution-service_process.";
        SvcLogicContext ctx = createAnyXmlAttList(pre);
        p.put("dirPath", "src/test/resources");
        p.put("format", "json");
        p.put("httpMethod", "post");
        p.put("restapiUrl", "http://echo.getpostman" +
                ".com/api/v1/execution-service/process");
        restconf.sendRequest(p, ctx);
        assertThat(dfCaptor.getResult(), is(ENCODE_TO_ANYXML));
    }

    /**
     * Verifies encoding of parameters to JSON data format with identity-ref
     * and inter-file linking for put operation-type.
     *
     * @throws SvcLogicException when test case fails
     */
    @Test
    public void encodeToJsonIdWithPut() throws SvcLogicException {
        String pre = "identity-test_test.";
        SvcLogicContext ctx = createAttList(pre);
        ctx.setAttribute(pre + "l", "abc");
        p.put("dirPath", "src/test/resources");
        p.put("format", "json");
        p.put("httpMethod", "put");
        p.put("restapiUrl", "http://echo.getpostman" +
                ".com/restconf/operations/identity-test:test");
        restconf.sendRequest(p, ctx);
        assertThat(dfCaptor.getResult(), is(ENCODE_TO_JSON_ID_PUT));
    }

    /**
     * Verifies encoding of parameters to JSON data format with identity-ref
     * and inter-file linking for patch operation-type.
     *
     * @throws SvcLogicException when test case fails
     */
    @Test
    public void encodeToJsonIdWithPatch() throws SvcLogicException {
        String pre = "identity-test_test.";
        SvcLogicContext ctx = createAttList(pre);
        ctx.setAttribute(pre + "l", "abc");
        p.put("dirPath", "src/test/resources");
        p.put("format", "json");
        p.put("httpMethod", "patch");
        p.put("restapiUrl", "http://echo.getpostman" +
                ".com/restconf/operations/identity-test:test");
        restconf.sendRequest(p, ctx);
        assertThat(dfCaptor.getResult(), is(ENCODE_TO_JSON_ID_PUT));
    }

    /**
     * Verifies encoding of parameters to XML data format with identity-ref
     * and inter-file linking.
     *
     * @throws SvcLogicException when test case fails
     */
    @Test
    public void encodeToXmlId() throws SvcLogicException {
        String pre = "identity-test_test.";
        SvcLogicContext ctx = createAttList(pre);
        p.put("dirPath", "src/test/resources");
        p.put("format", "xml");
        p.put("httpMethod", "post");
        p.put("restapiUrl", "http://echo.getpostman" +
                ".com/restconf/operations/identity-test:test");
        restconf.sendRequest(p, ctx);
        assertThat(dfCaptor.getResult(), is(ENCODE_TO_XML_ID));
    }

    /**
     * Verifies encoding of parameters to XML data format with identity-ref
     * and inter-file linking for put operation-type.
     *
     * @throws SvcLogicException when test case fails
     */
    @Test
    public void encodeToXmlIdWithPut() throws SvcLogicException {
        String pre = "identity-test_test.";
        SvcLogicContext ctx = createAttList(pre);
        p.put("dirPath", "src/test/resources");
        p.put("format", "xml");
        p.put("httpMethod", "put");
        p.put("restapiUrl", "http://echo.getpostman" +
                ".com/restconf/operations/identity-test:test");
        restconf.sendRequest(p, ctx);
        assertThat(dfCaptor.getResult(), is(ENCODE_TO_XML_ID_PUT));
    }

    /**
     * Verifies encoding of parameters to XML data format with identity-ref
     * and inter-file linking for patch operation-type.
     *
     * @throws SvcLogicException when test case fails
     */
    @Test
    public void encodeToXmlIdWithPatch() throws SvcLogicException {
        String pre = "identity-test_test.";
        SvcLogicContext ctx = createAttList(pre);
        p.put("dirPath", "src/test/resources");
        p.put("format", "xml");
        p.put("httpMethod", "patch");
        p.put("restapiUrl", "http://echo.getpostman" +
                ".com/restconf/operations/identity-test:test");
        restconf.sendRequest(p, ctx);
        assertThat(dfCaptor.getResult(), is(ENCODE_TO_XML_ID_PUT));
    }

    /**
     * Verifies decoding of parameters from JSON data format with identity-ref
     * and inter-file linking.
     *
     * @throws SvcLogicException when test case fails
     */
    @Test
    public void decodeToJsonId() throws SvcLogicException {
        createMockForDecode(ENCODE_TO_JSON_ID);
        SvcLogicContext ctx = new SvcLogicContext();
        String pre = "identity-test_test.";
        p.put("dirPath", "src/test/resources");
        p.put("format", "json");
        p.put("httpMethod", "get");
        p.put("restapiUrl", "http://echo.getpostman" +
                ".com/restconf/operations/identity-test:test");
        restconf.sendRequest(p, ctx);
        assertThat(ctx.getAttribute(pre + "l"), is("abc"));
        verifyAttList(ctx, pre);
    }

    /**
     * Verifies decoding of parameters from XML data format with identity-ref
     * and inter-file linking.
     *
     * @throws SvcLogicException when test case fails
     */
    @Test
    public void decodeToXmlId() throws SvcLogicException {
        createMockForDecode(ENCODE_TO_XML_ID);
        SvcLogicContext ctx = new SvcLogicContext();
        String pre = "identity-test_test.";
        p.put("dirPath", "src/test/resources");
        p.put("format", "xml");
        p.put("httpMethod", "get");
        p.put("restapiUrl", "http://echo.getpostman" +
                ".com/restconf/operations/identity-test:test");
        restconf.sendRequest(p, ctx);
        verifyAttList(ctx, pre);
    }

    /**
     * Verifies encoding of parameters to JSON data format with containers,
     * grouping and augment.
     *
     * @throws SvcLogicException when test case fails
     */
    @Test
    public void encodeToJsonYang() throws SvcLogicException {
        String pre = "test-yang_cont1.cont2.";
        SvcLogicContext ctx = createAttListYang(pre);
        p.put("dirPath", "src/test/resources");
        p.put("format", "json");
        p.put("httpMethod", "post");
        p.put("restapiUrl", "http://echo.getpostman" +
                ".com/restconf/operations/test-yang:cont1");
        restconf.sendRequest(p, ctx);
        assertThat(dfCaptor.getResult(), is(ENCODE_TO_JSON_YANG));
    }

    /**
     * Verifies encoding of parameters to JSON data format with containers,
     * grouping and augment for put operation-type.
     *
     * @throws SvcLogicException when test case fails
     */
    @Test
    public void encodeToJsonYangWithPut() throws SvcLogicException {
        String pre = "test-yang_cont1.cont2.";
        SvcLogicContext ctx = createAttListYang(pre);
        p.put("dirPath", "src/test/resources");
        p.put("format", "json");
        p.put("httpMethod", "put");
        p.put("restapiUrl", "http://echo.getpostman" +
                ".com/restconf/operations/test-yang:cont1/cont2/cont4");
        restconf.sendRequest(p, ctx);
        assertThat(dfCaptor.getResult(), is(ENCODE_TO_JSON_YANG_PUT));
    }

    /**
     * Verifies encoding of parameters to JSON data format with containers,
     * grouping and augment for patch operation-type.
     *
     * @throws SvcLogicException when test case fails
     */
    @Test
    public void encodeToJsonYangWithPatch() throws SvcLogicException {
        String pre = "test-yang_cont1.cont2.";
        SvcLogicContext ctx = createAttListYang(pre);
        p.put("dirPath", "src/test/resources");
        p.put("format", "json");
        p.put("httpMethod", "patch");
        p.put("restapiUrl", "http://echo.getpostman" +
                ".com/restconf/operations/test-yang:cont1/cont2/cont4");
        restconf.sendRequest(p, ctx);
        assertThat(dfCaptor.getResult(), is(ENCODE_TO_JSON_YANG_PUT));
    }

    /**
     * Verifies encoding of parameters to JSON data format with augment as
     * root child.
     *
     * @throws SvcLogicException when test case fails
     */
    @Test
    public void encodeToJsonWithAugAsRootChild() throws SvcLogicException {
        String pre = "test-yang_cont1.cont2.";
        SvcLogicContext ctx = createAttListYang(pre);
        p.put("dirPath", "src/test/resources");
        p.put("format", "json");
        p.put("httpMethod", "post");
        p.put("restapiUrl", "http://echo.getpostman" +
                ".com/restconf/operations/test-yang:cont1/cont2/cont4");
        restconf.sendRequest(p, ctx);
        assertThat(dfCaptor.getResult(), is(ENCODE_TO_JSON_YANG_AUG_POST));
    }

    /**
     * Verifies decoding of parameters from JSON data format with containers,
     * grouping and augment.
     *
     * @throws SvcLogicException when test case fails
     */
    @Test
    public void decodeToJsonYang() throws SvcLogicException {
        createMockForDecode(ENCODE_TO_JSON_YANG);
        SvcLogicContext ctx = new SvcLogicContext();
        String pre = "test-yang_cont1.cont2.";
        p.put("dirPath", "src/test/resources");
        p.put("format", "json");
        p.put("httpMethod", "get");
        p.put("restapiUrl", "http://echo.getpostman" +
                ".com/restconf/operations/test-yang:cont1");
        restconf.sendRequest(p, ctx);
        verifyAttListYang(ctx, pre);
    }

    /**
     * Verifies encoding of parameters to XML data format with containers,
     * grouping and augment.
     *
     * @throws SvcLogicException when test case fails
     */
    @Test
    public void encodeToXmlYang() throws SvcLogicException {
        String pre = "test-yang_cont1.cont2.";
        SvcLogicContext ctx = createAttListYang(pre);
        p.put("dirPath", "src/test/resources");
        p.put("format", "xml");
        p.put("httpMethod", "post");
        p.put("restapiUrl", "http://echo.getpostman" +
                ".com/restconf/operations/test-yang:cont1");
        restconf.sendRequest(p, ctx);
        assertThat(dfCaptor.getResult(), is(ENCODE_TO_XML_YANG));
    }

    /**
     * Verifies encoding of parameters to XML data format with containers,
     * grouping and augment for put operation-type
     *
     * @throws SvcLogicException when test case fails
     */
    @Test
    public void encodeToXmlYangWithPut() throws SvcLogicException {
        String pre = "test-yang_cont1.cont2.";
        SvcLogicContext ctx = createAttListYang(pre);
        p.put("dirPath", "src/test/resources");
        p.put("format", "xml");
        p.put("httpMethod", "put");
        p.put("restapiUrl", "http://echo.getpostman" +
                ".com/restconf/operations/test-yang:cont1/cont2/cont4");
        restconf.sendRequest(p, ctx);
        assertThat(dfCaptor.getResult(), is(ENCODE_TO_XML_YANG_PUT));
    }

    /**
     * Verifies encoding of parameters to XML data format with containers,
     * grouping and augment for patch operation-type
     *
     * @throws SvcLogicException when test case fails
     */
    @Test
    public void encodeToXmlYangWithPatch() throws SvcLogicException {
        String pre = "test-yang_cont1.cont2.";
        SvcLogicContext ctx = createAttListYang(pre);
        p.put("dirPath", "src/test/resources");
        p.put("format", "xml");
        p.put("httpMethod", "put");
        p.put("restapiUrl", "http://echo.getpostman" +
                ".com/restconf/operations/test-yang:cont1/cont2/cont4");
        restconf.sendRequest(p, ctx);
        assertThat(dfCaptor.getResult(), is(ENCODE_TO_XML_YANG_PUT));
    }

    /**
     * Verifies encoding of parameters to XML data format with augment as
     * root child.
     *
     * @throws SvcLogicException when test case fails
     */
    @Test
    public void encodeToXmlWithAugAsRootChild() throws SvcLogicException {
        String pre = "test-yang_cont1.cont2.";
        SvcLogicContext ctx = createAttListYang(pre);
        p.put("dirPath", "src/test/resources");
        p.put("format", "xml");
        p.put("httpMethod", "post");
        p.put("restapiUrl", "http://echo.getpostman" +
                ".com/restconf/operations/test-yang:cont1/cont2/cont4");
        restconf.sendRequest(p, ctx);
        assertThat(dfCaptor.getResult(), is(ENCODE_TO_XML_YANG_AUG_POST));
    }

    /**
     * Verifies decoding of parameters from XML data format with containers,
     * grouping and augment.
     *
     * @throws SvcLogicException when test case fails
     */
    @Test
    public void decodeToXmlYang() throws SvcLogicException {
        createMockForDecode(ENCODE_TO_XML_YANG);
        SvcLogicContext ctx = new SvcLogicContext();
        String pre = "test-yang_cont1.cont2.";
        p.put("dirPath", "src/test/resources");
        p.put("format", "xml");
        p.put("httpMethod", "get");
        p.put("restapiUrl", "http://echo.getpostman" +
                ".com/restconf/operations/test-yang:cont1");
        restconf.sendRequest(p, ctx);
        verifyAttListYang(ctx, pre);
    }

    /**
     * Verifies encoding of and decoding from, JSON respectively for data
     * format with containers, grouping and augment.
     *
     * @throws SvcLogicException when test case fails
     */
    @Test
    public void codecToJsonRpc() throws SvcLogicException {
        createMockForDecode(DECODE_FROM_JSON_RPC);
        String inPre = "test-yang_create-sfc.input.";
        String outPre = "test-yang_create-sfc.output.";
        SvcLogicContext ctx = createAttListRpc(inPre);
        p.put("dirPath", "src/test/resources");
        p.put("format", "json");
        p.put("httpMethod", "post");
        p.put("restapiUrl", "http://echo.getpostman" +
                ".com/restconf/operations/test-yang:create-sfc");
        restconf.sendRequest(p, ctx);
        assertThat(dfCaptor.getResult(), is(ENCODE_TO_JSON_RPC));
        verifyAttListRpc(ctx, outPre);
    }

    /**
     * Verifies encoding of and decoding from, JSON for ANYXML.
     *
     * @throws SvcLogicException when test case fails
     */
    @Test
    public void codecForNormalAnyXml() throws SvcLogicException {
        createMockForDecode(DECODE_ANYXML_RESPONSE);
        String inPre = "execution-service_process.";
        SvcLogicContext ctx = createAnyXmlAttList(inPre);
        p.put("dirPath", "src/test/resources");
        p.put("format", "json");
        p.put("httpMethod", "post");
        p.put("responsePrefix", "pp");
        p.put("restapiUrl", "http://echo.getpostman" +
                ".com/api/v1/execution-service/process");
        restconf.sendRequest(p, ctx);
        assertThat(dfCaptor.getResult(), is(ENCODE_TO_ANYXML));
        verifyOutputOfAnyXml(ctx);
    }

    /**
     * Verifies encoding of and decoding from, XML respectively for data
     * format with containers, grouping and augment.
     *
     * @throws SvcLogicException when test case fails
     */
    @Test
    public void codecToXmlRpc() throws SvcLogicException {
        createMockForDecode(DECODE_FROM_XML_RPC);
        String inPre = "test-yang_create-sfc.input.";
        String outPre = "test-yang_create-sfc.output.";
        SvcLogicContext ctx = createAttListRpc(inPre);
        p.put("dirPath", "src/test/resources");
        p.put("format", "xml");
        p.put("httpMethod", "post");
        p.put("restapiUrl", "http://echo.getpostman" +
                ".com/restconf/operations/test-yang:create-sfc");
        restconf.sendRequest(p, ctx);
        assertThat(dfCaptor.getResult(), is(ENCODE_TO_XML_RPC));
        verifyAttListRpc(ctx, outPre);
    }

    /**
     * Verifies URL parser returning path with only schema information for all
     * kind of URL.
     *
     * @throws SvcLogicException when test case fails
     */
    @Test
    public void validateUrlParser() throws SvcLogicException {
        String actVal = "identity-test:test";
        String putId = "/for-put";
        String url1 = "http://echo.getpostman.com/restconf/operations/" +
                actVal;
        String url2 = "http://echo.getpostman.com/restconf/data/" + actVal;
        String url3 = "https://echo.getpostman.com/restconf/operations/" +
                actVal;
        String url4 = "https://echo.getpostman.com/restconf/data/" + actVal +
                putId;
        String url5 = "http://localhost:8282/restconf/operations/" + actVal;
        String url6 = "https://localhost:8282/restconf/operations/" + actVal;
        String url7 = "http://localhost:8282/restconf/data/" + actVal +
                putId;
        String url8 = "https://localhost:8282/restconf/data/" + actVal;
        String url9 = "http://182.2.61.24:2250/restconf/data/" + actVal;
        String url10 = "https://182.2.61.24:2250/restconf/operations/" + actVal;
        String url11 = "https://182.2.61.24:2250/api/v1/execution-service" +
                "/process";
        String url12 = "https://182.2.61.24:2250/api/v1/execution-service" +
                "/process/payload";
        String url13 = "https://182.2.61.24:2250/api/v1/execution-service" +
                "/process/payload/";
        String val1 = parseUrl(url1, POST);
        String val2 = parseUrl(url2, GET);
        String val3 = parseUrl(url3, PATCH);
        String val4 = parseUrl(url4, PUT);
        String val5 = parseUrl(url5, GET);
        String val6 = parseUrl(url6, POST);
        String val7 = parseUrl(url7, PUT);
        String val8 = parseUrl(url8, POST);
        String val9 = parseUrl(url9, GET);
        String val10 = parseUrl(url10, POST);
        String val11 = parseUrl(url11, POST);
        String val12 = parseUrl(url12, POST);
        String val13 = parseUrl(url13, POST);
        assertThat(val1, is(actVal));
        assertThat(val2, is(actVal));
        assertThat(val3, is(actVal));
        assertThat(val4, is(actVal + putId));
        assertThat(val5, is(actVal));
        assertThat(val6, is(actVal));
        assertThat(val7, is(actVal + putId));
        assertThat(val8, is(actVal));
        assertThat(val9, is(actVal));
        assertThat(val10, is(actVal));
        assertThat(val11, is("execution-service:process"));
        assertThat(val12, is("execution-service:process/payload"));
        assertThat(val13, is("execution-service:process/payload/"));
    }

    /**
     * Creates attribute list for encoding JSON or XML with ANYXML YANG
     * file.
     *
     * @param pre prefix
     * @return service logic context
     */
    private SvcLogicContext createAnyXmlAttList(String pre) {
        SvcLogicContext ctx = new SvcLogicContext();
        String pre1 = pre + "commonHeader.";
        String pre2 = pre + "actionIdentifiers.";
        ctx.setAttribute(pre + "isNonAppend", "true");
        ctx.setAttribute(pre1 + "originatorId", "SDNC_DG");
        ctx.setAttribute(pre1 + "requestId", "123456-1000");
        ctx.setAttribute(pre1 + "subRequestId", "sub-123456-1000");
        ctx.setAttribute(pre2 + "blueprintName",
                         "baseconfiguration");
        ctx.setAttribute(pre2 + "blueprintVersion", "1.0.0");
        ctx.setAttribute(pre2 + "actionName", "assign-activate");
        ctx.setAttribute(pre2 + "mode", "sync");
        ctx.setAttribute(pre + "payload." +
                                 "template-prefix", "vDNS-test");
        ctx.setAttribute(pre + "payload.resource-assignment-request" +
                                 ".resource-assignment-properties",
                         "{\n" +
                                 "                \"service-instance-id\": " +
                                 "\"1234\",\n" +
                                 "                \"vnf-id\": \"3526\",\n" +
                                 "                \"customer-name\": \"htipl\",\n" +
                                 "                \"subscriber-name\": \"huawei\"\n" +
                                 "            }");
        return ctx;
    }

    /**
     * Creates attribute list for encoding JSON or XML with identity-ref YANG
     * file.
     *
     * @param pre prefix
     * @return service logic context
     */
    private SvcLogicContext createAttList(String pre) {
        SvcLogicContext ctx = new SvcLogicContext();
        String pre1 = pre + "con1.interfaces.";
        ctx.setAttribute(pre + "con1.interface", "identity-types:physical");
        ctx.setAttribute(pre1 + "int-list[0].iden", "optical");
        ctx.setAttribute(pre1 + "int-list[0].available.ll[0]", "Giga");
        ctx.setAttribute(pre1 + "int-list[0].available.ll[1]",
                         "identity-types:Loopback");
        ctx.setAttribute(pre1 + "int-list[0].available.ll[2]",
                         "identity-types-second:Ethernet");
        ctx.setAttribute(pre1 + "int-list[0].available.leaf1", "58");
        ctx.setAttribute(pre1 + "int-list[0].available.leaf2",
                         "identity-types-second:iden2");

        ctx.setAttribute(pre1 + "int-list[1].iden", "214748364");
        ctx.setAttribute(pre1 + "int-list[1].available.ll[0]", "Giga");
        ctx.setAttribute(pre1 + "int-list[1].available.ll[1]",
                         "identity-types:Loopback");
        ctx.setAttribute(pre1 + "int-list[1].available.ll[2]",
                         "identity-types-second:Ethernet");
        ctx.setAttribute(pre1 + "int-list[1].available.leaf1",
                         "8888");
        ctx.setAttribute(pre1 + "int-list[1].available.leaf2",
                         "identity-types-second:iden2");
        return ctx;
    }

    /**
     * Creates attribute list for encoding JSON or XML with container,
     * grouping and augmented YANG file.
     *
     * @param pre prefix
     * @return service logic context
     */
    private SvcLogicContext createAttListYang(String pre) {
        SvcLogicContext ctx = new SvcLogicContext();
        ctx.setAttribute(pre + "cont3.leaf10", "abc");
        ctx.setAttribute(pre + "list1[0].leaf1", "true");
        ctx.setAttribute(pre + "list1[0].leaf2", "abc");
        ctx.setAttribute(pre + "list1[0].leaf3", "abc");
        ctx.setAttribute(pre + "list1[0].ll1[0]", "abc");
        ctx.setAttribute(pre + "list1[0].ll1[1]", "abc");
        ctx.setAttribute(pre + "list1[0].ll2[0]", "abc");
        ctx.setAttribute(pre + "list1[0].ll2[1]", "abc");
        ctx.setAttribute(pre + "list1[0].cont4.leaf11", "abc");
        ctx.setAttribute(pre + "list1[0].list4[0].leaf8", "abc");
        ctx.setAttribute(pre + "list1[0].list4[1].leaf8", "abc");
        ctx.setAttribute(pre + "list1[0].list5[0].leaf9", "abc");
        ctx.setAttribute(pre + "list1[0].list5[1].leaf9", "abc");
        ctx.setAttribute(pre + "list1[1].leaf1", "true");
        ctx.setAttribute(pre + "list1[1].leaf2", "abc");
        ctx.setAttribute(pre + "list1[1].leaf3", "abc");
        ctx.setAttribute(pre + "list1[1].ll1[0]", "abc");
        ctx.setAttribute(pre + "list1[1].ll1[1]", "abc");
        ctx.setAttribute(pre + "list1[1].ll2[0]", "abc");
        ctx.setAttribute(pre + "list1[1].ll2[1]", "abc");
        ctx.setAttribute(pre + "list1[1].cont4.leaf11", "abc");
        ctx.setAttribute(pre + "list1[1].list4[0].leaf8", "abc");
        ctx.setAttribute(pre + "list1[1].list4[1].leaf8", "abc");
        ctx.setAttribute(pre + "list1[1].list5[0].leaf9", "abc");
        ctx.setAttribute(pre + "list1[1].list5[1].leaf9", "abc");
        ctx.setAttribute(pre + "list2[0].leaf4", "abc");
        ctx.setAttribute(pre + "list2[1].leaf4", "abc");
        ctx.setAttribute(pre + "leaf5", "abc");
        ctx.setAttribute(pre + "leaf6", "abc");
        ctx.setAttribute(pre + "ll3[0]", "abc");
        ctx.setAttribute(pre + "ll3[1]", "abc");
        ctx.setAttribute(pre + "ll4[0]", "abc");
        ctx.setAttribute(pre + "ll4[1]", "abc");
        ctx.setAttribute(pre + "cont4.leaf10", "abc");
        ctx.setAttribute(pre + "list6[0].leaf11", "abc");
        ctx.setAttribute(pre + "list6[1].leaf11", "abc");
        ctx.setAttribute(pre + "leaf12", "abc");
        ctx.setAttribute(pre + "ll5[0]", "abc");
        ctx.setAttribute(pre + "ll5[1]", "abc");
        ctx.setAttribute(pre + "cont4.test-augment_cont5.leaf13", "true");
        ctx.setAttribute(pre + "cont4.test-augment_list7[0].leaf14", "test");
        ctx.setAttribute(pre + "cont4.test-augment_list7[1].leaf14", "create");
        ctx.setAttribute(pre + "cont4.test-augment_leaf15", "abc");
        ctx.setAttribute(pre + "cont4.test-augment_ll6[0]", "unbounded");
        ctx.setAttribute(pre + "cont4.test-augment_ll6[1]", "8");
        ctx.setAttribute(pre + "cont4.test-augment_cont13.cont12.leaf26",
                         "abc");
        ctx.setAttribute(pre + "cont4.test-augment_cont13.list9[0].leaf27",
                         "abc");
        ctx.setAttribute(pre + "cont4.test-augment_cont13.list9[1].leaf27",
                         "abc");
        ctx.setAttribute(pre + "cont4.test-augment_cont13.leaf28", "abc");
        ctx.setAttribute(pre + "cont4.test-augment_cont13.ll9[0]", "abc");
        ctx.setAttribute(pre + "cont4.test-augment_cont13.ll9[1]", "abc");
        return ctx;
    }

    /**
     * Creates attribute list for encoding JSON or XML with RPC YANG file.
     *
     * @param pre prefix
     * @return service logic context
     */
    private SvcLogicContext createAttListRpc(String pre) {
        SvcLogicContext ctx = new SvcLogicContext();
        ctx.setAttribute(pre + "cont14.leaf28", "abc");
        ctx.setAttribute(pre + "list10[0].leaf29", "abc");
        ctx.setAttribute(pre + "list10[1].leaf29", "abc");
        ctx.setAttribute(pre + "leaf30", "abc");
        ctx.setAttribute(pre + "ll10[0]", "abc");
        ctx.setAttribute(pre + "ll10[1]", "abc");
        ctx.setAttribute(pre + "cont15.leaf31", "abc");
        ctx.setAttribute(pre + "cont13.list9[0].leaf27", "abc");
        ctx.setAttribute(pre + "cont13.list9[1].leaf27", "abc");
        ctx.setAttribute(pre + "cont13.leaf28", "abc");
        ctx.setAttribute(pre + "cont13.ll9[0]", "abc");
        ctx.setAttribute(pre + "cont13.ll9[1]", "abc");
        return ctx;
    }

    /**
     * Verifies the attribute list for decoding from JSON or XML with
     * identity-ref YANG file.
     *
     * @param ctx service logic context
     * @param pre prefix
     */
    private void verifyAttList(SvcLogicContext ctx, String pre) {
        String pre1 = pre + "con1.interfaces.";
        assertThat(ctx.getAttribute(pre + "con1.interface"), is(
                "identity-types:physical"));
        assertThat(ctx.getAttribute(pre + "con1.interface"), is(
                "identity-types:physical"));
        assertThat(ctx.getAttribute(pre1 + "int-list[0].iden"), is("optical"));
        assertThat(ctx.getAttribute(pre1 + "int-list[0].available.ll[0]"), is(
                "Giga"));
        assertThat(ctx.getAttribute(pre1 + "int-list[0].available.ll[1]"), is(
                "identity-types:Loopback"));
        assertThat(ctx.getAttribute(pre1 + "int-list[0].available.ll[2]"), is(
                "identity-types-second:Ethernet"));
        assertThat(ctx.getAttribute(pre1 + "int-list[0].available.leaf1"), is(
                "58"));
        assertThat(ctx.getAttribute(pre1 + "int-list[0].available.leaf2"), is(
                "identity-types-second:iden2"));

        assertThat(ctx.getAttribute(pre1 + "int-list[1].iden"), is(
                "214748364"));
        assertThat(ctx.getAttribute(pre1 + "int-list[1].available.ll[0]"), is(
                "Giga"));
        assertThat(ctx.getAttribute(pre1 + "int-list[1].available.ll[1]"), is(
                "identity-types:Loopback"));
        assertThat(ctx.getAttribute(pre1 + "int-list[1].available.ll[2]"), is(
                "identity-types-second:Ethernet"));
        assertThat(ctx.getAttribute(pre1 + "int-list[1].available.leaf1"), is(
                "8888"));
        assertThat(ctx.getAttribute(pre1 + "int-list[1].available.leaf2"), is(
                "identity-types-second:iden2"));
    }

    /**
     * Verifies the attribute list for decoding from JSON or XML with
     * container, grouping and augmented file.
     *
     * @param ctx service logic context
     * @param pre prefix
     */
    private void verifyAttListYang(SvcLogicContext ctx, String pre) {
        assertThat(ctx.getAttribute(pre + "cont3.leaf10"), is("abc"));
        assertThat(ctx.getAttribute(pre + "list1[0].leaf1"), is("true"));
        assertThat(ctx.getAttribute(pre + "list1[0].leaf2"), is("abc"));
        assertThat(ctx.getAttribute(pre + "list1[0].leaf3"), is("abc"));
        assertThat(ctx.getAttribute(pre + "list1[0].ll1[0]"), is("abc"));
        assertThat(ctx.getAttribute(pre + "list1[0].ll1[1]"), is("abc"));
        assertThat(ctx.getAttribute(pre + "list1[0].ll2[0]"), is("abc"));
        assertThat(ctx.getAttribute(pre + "list1[0].ll2[1]"), is("abc"));
        assertThat(ctx.getAttribute(pre + "list1[0].cont4.leaf11"), is("abc"));
        assertThat(ctx.getAttribute(pre + "list1[0].list4[0].leaf8"),
                   is("abc"));
        assertThat(ctx.getAttribute(pre + "list1[0].list4[1].leaf8"),
                   is("abc"));
        assertThat(ctx.getAttribute(pre + "list1[0].list5[0].leaf9"),
                   is("abc"));
        assertThat(ctx.getAttribute(pre + "list1[0].list5[1].leaf9"),
                   is("abc"));
        assertThat(ctx.getAttribute(pre + "list1[1].leaf1"), is("true"));
        assertThat(ctx.getAttribute(pre + "list1[1].leaf2"), is("abc"));
        assertThat(ctx.getAttribute(pre + "list1[1].leaf3"), is("abc"));
        assertThat(ctx.getAttribute(pre + "list1[1].ll1[0]"), is("abc"));
        assertThat(ctx.getAttribute(pre + "list1[1].ll1[1]"), is("abc"));
        assertThat(ctx.getAttribute(pre + "list1[1].ll2[0]"), is("abc"));
        assertThat(ctx.getAttribute(pre + "list1[1].ll2[1]"), is("abc"));
        assertThat(ctx.getAttribute(pre + "list1[1].cont4.leaf11"), is("abc"));
        assertThat(ctx.getAttribute(pre + "list1[1].list4[0].leaf8"),
                   is("abc"));
        assertThat(ctx.getAttribute(pre + "list1[1].list4[1].leaf8"),
                   is("abc"));
        assertThat(ctx.getAttribute(pre + "list1[1].list5[0].leaf9"),
                   is("abc"));
        assertThat(ctx.getAttribute(pre + "list1[1].list5[1].leaf9"),
                   is("abc"));
        assertThat(ctx.getAttribute(pre + "list2[0].leaf4"), is("abc"));
        assertThat(ctx.getAttribute(pre + "list2[1].leaf4"), is("abc"));
        assertThat(ctx.getAttribute(pre + "leaf5"), is("abc"));
        assertThat(ctx.getAttribute(pre + "leaf6"), is("abc"));
        assertThat(ctx.getAttribute(pre + "ll3[0]"), is("abc"));
        assertThat(ctx.getAttribute(pre + "ll3[1]"), is("abc"));
        assertThat(ctx.getAttribute(pre + "ll4[0]"), is("abc"));
        assertThat(ctx.getAttribute(pre + "ll4[1]"), is("abc"));
        assertThat(ctx.getAttribute(pre + "cont4.leaf10"), is( "abc"));
        assertThat(ctx.getAttribute(pre + "list6[0].leaf11"), is("abc"));
        assertThat(ctx.getAttribute(pre + "list6[1].leaf11"), is("abc"));
        assertThat(ctx.getAttribute(pre + "leaf12"), is("abc"));
        assertThat(ctx.getAttribute(pre + "ll5[0]"), is("abc"));
        assertThat(ctx.getAttribute(pre + "ll5[1]"), is("abc"));
        assertThat(ctx.getAttribute(pre + "cont4.test-augment_cont5.leaf13"),
                   is("true"));
        assertThat(ctx.getAttribute(pre + "cont4.test-augment_list7[0].leaf14"),
                   is("test"));
        assertThat(ctx.getAttribute(pre + "cont4.test-augment_list7[1].leaf14"),
                   is("create"));
        assertThat(ctx.getAttribute(pre + "cont4.test-augment_leaf15"),
                   is("abc"));
        assertThat(ctx.getAttribute(pre + "cont4.test-augment_ll6[0]"),
                   is("unbounded"));
        assertThat(ctx.getAttribute(pre + "cont4.test-augment_ll6[1]"),
                   is("8"));
        assertThat(ctx.getAttribute(pre + "cont4.test-augment_cont13" +
                                            ".cont12.leaf26"), is("abc"));
        assertThat(ctx.getAttribute(pre + "cont4.test-augment_cont13.list9[0]" +
                                            ".leaf27"), is("abc"));
        assertThat(ctx.getAttribute(pre + "cont4.test-augment_cont13.list9[1]" +
                                            ".leaf27"), is("abc"));
        assertThat(ctx.getAttribute(pre + "cont4.test-augment_cont13.leaf28"),
                   is("abc"));
        assertThat(ctx.getAttribute(pre + "cont4.test-augment_cont13.ll9[0]"),
                   is("abc"));
        assertThat(ctx.getAttribute(pre + "cont4.test-augment_cont13.ll9[1]"),
                   is("abc"));
    }

    /**
     * Verifies the attribute list for decoding from JSON or XML with
     * RPC YANG file.
     *
     * @param ctx service logic context
     * @param pre prefix
     */
    private void verifyAttListRpc(SvcLogicContext ctx, String pre) {
        assertThat(ctx.getAttribute(pre + "cont16.leaf32"), is("abc"));
        assertThat(ctx.getAttribute(pre + "list11[0].leaf33"), is("abc"));
        assertThat(ctx.getAttribute(pre + "list11[1].leaf33"), is("abc"));
        assertThat(ctx.getAttribute(pre + "leaf34"), is("abc"));
        assertThat(ctx.getAttribute(pre + "ll11[0]"), is("abc"));
        assertThat(ctx.getAttribute(pre + "ll11[1]"), is("abc"));
        assertThat(ctx.getAttribute(pre + "cont17.leaf35"), is("abc"));
        assertThat(ctx.getAttribute(pre + "cont13.cont12.leaf26"), is("abc"));
        assertThat(ctx.getAttribute(pre + "cont13.list9[0].leaf27"), is("abc"));
        assertThat(ctx.getAttribute(pre + "cont13.list9[1].leaf27"), is("abc"));
        assertThat(ctx.getAttribute(pre + "cont13.ll9[0]"), is("abc"));
        assertThat(ctx.getAttribute(pre + "cont13.ll9[1]"), is("abc"));
        assertThat(ctx.getAttribute(pre + "cont13.leaf28"), is("abc"));
    }

    /**
     * Verifies the attribute list for decoding from JSON or XML with
     * ANYXML YANG file.
     *
     * @param ctx service logic context
     */
    private void verifyOutputOfAnyXml(SvcLogicContext ctx) {
        System.out.println(ctx.getAttribute("pp.status.eventType"));
        assertThat(ctx.getAttribute("pp.status.eventType"), is(
                "EVENT_COMPONENT_EXECUTED"));
        assertThat(ctx.getAttribute("pp.actionIdentifiers.blueprintName"),
                   is("golden"));
        assertThat(ctx.getAttribute("pp.actionIdentifiers.mode"),
                   is("sync"));
        assertThat(ctx.getAttribute("pp.stepData.name"),
                   is("resource-assignment"));
        assertThat(ctx.getAttribute("pp.status.message"),
                   is("success"));
        assertThat(ctx.getAttribute("pp.commonHeader.originatorId"),
                   is("System"));
        assertThat(ctx.getAttribute("pp.status.code"),
                   is("200"));
        assertThat(ctx.getAttribute("pp.commonHeader.requestId"),
                   is("1234"));
        assertThat(ctx.getAttribute("pp.commonHeader.subRequestId"),
                   is("1234-12234"));
        assertThat(ctx.getAttribute("pp.commonHeader.timestamp"),
                   is("2019-05-18T23:42:41.658Z"));
        assertThat(ctx.getAttribute("pp.status.timestamp"),
                   is("2019-05-18T23:42:41.950Z"));
        assertThat(ctx.getAttribute("pp.actionIdentifiers.blueprintV" +
                                            "ersion"), is("1.0.0"));
        assertThat(ctx.getAttribute("pp.actionIdentifiers.actionName"),
                   is("resource-assignment"));
        assertThat(ctx.getAttribute("pp.payload.resource-assignment-resp" +
                                            "onse.meshed-template.vf-module-1"),
                   is("<interface>\n    <description>This i" +
                              "s the Virtual Firewall entity</description>\n" +
                              "    <vfw>10.0.101.20/24</vfw>\n" +
                              "</interface>"));
        assertThat(ctx.getAttribute("pp.actionIdentifiers.actionName"),
                   is("resource-assignment"));
    }


    /**
     * Captures the data format messages by mocking it, which can be used in
     * testing the value.
     *
     * @param <String> capturing data format
     */
    public class DfCaptor<String> implements Answer {

        private String result;

        /**
         * Returns the captured data format message.
         *
         * @return data format message.
         */
        public String getResult() {
            return result;
        }

        @Override
        public String answer(InvocationOnMock invocationOnMock)
                throws Throwable {
            result = (String) invocationOnMock.callRealMethod();
            return result;
        }
    }

}