a80d68a6964ff2a0ed601267faec7834b95cd1d1
[oam.git] / features / devicemanager / x-ran / ru-fh / provider / src / test / java / org / onap / ccsdk / features / sdnr / wt / devicemanager / xran / TestXRanToInternalDataModel.java
1 /*
2  * ============LICENSE_START========================================================================
3  * ONAP : ccsdk feature sdnr wt
4  * =================================================================================================
5  * Copyright (C) 2020 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.xran;
19
20 import static org.junit.Assert.assertEquals;
21 import static org.mockito.Mockito.mock;
22 import static org.mockito.Mockito.when;
23
24 import java.util.List;
25 import java.io.IOException;
26 import java.util.ArrayList;
27
28 import org.junit.After;
29 import org.junit.Before;
30 import org.junit.Test;
31 import org.mockito.Mockito;
32 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana.hardware.rev180313.HardwareClass;
33 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.hardware.rev180313.hardware.Component;
34 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime;
35 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid;
36 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
37 import org.oransc.oam.features.devicemanager.xran.impl.XRanToInternalDataModel;
38 import org.onap.ccsdk.features.sdnr.wt.devicemanager.xran.TestHardwareClass;
39
40 public class TestXRanToInternalDataModel {
41
42     NodeId nodeId;
43     Component component;
44
45     @Before
46     public void init() throws InterruptedException, IOException {
47         nodeId = mock(NodeId.class);
48         component = mock(Component.class);
49
50         when(nodeId.getValue()).thenReturn("ORan-1000");
51         when(component.getParent()).thenReturn("Shelf");
52         when(component.getParentRelPos()).thenReturn(0);
53         when(component.getUuid()).thenReturn(new Uuid("0Aabcdef-0abc-0cfD-0abC-0123456789AB"));
54
55         List<String> list = new ArrayList<>();
56         list.add("Card-01A");
57         list.add("Card-01B");
58
59         when (component.getContainsChild()).thenReturn(list);
60         when (component.getName()).thenReturn("Nokia");
61         when (component.getDescription()).thenReturn("ORAN Network Element NO-456");
62         Class<? extends HardwareClass> hwClass = TestHardwareClass.class;
63         Mockito.<Class<? extends HardwareClass>>when(component.getXmlClass()).thenReturn(hwClass);
64
65         DateAndTime dt = new DateAndTime("2020-02-05T12:30:45.283Z");
66         when (component.getMfgDate()).thenReturn(dt);
67
68     }
69
70     @Test
71     public void test() throws Exception {
72         XRanToInternalDataModel model = new XRanToInternalDataModel();
73         model.getInternalEquipment(nodeId, component);
74         assertEquals(component.getUuid().getValue(), "0Aabcdef-0abc-0cfD-0abC-0123456789AB");
75         assertEquals(component.getMfgDate().getValue(), "2020-02-05T12:30:45.283Z");
76
77     }
78
79     @After
80     public void cleanUp() throws Exception {
81
82     }
83 }