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.ArrayList;
22 import java.util.List;
23 import org.junit.BeforeClass;
24 import org.junit.Test;
25 import org.mockito.Mockito;
26 import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.impl.Onf14ToInternalDataModel;
27 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime;
28 import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.Equipment;
29 import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.UniversalId;
30 import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.equipment.ActualEquipment;
31 import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.equipment.ContainedHolder;
32 import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.equipment.detail.ManufacturedThing;
33 import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.manufactured.thing.EquipmentInstance;
34 import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.manufactured.thing.EquipmentType;
35 import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.manufactured.thing.ManufacturerProperties;
36 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
38 public class TestOnf14ToInternalDataModel2 extends Mockito {
40 private static NodeId nodeId;
41 private static Equipment currentEq;
42 private static Equipment parentEq;
43 private static ActualEquipment component;
44 private static ContainedHolder holder;
45 private static ManufacturedThing manThing;
46 private static ManufacturerProperties manProperties;
47 private static EquipmentInstance eqInstance;
48 private static EquipmentType eqType;
51 public static void init() {
52 nodeId = mock(NodeId.class);
53 currentEq = mock(Equipment.class);
54 parentEq = mock(Equipment.class);
55 component = mock(ActualEquipment.class);
56 holder = mock(ContainedHolder.class);
57 manThing = mock(ManufacturedThing.class);
58 manProperties = mock(ManufacturerProperties.class);
59 eqInstance = mock(EquipmentInstance.class);
60 eqType = mock(EquipmentType.class);
62 when(nodeId.getValue()).thenReturn("CoreModel-1-4-node");
64 when(component.getLocalId()).thenReturn("actLocalEq");
65 when(currentEq.getUuid()).thenReturn(new UniversalId("0Aabcdef-0abc-0cfD-0abC-0123456789AB"));
66 when(parentEq.getUuid()).thenReturn(new UniversalId("0Aabcdef-0123-0abc-abcd-0123456789AB"));
68 List<ContainedHolder> containedHolderList = new ArrayList<ContainedHolder>();
69 containedHolderList.add(holder);
70 when(currentEq.nonnullContainedHolder()).thenReturn(containedHolderList);
77 Onf14ToInternalDataModel model = new Onf14ToInternalDataModel();
79 when(currentEq.getActualEquipment()).thenReturn(component);
80 when(holder.getOccupyingFru()).thenReturn(new UniversalId("12345678-0123-0abc-abcd-0123456789AB"));
81 when(component.getManufacturedThing()).thenReturn(manThing);
82 when(manThing.getManufacturerProperties()).thenReturn(manProperties);
83 when(manThing.getEquipmentInstance()).thenReturn(eqInstance);
84 when(eqInstance.getManufactureDate()).thenReturn(new DateAndTime("2020-02-05T12:30:45.283Z"));
85 when(manThing.getEquipmentType()).thenReturn(eqType);
87 model.getInternalEquipment(nodeId, currentEq, parentEq, 0);
88 assertEquals(currentEq.getActualEquipment().getLocalId(), "actLocalEq");
94 Onf14ToInternalDataModel model = new Onf14ToInternalDataModel();
96 when(holder.getOccupyingFru()).thenReturn(null);
97 when(component.getManufacturedThing()).thenReturn(null);
98 when(manThing.getManufacturerProperties()).thenReturn(null);
99 when(manThing.getEquipmentInstance()).thenReturn(null);
100 when(manThing.getEquipmentType()).thenReturn(null);
102 model.getInternalEquipment(nodeId, currentEq, null, 0);
107 public void test3() {
108 Onf14ToInternalDataModel model = new Onf14ToInternalDataModel();
110 when(component.getManufacturedThing()).thenReturn(manThing);
111 when(manThing.getManufacturerProperties()).thenReturn(null);
112 when(manThing.getEquipmentInstance()).thenReturn(null);
113 when(manThing.getEquipmentType()).thenReturn(null);
115 model.getInternalEquipment(nodeId, currentEq, null, 0);
119 public void test4() {
120 Onf14ToInternalDataModel model = new Onf14ToInternalDataModel();
122 when(currentEq.getActualEquipment()).thenReturn(null);
123 model.getInternalEquipment(nodeId, currentEq, null, 0);