bd28ef7a3e611c84fba641134c1c19edb25a6469
[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  * 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
14  * 
15  *      http://www.apache.org/licenses/LICENSE-2.0
16  * 
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.
22  * 
23  * ============LICENSE_END=========================================================
24  */
25
26 package org.onap.sdnc.config.audit.node;
27
28 import java.util.HashMap;
29
30 import org.junit.Test;
31 import org.onap.sdnc.config.audit.node.CompareNode;
32 import org.slf4j.Logger;
33 import org.slf4j.LoggerFactory;
34
35 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
36 import org.onap.ccsdk.sli.core.sli.SvcLogicException;
37 import static org.junit.Assert.assertEquals;
38
39 public class TestCompareNodeCli {
40     private static final Logger log = LoggerFactory.getLogger(TestCompareNodeCli.class);
41
42     @Test
43     public void TestCompareCliForSamePayload() throws SvcLogicException {
44         SvcLogicContext ctx = new SvcLogicContext();
45         HashMap<String, String> testMap = new HashMap<String, String>();
46         CompareNode cmp = new CompareNode();
47         testMap.put("compareDataType", "Cli");
48         testMap.put("sourceData", "This is a Text Configuration of Device");
49         testMap.put("targetData", "This is a Text Configuration of Device");
50         cmp.compare(testMap, ctx);
51         assert (ctx.getAttribute("STATUS").equals("SUCCESS"));
52     }
53     
54     @Test
55     public void TestCompareCliForNoPayload() throws SvcLogicException {
56         SvcLogicContext ctx = new SvcLogicContext();
57         HashMap<String, String> testMap = new HashMap<String, String>();
58         CompareNode cmp = new CompareNode();
59         testMap.put("compareDataType", "Cli");
60         cmp.compare(testMap, ctx);
61         assertEquals ("FAILURE",ctx.getAttribute("STATUS"));
62     }
63
64     @Test
65     public void TestCompareCliFordifferentPayload() throws SvcLogicException {
66         SvcLogicContext ctx = new SvcLogicContext();
67         HashMap<String, String> testMap = new HashMap<String, String>();
68         CompareNode cmp = new CompareNode();
69         testMap.put("compareDataType", "Cli");
70         testMap.put("sourceData", "This is a Text Negative test Configuration of Device");
71         testMap.put("targetData", "This is a Text Configuration of Device");
72         cmp.compare(testMap, ctx);
73         assert (ctx.getAttribute("STATUS").equals("FAILURE"));
74     }
75
76     @Test
77     public void TestCompareForMissingInput() throws SvcLogicException {
78         SvcLogicContext ctx = new SvcLogicContext();
79         HashMap<String, String> testMap = new HashMap<String, String>();
80         CompareNode cmp = new CompareNode();
81         testMap.put("sourceData", "This is a Text Negative test Configuration of Device");
82         testMap.put("targetData.configuration-data", "This is a Text Configuration of Device");
83         cmp.compare(testMap, ctx);
84         assert (ctx.getAttribute("STATUS").equals("FAILURE"));
85     }
86
87 }