2 * ============LICENSE_START=======================================================
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
13 * http://www.apache.org/licenses/LICENSE-2.0
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.
21 * ============LICENSE_END=========================================================
24 package org.onap.sdnc.config.audit.node;
26 import java.util.HashMap;
28 import org.junit.Test;
29 import org.onap.sdnc.config.audit.node.CompareNode;
30 import org.slf4j.Logger;
31 import org.slf4j.LoggerFactory;
33 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
34 import org.onap.ccsdk.sli.core.sli.SvcLogicException;
36 public class TestCompareNodeJson {
37 private static final Logger log = LoggerFactory.getLogger(TestCompareNodeJson.class);
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"));
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"));