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.onap.ccsdk.features.sdnr.wt.devicemanager.oran.test;
20 import static org.junit.Assert.assertTrue;
21 import static org.mockito.Mockito.mock;
22 import static org.mockito.Mockito.when;
23 import java.io.IOException;
24 import java.util.Optional;
26 import org.junit.After;
27 import org.junit.BeforeClass;
28 import org.junit.Test;
29 import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.impl.ORanNetworkElementFactory;
30 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider;
31 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.VESCollectorService;
32 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.Capabilities;
33 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfBindingAccessor;
34 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.TransactionUtils;
35 import org.opendaylight.yang.gen.v1.urn.o.ran.hardware._1._0.rev190328.ORANHWCOMPONENT;
36 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
38 public class TestORanNetworkElementFactory {
40 private static String NODEIDSTRING = "nSky";
42 private static NetconfBindingAccessor accessor;
43 private static DeviceManagerServiceProvider serviceProvider;
44 private static Capabilities capabilities;
45 private static VESCollectorService vesCollectorService;
46 private static NetconfBindingAccessor bindingCommunicator;
49 public static void init() throws InterruptedException, IOException {
50 bindingCommunicator = mock(NetconfBindingAccessor.class);
51 vesCollectorService = mock(VESCollectorService.class);
52 NodeId nodeId = new NodeId(NODEIDSTRING);
53 when(bindingCommunicator.getTransactionUtils()).thenReturn(mock(TransactionUtils.class));
54 when(bindingCommunicator.getNodeId()).thenReturn(nodeId);
57 capabilities = mock(Capabilities.class);
58 accessor = mock(NetconfBindingAccessor.class);
59 serviceProvider = mock(DeviceManagerServiceProvider.class);
61 when(accessor.getCapabilites()).thenReturn(capabilities);
62 when(accessor.getNetconfBindingAccessor()).thenReturn(Optional.of(bindingCommunicator));
63 when(serviceProvider.getDataProvider()).thenReturn(null);
64 when(serviceProvider.getVESCollectorService()).thenReturn(vesCollectorService);
70 public void testCreateORANHWComponent() throws Exception {
71 when(accessor.getCapabilites().isSupportingNamespace(ORANHWCOMPONENT.QNAME)).thenReturn(true);
72 ORanNetworkElementFactory factory = new ORanNetworkElementFactory();
73 assertTrue((factory.create(accessor, serviceProvider)).isPresent());
77 public void testCreateNone() throws Exception {
78 when(accessor.getCapabilites().isSupportingNamespace(ORANHWCOMPONENT.QNAME)).thenReturn(false);
79 ORanNetworkElementFactory factory = new ORanNetworkElementFactory();
80 assertTrue(!(factory.create(accessor, serviceProvider).isPresent()));
84 public void cleanUp() throws Exception {