Replaced all tabs with spaces in java and pom.xml
[so.git] / adapters / mso-sdnc-adapter / src / test / java / org / onap / so / adapters / sdnc / impl / UtilsTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
4  * ================================================================================
5  * Copyright (C) 2017 - 2018 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.onap.so.adapters.sdnc.impl;
22
23 import static org.junit.Assert.assertEquals;
24 import java.io.File;
25 import javax.xml.bind.JAXBContext;
26 import javax.xml.bind.JAXBException;
27 import javax.xml.bind.Unmarshaller;
28 import org.junit.Test;
29 import org.onap.so.adapters.sdnc.SDNCAdapterRequest;
30 import org.w3c.dom.Document;
31 import org.w3c.dom.Node;
32
33 public class UtilsTest {
34
35     @Test
36     public final void testUnmarshal() {
37
38         String expectedXml =
39                 "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?><feature-list xmlns=\"com:att:sdnctl:l3api\"><feature-type>FIREWALL-LITE</feature-type><feature-instance-id>mtjnj40evbc0eceb</feature-instance-id><feature-sub-type>SHARED</feature-sub-type><feature-instance-xpath>/restconf/config/Firewall-API:feature-model/feature-list/FIREWALL-LITE/mtjnj40evbc0eceb/</feature-instance-xpath>      </feature-list>";
40
41         try {
42
43             File file = new File("src/test/resources/sdncBpmnAdiodFirewallRequest.xml");
44             JAXBContext jaxbContext = JAXBContext.newInstance(SDNCAdapterRequest.class);
45
46             Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
47             SDNCAdapterRequest request = (SDNCAdapterRequest) jaxbUnmarshaller.unmarshal(file);
48
49             RequestTunables rt = new RequestTunables("0460ba40-60c8-4b07-8878-c8e8d87cde04-1527983610512", "",
50                     "/L3SDN-API:services/layer3-service-list/MIS%2F1806%2F25057%2FSW_INTERNET/service-data/feature-list/FIREWALL-LITE/",
51                     "put");
52
53             Node node = (Node) request.getRequestData();
54             Document reqDoc = node.getOwnerDocument();
55             String sdncReqBody = Utils.genSdncPutReq(reqDoc, rt);
56             assertEquals(sdncReqBody.replaceAll("[\\t\\n\\r]+", ""), expectedXml);
57
58         } catch (JAXBException e) {
59             e.printStackTrace();
60         }
61
62     }
63
64 }