ad1112ffc4d9480b78e8648ccba4192207556e2f
[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.openecomp.sdnc.sli.SvcLogicContext;
31 import org.openecomp.sdnc.sli.SvcLogicException;
32
33 public class TestCompareNodeCli
34 {
35 private static final Logger log = LoggerFactory.getLogger(TestCompareNodeCli.class);
36     
37
38 //@Test
39     public void TestCompareCliForSamePayload()
40     {
41         SvcLogicContext ctx  = new SvcLogicContext();
42         HashMap<String, String> testMap = new HashMap<String, String>();        
43         CompareNode cmp  = new CompareNode();
44         try
45         {
46             testMap.put("compareDataType", "Cli");
47             testMap.put("sourceData", "This is a Text Configuration of Device");
48             testMap.put("targetData", "This is a Text Configuration of Device");            
49             cmp.compare(testMap, ctx);            
50             assert(ctx.getAttribute("STATUS").equals("SUCCESS"));            
51         }
52         catch (SvcLogicException e)
53         {
54             // TODO Auto-generated catch block
55             e.printStackTrace();
56         }        
57     }
58
59     //@Test
60     public void TestCompareCliFordifferentPayload()
61     {
62         SvcLogicContext ctx  = new SvcLogicContext();
63         HashMap<String, String> testMap = new HashMap<String, String>();        
64         CompareNode cmp  = new CompareNode();
65         try
66         {
67             testMap.put("compareDataType", "Cli");
68             testMap.put("sourceData", "This is a Text Negative test Configuration of Device");
69             testMap.put("targetData", "This is a Text Configuration of Device");            
70             cmp.compare(testMap, ctx);            
71             assert(ctx.getAttribute("STATUS").equals("FAILURE"));            
72         }
73         catch (SvcLogicException e)
74         {
75             // TODO Auto-generated catch block
76             e.printStackTrace();
77         }        
78     }
79     
80     //@Test
81     public void TestCompareForMissingInput()
82     {
83         SvcLogicContext ctx  = new SvcLogicContext();
84         HashMap<String, String> testMap = new HashMap<String, String>();        
85         CompareNode cmp  = new CompareNode();
86         try
87         {
88         //    testMap.put("compareDataType", "Cli"); Missing compareDataType from the input            
89             testMap.put("sourceData", "This is a Text Negative test Configuration of Device");
90             testMap.put("targetData.configuration-data", "This is a Text Configuration of Device");    
91             cmp.compare(testMap, ctx);            
92             assert(ctx.getAttribute("STATUS").equals("FAILURE"));            
93         }
94         catch (SvcLogicException e)
95         {
96             assert(ctx.getAttribute("STATUS").equals("FAILURE"));
97         }        
98     }
99     
100 }