631b223e560758770c3fcd22be17ffd897e23305
[appc.git] / appc-config / appc-config-audit / provider / src / test / java / org / onap / sdnc / config / audit / node / TestCompareNodeJson.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP : APPC
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Copyright (C) 2017 Amdocs
8  * =============================================================================
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  * 
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  * 
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  * 
21  * ECOMP is a trademark and service mark of AT&T Intellectual Property.
22  * ============LICENSE_END=========================================================
23  */
24
25 package org.onap.sdnc.config.audit.node;
26
27 import java.util.HashMap;
28
29 import org.junit.Test;
30 import org.onap.sdnc.config.audit.node.CompareNode;
31 import org.slf4j.Logger;
32 import org.slf4j.LoggerFactory;
33
34 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
35 import org.onap.ccsdk.sli.core.sli.SvcLogicException;
36
37 public class TestCompareNodeJson {
38     private static final Logger log = LoggerFactory.getLogger(TestCompareNodeJson.class);
39
40     @Test
41     public void TestCompareJsonForSamePayload() throws SvcLogicException {
42         SvcLogicContext ctx = new SvcLogicContext();
43         HashMap<String, String> testMap = new HashMap<String, String>();
44         CompareNode cmp = new CompareNode();
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
54     @Test
55     public void TestCompareJsonFordifferentPayload() throws SvcLogicException {
56         SvcLogicContext ctx = new SvcLogicContext();
57         HashMap<String, String> testMap = new HashMap<String, String>();
58         CompareNode cmp = new CompareNode();
59         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}";
60         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}";
61         testMap.put("compareDataType", "RestConf");
62         testMap.put("sourceData", controlJson);
63         testMap.put("targetData", testJson);
64         cmp.compare(testMap, ctx);
65         assert (ctx.getAttribute("STATUS").equals("FAILURE"));
66     }
67 }