Create VES client example for domain 'notification'
[oam.git] / features / devicemanager / o-ran / ru-fh / provider / src / test / java / org / oransc / oam / features / devicemanager / oran / test / TestORanNetworkElement.java
1 /*
2  * ============LICENSE_START========================================================================
3  * O-RAN-SC : oam/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.oransc.oam.features.devicemanager.oran.test;
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.spy;
24 import static org.mockito.Mockito.when;
25 import java.io.IOException;
26 import java.util.Optional;
27 import org.junit.After;
28 import org.junit.BeforeClass;
29 import org.junit.Test;
30 import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider;
31 import org.onap.ccsdk.features.sdnr.wt.devicemanager.ne.service.NetworkElement;
32 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider;
33 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.Capabilities;
34 import org.opendaylight.yang.gen.v1.urn.o.ran.hardware._1._0.rev190328.ORANHWCOMPONENT;
35 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
36 import org.opendaylight.yangtools.yang.common.QName;
37 import org.oransc.oam.features.devicemanager.oran.impl.ORanNetworkElementFactory;
38 import org.oransc.oam.features.devicemanager.oran.test.mock.NetconfAccessorMock;
39 import org.oransc.oam.features.devicemanager.oran.test.mock.TransactionUtilsMock;
40
41 public class TestORanNetworkElement {
42
43     static NetconfAccessorMock accessor;
44     static DeviceManagerServiceProvider serviceProvider;
45     static Capabilities capabilities;
46     QName qCapability;
47
48     @BeforeClass
49     public static void init() throws InterruptedException, IOException {
50         capabilities = mock(Capabilities.class);
51         //accessor = mock(NetconfAccessorMock.class);
52         accessor = spy(new NetconfAccessorMock(null, null, null, null));
53         serviceProvider = mock(DeviceManagerServiceProvider.class);
54
55         NodeId nNodeId = new NodeId("nSky");
56         when(accessor.getCapabilites()).thenReturn(capabilities);
57         when (accessor.getNodeId()).thenReturn(nNodeId);
58         when (accessor.getTransactionUtils()).thenReturn(new TransactionUtilsMock());
59
60         DataProvider dataProvider = mock(DataProvider.class);
61         when(serviceProvider.getDataProvider()).thenReturn(dataProvider);
62     }
63
64     @Test
65     public void test() {
66         Optional<NetworkElement> oRanNe;
67         when(accessor.getCapabilites().isSupportingNamespace(ORANHWCOMPONENT.QNAME)).thenReturn(true);
68         ORanNetworkElementFactory factory = new ORanNetworkElementFactory();
69         oRanNe = factory.create(accessor, serviceProvider);
70         assertTrue(factory.create(accessor, serviceProvider).isPresent());
71         oRanNe.get().register();
72         oRanNe.get().deregister();
73         oRanNe.get().getAcessor();
74         oRanNe.get().getDeviceType();
75         assertEquals(oRanNe.get().getNodeId().getValue(), "nSky");
76     }
77
78     @After
79     public void cleanUp() throws Exception {
80
81     }
82 }