60fc0a170c9e2e99bfc8aae7cdcc766cf54b9e5f
[appc.git] /
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP : APPC
4  * ================================================================================
5  * Copyright (C) 2017-2018 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  * ============LICENSE_END=========================================================
22  */
23
24 package org.onap.sdnc.config.audit.node;
25
26 import java.util.HashMap;
27
28 import org.junit.Test;
29 import org.onap.sdnc.config.audit.node.CompareNode;
30 import org.slf4j.Logger;
31 import org.slf4j.LoggerFactory;
32
33 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
34 import org.onap.ccsdk.sli.core.sli.SvcLogicException;
35
36 public class TestCompareNodeJson {
37     private static final Logger log = LoggerFactory.getLogger(TestCompareNodeJson.class);
38
39     @Test
40     public void TestCompareJsonForSamePayload() throws SvcLogicException {
41         SvcLogicContext ctx = new SvcLogicContext();
42         HashMap<String, String> testMap = new HashMap<String, String>();
43         CompareNode cmp = new CompareNode();
44         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}";
45         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}";
46         testMap.put("compareDataType", "RestConf");
47         testMap.put("sourceData", controlJson);
48         testMap.put("targetData", testJson);
49         cmp.compare(testMap, ctx);
50         assert (ctx.getAttribute("STATUS").equals("SUCCESS"));
51     }
52
53     @Test
54     public void TestCompareJsonFordifferentPayload() throws SvcLogicException {
55         SvcLogicContext ctx = new SvcLogicContext();
56         HashMap<String, String> testMap = new HashMap<String, String>();
57         CompareNode cmp = new CompareNode();
58         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}";
59         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}";
60         testMap.put("compareDataType", "RestConf");
61         testMap.put("sourceData", controlJson);
62         testMap.put("targetData", testJson);
63         cmp.compare(testMap, ctx);
64         assert (ctx.getAttribute("STATUS").equals("FAILURE"));
65     }
66 }