2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.onap.so.adapters.sdnc.impl;
23 import static org.junit.Assert.assertEquals;
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;
33 public class UtilsTest {
36 public final void testUnmarshal () {
38 String expectedXml = "<?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>";
42 File file = new File("src/test/resources/sdncBpmnAdiodFirewallRequest.xml");
43 JAXBContext jaxbContext = JAXBContext.newInstance(SDNCAdapterRequest.class);
45 Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
46 SDNCAdapterRequest request = (SDNCAdapterRequest) jaxbUnmarshaller.unmarshal(file);
48 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/",
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);
58 } catch (JAXBException e) {