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
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==========================================================================
17 ******************************************************************************/
18 package org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.test;
20 import static org.junit.Assert.assertEquals;
21 import static org.junit.Assert.assertTrue;
22 import static org.mockito.Mockito.mock;
23 import static org.mockito.Mockito.when;
24 import static org.mockito.Mockito.*;
26 import java.util.List;
27 import java.util.Optional;
28 import java.io.IOException;
29 import java.util.Date;
31 import org.junit.After;
32 import org.junit.BeforeClass;
33 import org.junit.Test;
34 import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider;
35 import org.onap.ccsdk.features.sdnr.wt.devicemanager.ne.service.NetworkElement;
36 import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.impl.ORanNetworkElementFactory;
37 import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.test.mock.TransactionUtilsMock;
38 import org.opendaylight.yang.gen.v1.urn.o.ran.hardware._1._0.rev190328.ORANHWCOMPONENT;
39 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.network.topology.simulator.rev191025.SimulatorStatus;
40 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ConnectionlogEntity;
41 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.EventlogEntity;
42 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.FaultcurrentEntity;
43 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.FaultlogEntity;
44 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.Inventory;
45 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.NetworkElementConnectionEntity;
46 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.PmdataEntity;
47 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
48 import org.opendaylight.yangtools.yang.common.QName;
49 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider;
50 import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.test.mock.NetconfAccessorMock;
51 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.Capabilities;
53 public class TestORanNetworkElement {
55 static NetconfAccessorMock accessor;
56 static DeviceManagerServiceProvider serviceProvider;
57 static Capabilities capabilities;
60 @SuppressWarnings("unchecked")
62 public static void init() throws InterruptedException, IOException {
63 capabilities = mock(Capabilities.class);
64 //accessor = mock(NetconfAccessorMock.class);
65 accessor = spy(new NetconfAccessorMock(null, null, null, null));
66 serviceProvider = mock(DeviceManagerServiceProvider.class);
68 NodeId nNodeId = new NodeId("nSky");
69 when(accessor.getCapabilites()).thenReturn(capabilities);
70 when (accessor.getNodeId()).thenReturn(nNodeId);
71 when (accessor.getTransactionUtils()).thenReturn(new TransactionUtilsMock());
73 when(serviceProvider.getDataProvider()).thenReturn(new DataProvider() {
76 public void writeConnectionLog(ConnectionlogEntity event) {
77 // TODO Auto-generated method stub
82 public void writeEventLog(EventlogEntity event) {
83 // TODO Auto-generated method stub
88 public void writeFaultLog(FaultlogEntity fault) {
89 // TODO Auto-generated method stub
94 public void updateFaultCurrent(FaultcurrentEntity fault) {
95 // TODO Auto-generated method stub
100 public int clearFaultsCurrentOfNode(String nodeName) {
101 // TODO Auto-generated method stub
106 public int clearFaultsCurrentOfNodeWithObjectId(String nodeName, String objectId) {
107 // TODO Auto-generated method stub
112 public List<String> getAllNodesWithCurrentAlarms() {
113 // TODO Auto-generated method stub
118 public void writeInventory(Inventory internalEquipment) {
119 // TODO Auto-generated method stub
124 public void updateNetworkConnectionDeviceType(
125 NetworkElementConnectionEntity networkElementConnectionEntitiy, String nodeId) {
126 // TODO Auto-generated method stub
131 public void updateNetworkConnection22(NetworkElementConnectionEntity networkElementConnectionEntitiy,
133 // TODO Auto-generated method stub
138 public void removeNetworkConnection(String nodeId) {
139 // TODO Auto-generated method stub
144 public int doIndexClean(Date olderAreOutdated) {
145 // TODO Auto-generated method stub
150 public int getNumberOfOldObjects(Date olderAreOutdated) {
151 // TODO Auto-generated method stub
156 public List<NetworkElementConnectionEntity> getNetworkElementConnections() {
157 // TODO Auto-generated method stub
162 public void doWritePerformanceData(List<PmdataEntity> list) {
163 // TODO Auto-generated method stub
174 Optional<NetworkElement> oRanNe;
175 when(accessor.getCapabilites().isSupportingNamespace(ORANHWCOMPONENT.QNAME)).thenReturn(true);
176 when(accessor.getCapabilites().isSupportingNamespace(SimulatorStatus.QNAME)).thenReturn(false);
177 ORanNetworkElementFactory factory = new ORanNetworkElementFactory();
178 oRanNe = factory.create(accessor, serviceProvider);
179 assertTrue((factory.create(accessor, serviceProvider)).isPresent());
180 oRanNe.get().register();
181 oRanNe.get().deregister();
182 oRanNe.get().getAcessor();
183 oRanNe.get().getDeviceType();
184 assertEquals(oRanNe.get().getNodeId().getValue(), "nSky");
188 public void cleanUp() throws Exception {