Changed to unmaintained
[appc.git] / appc-config / appc-config-audit / provider / src / test / java / org / onap / sdnc / config / audit / node / TestCompareNodeCli.java
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.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;
35
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;
40
41 public class TestCompareNodeCli {
42     private static final Logger log = LoggerFactory.getLogger(TestCompareNodeCli.class);
43     private CompareNode cmp;
44     SvcLogicContext ctx;
45     HashMap<String, String> testMap;
46         
47     
48     @Before
49     public void setUp()
50     {
51         cmp = new CompareNode();
52         ctx = new SvcLogicContext();
53         testMap = new HashMap<String, String>();
54     }
55     
56     @Test
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);
64     }
65     
66     @Test
67     public void TestCompareCliForNoPayload() throws SvcLogicException {
68         testMap.put("compareDataType", "Cli");
69         cmp.compare(testMap, ctx);
70         assertEquals ("FAILURE",ctx.getAttribute("STATUS"));
71     }
72
73     @Test
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);
81     }
82
83     @Test
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);
90     }
91
92 }