Update license header in appc-config files
[appc.git] / appc-config / appc-config-audit / provider / src / test / java / org / onap / sdnc / config / audit / node / TestCompareNodeXml.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  * 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.io.IOException;
27 import java.util.HashMap;
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 TestCompareNodeXml {
37     private static final Logger log = LoggerFactory.getLogger(TestCompareNodeXml.class);
38
39     @Test
40     public void TestCompareExtactXML() throws SvcLogicException {
41         log.debug("TestCompareNode.TestCompareExtactXML()");
42         SvcLogicContext ctx = new SvcLogicContext();
43         HashMap<String, String> testMap = new HashMap<String, String>();
44         CompareNode cmp = new CompareNode();
45         String s = "<configuration xmlns=\"http://xml.juniper.net/xnm/1.1/xnm\" junos:commit-seconds=\"1502141521\" junos:commit-localtime=\"2017-08-07 21:32:03 UTC\" junos:commit-user=\"root\"> </configuration>";
46         String t = "<configuration xmlns=\"http://xml.juniper.net/xnm/1.1/xnm\"  junos:commit-localtime=\"2017-08-07 21:12:03 UTC\" junos:commit-seconds=\"15021523\" junos:commit-user=\"root\"> </configuration>";
47         testMap.put("compareDataType", "RESTCONF-XML");
48         testMap.put("requestIdentifier", "123");
49         testMap.put("sourceData", s);
50         testMap.put("targetData", t);
51         cmp.compare(testMap, ctx);
52         assert (ctx.getAttribute("123." + "STATUS").equals("SUCCESS"));
53     }
54
55     @Test
56     public void TestCompareforAttributeOrder() throws IOException, SvcLogicException {
57         log.debug("TestCompareNode.TestCompareforAttributeOrder()");
58         SvcLogicContext ctx = new SvcLogicContext();
59         HashMap<String, String> testMap = new HashMap<String, String>();
60         CompareNode cmp = new CompareNode();
61         testMap.put("compareDataType", "XML");
62         testMap.put("sourceData",
63                 "<SipIfTermination><id>2</id><udpPortInUse>true</udpPortInUse><udpPort>5060</udpPort><tcpPortInUse>true</tcpPortInUse><tcpPort>5060</tcpPort></SipIfTermination>");
64         testMap.put("targetData",
65                 "<SipIfTermination><udpPortInUse>true</udpPortInUse><udpPort>5060</udpPort><tcpPortInUse>true</tcpPortInUse><tcpPort>5060</tcpPort><id>2</id></SipIfTermination>");
66         cmp.compare(testMap, ctx);
67         assert (ctx.getAttribute("STATUS").equals("SUCCESS"));
68     }
69
70     @Test
71     public void TestCompareForComments() throws SvcLogicException {
72         log.debug("TestCompareNode.TestCompareForComments()");
73         SvcLogicContext ctx = new SvcLogicContext();
74         HashMap<String, String> testMap = new HashMap<String, String>();
75         CompareNode cmp = new CompareNode();
76         testMap.put("compareDataType", "XML");
77         testMap.put("sourceData", "<SipIfTermination><id>2</id><!--this is a commnect --></SipIfTermination>");
78         testMap.put("targetData", "<SipIfTermination><id>2</id></SipIfTermination>");
79         cmp.compare(testMap, ctx);
80         assert (ctx.getAttribute("STATUS").equals("SUCCESS"));
81     }
82
83 }