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