Add bounds to sphinx requirement
[ccsdk/features.git] / sdnr / wt / devicemanager-o-ran-sc / o-ran / ru-fh / provider / src / test / java / org / onap / ccsdk / features / sdnr / wt / devicemanager / oran / impl / binding / TestORanNetworkElement.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.oran.impl.binding;
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 java.io.IOException;
25 import java.util.Optional;
26 import org.eclipse.jdt.annotation.NonNull;
27 import org.junit.BeforeClass;
28 import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider;
29 import org.onap.ccsdk.features.sdnr.wt.devicemanager.ne.service.NetworkElement;
30 import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.impl.startup.ORanNetworkElementFactory;
31 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider;
32 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.FaultService;
33 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.NotificationProxyParser;
34 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.VESCollectorCfgService;
35 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.VESCollectorService;
36 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.Capabilities;
37 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor;
38 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfBindingAccessor;
39 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfDomAccessor;
40 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.TransactionUtils;
41 import org.onap.ccsdk.features.sdnr.wt.websocketmanager.model.WebsocketManagerService;
42 import org.opendaylight.yang.gen.v1.urn.o.ran.hardware._1._0.rev190328.ORANHWCOMPONENT;
43 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
44 import org.opendaylight.yangtools.yang.common.QName;
45
46 public class TestORanNetworkElement {
47
48     private static final QName OneCell =
49             QName.create("urn:onf:otcc:wireless:yang:radio-access:commscope-onecell", "2020-06-22", "onecell").intern();
50     private static final @NonNull QName OnapSystem = QName.create("urn:onap:system", "2020-10-26", "onap-system").intern();
51     private static String NODEIDSTRING = "nSky";
52     private static NodeId nodeId = new NodeId(NODEIDSTRING);
53
54     private static NetconfAccessor accessor;
55     private static DeviceManagerServiceProvider serviceProvider;
56     private static Capabilities capabilities;
57     private static TransactionUtils transactionUtils;
58     private static NetconfBindingAccessor bindingAccessor;
59     private static NetconfDomAccessor domAccessor;
60     private static VESCollectorService vesCollectorService;
61     private static NotificationProxyParser notificationProxyParser;
62     private static VESCollectorCfgService vesCfgService;
63     private static WebsocketManagerService websocketManagerService;
64
65     @BeforeClass
66     public static void init() throws InterruptedException, IOException {
67         capabilities = mock(Capabilities.class);
68         accessor = mock(NetconfAccessor.class);
69         serviceProvider = mock(DeviceManagerServiceProvider.class);
70         transactionUtils = mock(TransactionUtils.class);
71         bindingAccessor = mock(NetconfBindingAccessor.class);
72         domAccessor = mock(NetconfDomAccessor.class);
73         vesCollectorService = mock(VESCollectorService.class);
74         notificationProxyParser = mock(NotificationProxyParser.class);
75         vesCfgService = mock(VESCollectorCfgService.class);
76         websocketManagerService = mock(WebsocketManagerService.class);
77
78         when(accessor.getCapabilites()).thenReturn(capabilities);
79         when(accessor.getNodeId()).thenReturn(nodeId);
80         when(accessor.getNetconfBindingAccessor()).thenReturn(Optional.of(bindingAccessor));
81         when(accessor.getNetconfDomAccessor()).thenReturn(Optional.of(domAccessor));
82         when(bindingAccessor.getCapabilites()).thenReturn(capabilities);
83         when(bindingAccessor.getTransactionUtils()).thenReturn(transactionUtils);
84         when(bindingAccessor.getNodeId()).thenReturn(nodeId);
85         when(vesCollectorService.getNotificationProxyParser()).thenReturn(notificationProxyParser);
86
87         DataProvider dataProvider = mock(DataProvider.class);
88         FaultService faultService = mock(FaultService.class);
89         when(serviceProvider.getWebsocketService()).thenReturn(websocketManagerService);
90         when(serviceProvider.getFaultService()).thenReturn(faultService);
91         when(serviceProvider.getDataProvider()).thenReturn(dataProvider);
92         when(serviceProvider.getVESCollectorService()).thenReturn(vesCollectorService);
93         when(vesCollectorService.getConfig()).thenReturn(vesCfgService);
94         when(vesCfgService.isVESCollectorEnabled()).thenReturn(true);
95
96     }
97
98     //@Test
99     public void test() {
100         Optional<NetworkElement> oRanNe;
101         when(capabilities.isSupportingNamespace(ORANHWCOMPONENT.QNAME)).thenReturn(true);
102         when(capabilities.isSupportingNamespace(OneCell)).thenReturn(false);
103         when(capabilities.isSupportingNamespace(OnapSystem)).thenReturn(false);
104
105         ORanNetworkElementFactory factory = new ORanNetworkElementFactory();
106         oRanNe = factory.create(accessor, serviceProvider);
107         assertTrue(factory.create(accessor, serviceProvider).isPresent());
108         oRanNe.get().register();
109         oRanNe.get().deregister();
110         oRanNe.get().getAcessor();
111         oRanNe.get().getDeviceType();
112         assertEquals(oRanNe.get().getNodeId().getValue(), "nSky");
113     }
114
115  }