2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.openecomp.sdnc.config.audit.node;
23 import java.util.HashMap;
25 import org.junit.Test;
26 import org.openecomp.sdnc.config.audit.node.CompareNode;
27 import org.slf4j.Logger;
28 import org.slf4j.LoggerFactory;
30 import org.openecomp.sdnc.sli.SvcLogicContext;
31 import org.openecomp.sdnc.sli.SvcLogicException;
33 public class TestCompareNodeJson
35 private static final Logger log = LoggerFactory.getLogger(TestCompareNodeJson.class);
38 public void TestCompareJsonForSamePayload()
40 SvcLogicContext ctx = new SvcLogicContext();
41 HashMap<String, String> testMap = new HashMap<String, String>();
42 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"));
53 catch (SvcLogicException e)
60 public void TestCompareJsonFordifferentPayload()
62 SvcLogicContext ctx = new SvcLogicContext();
63 HashMap<String, String> testMap = new HashMap<String, String>();
64 CompareNode cmp = new CompareNode();
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"));
75 catch (SvcLogicException e)