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