cb1fd3795b449a2817fe71106296a73930274146
[appc.git] / appc-config / appc-config-audit / provider / src / test / java / org / openecomp / sdnc / config / audit / node / TestCompareNodeJson.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP : APP-C
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property.  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
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
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=========================================================
19  */
20
21 package org.openecomp.sdnc.config.audit.node;
22
23 import java.util.HashMap;
24
25 import org.junit.Test;
26 import org.openecomp.sdnc.config.audit.node.CompareNode;
27 import org.slf4j.Logger;
28 import org.slf4j.LoggerFactory;
29
30 import org.openecomp.sdnc.sli.SvcLogicContext;
31 import org.openecomp.sdnc.sli.SvcLogicException;
32
33 public class TestCompareNodeJson
34 {
35 private static final Logger log = LoggerFactory.getLogger(TestCompareNodeJson.class);
36
37     //@Test
38     public void TestCompareJsonForSamePayload()
39     {
40         SvcLogicContext ctx  = new SvcLogicContext();
41         HashMap<String, String> testMap = new HashMap<String, String>();
42         CompareNode cmp  = new CompareNode();
43         try
44         {
45             String controlJson = "{\n\"input\": {\n   \"appc-request-header\": {\n       \"svc-request-id\": \"000000000\", \n \"svc-action\": \"prepare\"   \n }, \n\"request-information\": {\n \"request-id\": \"000000000\", \n\"request-action\": \"VsbgServiceActivateRequest\", \n\"request-sub-action\": \"PREPARE\",  \n \"source\": \"Version2\" \n} \n} \n}";
46             String testJson = "{\n\"input\": {\n  \"appc-request-header\": {\n \"svc-request-id\": \"000000000\", \n \"svc-action\": \"prepare\"   \n }, \n\"request-information\": {\n \"request-id\": \"000000000\", \n\"request-action\": \"VsbgServiceActivateRequest\", \n\"request-sub-action\": \"PREPARE\",  \n \"source\": \"Version2\" \n} \n} \n}";
47             testMap.put("compareDataType", "RestConf");
48             testMap.put("sourceData", controlJson);
49             testMap.put("targetData", testJson);
50             cmp.compare(testMap, ctx);
51             assert(ctx.getAttribute("STATUS").equals("SUCCESS"));
52         }
53         catch (SvcLogicException e)
54         {
55             e.printStackTrace();
56         }
57     }
58
59     //@Test
60     public void TestCompareJsonFordifferentPayload()
61     {
62         SvcLogicContext ctx  = new SvcLogicContext();
63         HashMap<String, String> testMap = new HashMap<String, String>();
64         CompareNode cmp  = new CompareNode();
65         try
66         {
67             String controlJson = "{\n\"input\": {\n   \"appc-request-header\": {\n       \"svc-request-id\": \"000000000\", \n \"svc-action\": \"prepare\"   \n }, \n\"request-information\": {\n \"request-id\": \"000000000\", \n\"request-action\": \"VsbgServiceActivateRequest\", \n\"request-sub-action\": \"PREPARE\",  \n \"source\": \"Version2\" \n} \n} \n}";
68             String testJson = "{\n\"input\": {\n  \"appc-request-header\": { \n \"svc-action\": \"prepare\"   \n }, \n\"request-information\": {\n \"request-id\": \"0000000000\", \n\"request-action\": \"VsbgServiceActivateRequest\", \n\"request-sub-action\": \"PREPARE\",  \n \"source\": \"Version2\" \n} \n} \n}";
69             testMap.put("compareDataType", "RestConf");
70             testMap.put("sourceData", controlJson);
71             testMap.put("targetData", testJson);
72             cmp.compare(testMap, ctx);
73             assert(ctx.getAttribute("STATUS").equals("FAILURE"));
74         }
75         catch (SvcLogicException e)
76         {
77             e.printStackTrace();
78         }
79     }
80 }