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
10 * http://www.apache.org/licenses/LICENSE-2.0
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
16 * ============LICENSE_END==========================================================================
18 package org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14;
20 import static org.junit.Assert.assertEquals;
21 import java.util.HashMap;
23 import org.eclipse.jdt.annotation.NonNull;
24 import org.junit.BeforeClass;
25 import org.junit.Test;
26 import org.mockito.Mockito;
27 import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.impl.dataprovider.Onf14ToInternalDataModel;
28 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime;
29 import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.Equipment;
30 import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.UniversalId;
31 import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.equipment.ActualEquipment;
32 import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.equipment.ContainedHolder;
33 import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.equipment.ContainedHolderKey;
34 import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.equipment.detail.ManufacturedThing;
35 import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.manufactured.thing.EquipmentInstance;
36 import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.manufactured.thing.EquipmentType;
37 import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.manufactured.thing.ManufacturerProperties;
38 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
40 public class TestOnf14ToInternalDataModel2 extends Mockito {
42 private static NodeId nodeId;
43 private static Equipment currentEq;
44 private static Equipment parentEq;
45 private static ActualEquipment component;
46 private static ContainedHolder holder;
47 private static ManufacturedThing manThing;
48 private static ManufacturerProperties manProperties;
49 private static EquipmentInstance eqInstance;
50 private static EquipmentType eqType;
53 public static void init() {
54 nodeId = mock(NodeId.class);
55 currentEq = mock(Equipment.class);
56 parentEq = mock(Equipment.class);
57 component = mock(ActualEquipment.class);
58 holder = mock(ContainedHolder.class);
59 manThing = mock(ManufacturedThing.class);
60 manProperties = mock(ManufacturerProperties.class);
61 eqInstance = mock(EquipmentInstance.class);
62 eqType = mock(EquipmentType.class);
64 when(nodeId.getValue()).thenReturn("CoreModel-1-4-node");
66 when(component.getLocalId()).thenReturn("actLocalEq");
67 when(currentEq.getUuid()).thenReturn(new UniversalId("0Aabcdef-0abc-0cfD-0abC-0123456789AB"));
68 when(parentEq.getUuid()).thenReturn(new UniversalId("0Aabcdef-0123-0abc-abcd-0123456789AB"));
70 @NonNull Map<ContainedHolderKey, ContainedHolder> containedHolderList = new HashMap<>();
71 containedHolderList.put(holder.key(),holder);
72 when(currentEq.nonnullContainedHolder()).thenReturn(containedHolderList);
79 Onf14ToInternalDataModel model = new Onf14ToInternalDataModel();
81 when(currentEq.getActualEquipment()).thenReturn(component);
82 when(holder.getOccupyingFru()).thenReturn(new UniversalId("12345678-0123-0abc-abcd-0123456789AB"));
83 when(component.getManufacturedThing()).thenReturn(manThing);
84 when(manThing.getManufacturerProperties()).thenReturn(manProperties);
85 when(manThing.getEquipmentInstance()).thenReturn(eqInstance);
86 when(eqInstance.getManufactureDate()).thenReturn(new DateAndTime("2020-02-05T12:30:45.283Z"));
87 when(manThing.getEquipmentType()).thenReturn(eqType);
89 model.getInternalEquipment(nodeId, currentEq, parentEq, 0);
90 assertEquals(currentEq.getActualEquipment().getLocalId(), "actLocalEq");
96 Onf14ToInternalDataModel model = new Onf14ToInternalDataModel();
98 when(holder.getOccupyingFru()).thenReturn(null);
99 when(component.getManufacturedThing()).thenReturn(null);
100 when(manThing.getManufacturerProperties()).thenReturn(null);
101 when(manThing.getEquipmentInstance()).thenReturn(null);
102 when(manThing.getEquipmentType()).thenReturn(null);
104 model.getInternalEquipment(nodeId, currentEq, null, 0);
109 public void test3() {
110 Onf14ToInternalDataModel model = new Onf14ToInternalDataModel();
112 when(component.getManufacturedThing()).thenReturn(manThing);
113 when(manThing.getManufacturerProperties()).thenReturn(null);
114 when(manThing.getEquipmentInstance()).thenReturn(null);
115 when(manThing.getEquipmentType()).thenReturn(null);
117 model.getInternalEquipment(nodeId, currentEq, null, 0);
121 public void test4() {
122 Onf14ToInternalDataModel model = new Onf14ToInternalDataModel();
124 when(currentEq.getActualEquipment()).thenReturn(null);
125 model.getInternalEquipment(nodeId, currentEq, null, 0);