0909829569c08c56e82fd70a441ffca3578eea6b
[ccsdk/features.git] /
1 /*
2  * ============LICENSE_START========================================================================
3  * ONAP : ccsdk feature sdnr wt
4  * =================================================================================================
5  * Copyright (C) 2022 highstreet technologies GmbH Intellectual Property. All rights reserved.
6  * =================================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
8  * in compliance with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software distributed under the License
13  * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
14  * or implied. See the License for the specific language governing permissions and limitations under
15  * the License.
16  * ============LICENSE_END==========================================================================
17  */
18 package org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom;
19
20 import static org.junit.Assert.assertEquals;
21 import java.io.IOException;
22 import java.net.URISyntaxException;
23 import java.util.ArrayList;
24 import java.util.Collection;
25 import java.util.List;
26 import javax.xml.stream.XMLStreamException;
27 import org.junit.After;
28 import org.junit.BeforeClass;
29 import org.junit.Test;
30 import org.mockito.Mockito;
31 import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.dataprovider.Onf14DomToInternalDataModel;
32 import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.util.Onf14DevicemanagerQNames;
33 import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.util.Onf14DomTestUtils;
34 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.Inventory;
35 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
36 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
37 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
38 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
39 import org.opendaylight.yangtools.yang.data.api.schema.MapNode;
40 import org.xml.sax.SAXException;
41
42 public class TestOnf14ToInternalDataModel2 extends Mockito {
43
44     private static NodeId nodeId;
45
46     @BeforeClass
47     public static void init() {
48         nodeId = mock(NodeId.class);
49     }
50
51     @After
52     public void cleanUp() {
53         Onf14DomTestUtils.cleanup();
54     }
55
56     @Test
57     public void testWithNormalizedNodeFromJson() throws IOException, URISyntaxException {
58
59         Onf14DomToInternalDataModel model = new Onf14DomToInternalDataModel();
60
61         ContainerNode cn = (ContainerNode) Onf14DomTestUtils.getNormalizedNodeFromJson();
62         MapNode equipmentMap =
63                 (MapNode) cn.getChildByArg(new NodeIdentifier(Onf14DevicemanagerQNames.CORE_MODEL_CC_EQPT));
64         List<Inventory> inventoryList = new ArrayList<Inventory>();
65
66         Collection<MapEntryNode> containerMapEntries = equipmentMap.body();
67         for (MapEntryNode mapEntryNode : containerMapEntries) {
68             inventoryList.add(model.getInternalEquipment(new NodeId("nSky"), mapEntryNode, null, 0));
69         }
70         assertEquals("All elements", 1, inventoryList.size());
71
72     }
73
74     @Test
75     public void testWithNormalizedNodeFromXML()
76             throws IOException, URISyntaxException, XMLStreamException, SAXException {
77
78         Onf14DomToInternalDataModel model = new Onf14DomToInternalDataModel();
79
80         ContainerNode cn = (ContainerNode) Onf14DomTestUtils.getNormalizedNodeFromXML();
81         MapNode equipmentMap =
82                 (MapNode) cn.getChildByArg(new NodeIdentifier(Onf14DevicemanagerQNames.CORE_MODEL_CC_EQPT));
83         List<Inventory> inventoryList = new ArrayList<Inventory>();
84
85         Collection<MapEntryNode> containerMapEntries = equipmentMap.body();
86         for (MapEntryNode mapEntryNode : containerMapEntries) {
87             inventoryList.add(model.getInternalEquipment(new NodeId("nSky"), mapEntryNode, null, 0));
88         }
89         assertEquals("All elements", 1, inventoryList.size());
90
91     }
92
93 }