2e3af295f77dc314cfca99ce47bc8e080158779b
[oam.git] / features / devicemanager / x-ran / ru-fh / provider / src / test / java / org / onap / ccsdk / features / sdnr / wt / devicemanager / xran / TestXRanNetworkElement.java
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.xran;
19
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.*;
25
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.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider;
38 import org.onap.ccsdk.features.sdnr.wt.devicemanager.xran.mock.NetconfAccessorMock;
39 import org.onap.ccsdk.features.sdnr.wt.devicemanager.xran.mock.TransactionUtilsMock;
40 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.Capabilities;
41
42 public class TestXRanNetworkElement {
43
44     static NetconfAccessorMock accessor;
45     static DeviceManagerServiceProvider serviceProvider;
46     static Capabilities capabilities;
47     QName qCapability;
48
49     @BeforeClass
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);
55
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());
60
61         DataProvider dataProvider = mock(DataProvider.class);
62         when(serviceProvider.getDataProvider()).thenReturn(dataProvider);
63     }
64
65     @Test
66     public void test() {
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");
77     }
78
79     @After
80     public void cleanUp() throws Exception {
81
82     }
83 }