2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Copyright (C) 2017 Amdocs
8 * =============================================================================
9 * Modifications Copyright (C) 2018 IBM
10 * =============================================================================
11 * Licensed under the Apache License, Version 2.0 (the "License");
12 * you may not use this file except in compliance with the License.
13 * You may obtain a copy of the License at
15 * http://www.apache.org/licenses/LICENSE-2.0
17 * Unless required by applicable law or agreed to in writing, software
18 * distributed under the License is distributed on an "AS IS" BASIS,
19 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20 * See the License for the specific language governing permissions and
21 * limitations under the License.
23 * ============LICENSE_END=========================================================
26 package org.onap.sdnc.config.audit.node;
28 import java.util.HashMap;
30 import org.junit.Before;
31 import org.junit.Test;
32 import org.onap.sdnc.config.audit.node.CompareNode;
33 import org.slf4j.Logger;
34 import org.slf4j.LoggerFactory;
36 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
37 import org.onap.ccsdk.sli.core.sli.SvcLogicException;
38 import static org.junit.Assert.assertEquals;
39 import static org.junit.Assert.assertNotNull;
41 public class TestCompareNodeCli {
42 private static final Logger log = LoggerFactory.getLogger(TestCompareNodeCli.class);
43 private CompareNode cmp;
45 HashMap<String, String> testMap;
51 cmp = new CompareNode();
52 ctx = new SvcLogicContext();
53 testMap = new HashMap<String, String>();
57 public void TestCompareCliForSamePayload() throws SvcLogicException {
58 testMap.put("compareDataType", "Cli");
59 testMap.put("sourceData", "This is a Text Configuration of Device");
60 testMap.put("targetData", "This is a Text Configuration of Device");
61 cmp.compare(testMap, ctx);
62 assert (ctx.getAttribute("STATUS").equals("SUCCESS"));
63 assertNotNull(testMap);
67 public void TestCompareCliForNoPayload() throws SvcLogicException {
68 testMap.put("compareDataType", "Cli");
69 cmp.compare(testMap, ctx);
70 assertEquals ("FAILURE",ctx.getAttribute("STATUS"));
74 public void TestCompareCliFordifferentPayload() throws SvcLogicException {
75 testMap.put("compareDataType", "Cli");
76 testMap.put("sourceData", "This is a Text Negative test Configuration of Device");
77 testMap.put("targetData", "This is a Text Configuration of Device");
78 cmp.compare(testMap, ctx);
79 assert (ctx.getAttribute("STATUS").equals("FAILURE"));
80 assertNotNull(testMap);
84 public void TestCompareForMissingInput() throws SvcLogicException {
85 testMap.put("sourceData", "This is a Text Negative test Configuration of Device");
86 testMap.put("targetData.configuration-data", "This is a Text Configuration of Device");
87 cmp.compare(testMap, ctx);
88 assert (ctx.getAttribute("STATUS").equals("FAILURE"));
89 assertNotNull(testMap);