8b4bb64b8da4a6bf5a0514c47256e5c469a5a6ce
[appc.git] /
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP : APPC
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Copyright (C) 2017 Amdocs
8  * =============================================================================
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  * 
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  * 
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  * 
21  * ECOMP is a trademark and service mark of AT&T Intellectual Property.
22  * ============LICENSE_END=========================================================
23  */
24
25 package org.onap.sdnc.config.audit.node;
26
27 import java.util.HashMap;
28
29 import org.junit.Test;
30 import org.onap.sdnc.config.audit.node.CompareNode;
31 import org.slf4j.Logger;
32 import org.slf4j.LoggerFactory;
33
34 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
35 import org.onap.ccsdk.sli.core.sli.SvcLogicException;
36
37 public class TestCompareNodeCli {
38     private static final Logger log = LoggerFactory.getLogger(TestCompareNodeCli.class);
39
40     @Test
41     public void TestCompareCliForSamePayload() throws SvcLogicException {
42         SvcLogicContext ctx = new SvcLogicContext();
43         HashMap<String, String> testMap = new HashMap<String, String>();
44         CompareNode cmp = new CompareNode();
45         testMap.put("compareDataType", "Cli");
46         testMap.put("sourceData", "This is a Text Configuration of Device");
47         testMap.put("targetData", "This is a Text Configuration of Device");
48         cmp.compare(testMap, ctx);
49         assert (ctx.getAttribute("STATUS").equals("SUCCESS"));
50     }
51
52     @Test
53     public void TestCompareCliFordifferentPayload() throws SvcLogicException {
54         SvcLogicContext ctx = new SvcLogicContext();
55         HashMap<String, String> testMap = new HashMap<String, String>();
56         CompareNode cmp = new CompareNode();
57         testMap.put("compareDataType", "Cli");
58         testMap.put("sourceData", "This is a Text Negative test Configuration of Device");
59         testMap.put("targetData", "This is a Text Configuration of Device");
60         cmp.compare(testMap, ctx);
61         assert (ctx.getAttribute("STATUS").equals("FAILURE"));
62     }
63
64     @Test
65     public void TestCompareForMissingInput() throws SvcLogicException {
66         SvcLogicContext ctx = new SvcLogicContext();
67         HashMap<String, String> testMap = new HashMap<String, String>();
68         CompareNode cmp = new CompareNode();
69         testMap.put("sourceData", "This is a Text Negative test Configuration of Device");
70         testMap.put("targetData.configuration-data", "This is a Text Configuration of Device");
71         cmp.compare(testMap, ctx);
72         assert (ctx.getAttribute("STATUS").equals("FAILURE"));
73     }
74
75 }