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.oransc.oam.features.devicemanager.xran.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.Optional;
27 import java.io.IOException;
28 import org.junit.After;
29 import org.junit.BeforeClass;
30 import org.junit.Test;
31 import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider;
32 import org.onap.ccsdk.features.sdnr.wt.devicemanager.ne.service.NetworkElement;
33 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
34 import org.opendaylight.yang.gen.v1.urn.xran.hardware._1._0.rev180720.XRANRADIO;
35 import org.opendaylight.yangtools.yang.common.QName;
36 import org.oransc.oam.features.devicemanager.xran.impl.XRanNetworkElementFactory;
37 import org.oransc.oam.features.devicemanager.xran.test.mock.NetconfAccessorMock;
38 import org.oransc.oam.features.devicemanager.xran.test.mock.TransactionUtilsMock;
39 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider;
40 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.Capabilities;
42 public class TestXRanNetworkElement {
44 static NetconfAccessorMock accessor;
45 static DeviceManagerServiceProvider serviceProvider;
46 static Capabilities capabilities;
50 public static void init() throws InterruptedException, IOException {
51 capabilities = mock(Capabilities.class);
52 //accessor = mock(NetconfAccessorMock.class);
53 accessor = spy(new NetconfAccessorMock(null, null, null, null));
54 serviceProvider = mock(DeviceManagerServiceProvider.class);
56 NodeId nNodeId = new NodeId("nSky");
57 when(accessor.getCapabilites()).thenReturn(capabilities);
58 when (accessor.getNodeId()).thenReturn(nNodeId);
59 when (accessor.getTransactionUtils()).thenReturn(new TransactionUtilsMock());
61 DataProvider dataProvider = mock(DataProvider.class);
62 when(serviceProvider.getDataProvider()).thenReturn(dataProvider);
67 Optional<NetworkElement> oRanNe;
68 when(accessor.getCapabilites().isSupportingNamespace(XRANRADIO.QNAME)).thenReturn(true);
69 XRanNetworkElementFactory factory = new XRanNetworkElementFactory();
70 oRanNe = factory.create(accessor, serviceProvider);
71 assertTrue(factory.create(accessor, serviceProvider).isPresent());
72 oRanNe.get().register();
73 oRanNe.get().deregister();
74 oRanNe.get().getAcessor();
75 oRanNe.get().getDeviceType();
76 assertEquals(oRanNe.get().getNodeId().getValue(), "nSky");
80 public void cleanUp() throws Exception {