Change to CCSDK and ODL Carbon
[appc.git] / appc-config / appc-config-audit / provider / src / test / java / org / openecomp / sdnc / config / audit / node / TestCompareNodeCli.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP : APP-C
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
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
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=========================================================
19  */
20
21 package org.openecomp.sdnc.config.audit.node;
22
23 import java.util.HashMap;
24
25 import org.junit.Test;
26 import org.openecomp.sdnc.config.audit.node.CompareNode;
27 import org.slf4j.Logger;
28 import org.slf4j.LoggerFactory;
29
30 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
31 import org.onap.ccsdk.sli.core.sli.SvcLogicException;
32
33 public class TestCompareNodeCli {
34     private static final Logger log = LoggerFactory.getLogger(TestCompareNodeCli.class);
35
36     @Test
37     public void TestCompareCliForSamePayload() throws SvcLogicException {
38         SvcLogicContext ctx = new SvcLogicContext();
39         HashMap<String, String> testMap = new HashMap<String, String>();
40         CompareNode cmp = new CompareNode();
41         testMap.put("compareDataType", "Cli");
42         testMap.put("sourceData", "This is a Text Configuration of Device");
43         testMap.put("targetData", "This is a Text Configuration of Device");
44         cmp.compare(testMap, ctx);
45         assert (ctx.getAttribute("STATUS").equals("SUCCESS"));
46     }
47
48     @Test
49     public void TestCompareCliFordifferentPayload() throws SvcLogicException {
50         SvcLogicContext ctx = new SvcLogicContext();
51         HashMap<String, String> testMap = new HashMap<String, String>();
52         CompareNode cmp = new CompareNode();
53         testMap.put("compareDataType", "Cli");
54         testMap.put("sourceData", "This is a Text Negative test Configuration of Device");
55         testMap.put("targetData", "This is a Text Configuration of Device");
56         cmp.compare(testMap, ctx);
57         assert (ctx.getAttribute("STATUS").equals("FAILURE"));
58     }
59
60     @Test
61     public void TestCompareForMissingInput() throws SvcLogicException {
62         SvcLogicContext ctx = new SvcLogicContext();
63         HashMap<String, String> testMap = new HashMap<String, String>();
64         CompareNode cmp = new CompareNode();
65         testMap.put("sourceData", "This is a Text Negative test Configuration of Device");
66         testMap.put("targetData.configuration-data", "This is a Text Configuration of Device");
67         cmp.compare(testMap, ctx);
68         assert (ctx.getAttribute("STATUS").equals("FAILURE"));
69     }
70 }