summaryrefslogtreecommitdiffstats
path: root/sdnr/wt/devicemanager-gran/provider/src
diff options
context:
space:
mode:
authorRavi Pendurty <ravi.pendurty@highstreet-technologies.com>2020-02-14 10:28:04 +0100
committerRavi Pendurty <ravi.pendurty@highstreet-technologies.com>2020-02-14 10:28:39 +0100
commitd2d661eeb66a7a2dc8ceadfe47dc3493ef07d671 (patch)
tree33789143145f026465c5e9503f0eb8dcee18ea23 /sdnr/wt/devicemanager-gran/provider/src
parentd0fc4329aa47fa3fdcc3a9f3af31e977ad21b979 (diff)
Add Unit tests
Add Unit tests to provide Code coverage for compliance Issue-ID: SDNC-1069 Signed-off-by: Ravi Pendurty <ravi.pendurty@highstreet-technologies.com> Change-Id: I34027a4cad73be01abf3ca1d988e66167449d251
Diffstat (limited to 'sdnr/wt/devicemanager-gran/provider/src')
-rw-r--r--sdnr/wt/devicemanager-gran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/gran/GRanNetworkElement.java2
-rw-r--r--sdnr/wt/devicemanager-gran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/gran/test/TestDeviceManagerGRanImpl.java58
-rw-r--r--sdnr/wt/devicemanager-gran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/gran/test/TestGRanNetworkElement.java55
-rw-r--r--sdnr/wt/devicemanager-gran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/gran/test/TestGRanNetworkElementFactory.java68
4 files changed, 182 insertions, 1 deletions
diff --git a/sdnr/wt/devicemanager-gran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/gran/GRanNetworkElement.java b/sdnr/wt/devicemanager-gran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/gran/GRanNetworkElement.java
index 077f02c4e..d4932b93e 100644
--- a/sdnr/wt/devicemanager-gran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/gran/GRanNetworkElement.java
+++ b/sdnr/wt/devicemanager-gran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/gran/GRanNetworkElement.java
@@ -39,7 +39,7 @@ public class GRanNetworkElement implements NetworkElement {
@SuppressWarnings("unused")
private final DataProvider databaseService;
- GRanNetworkElement(NetconfAccessor netconfAccess, DataProvider databaseService) {
+ public GRanNetworkElement(NetconfAccessor netconfAccess, DataProvider databaseService) {
log.info("Create {}",GRanNetworkElement.class.getSimpleName());
this.netconfAccessor = netconfAccess;
this.databaseService = databaseService;
diff --git a/sdnr/wt/devicemanager-gran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/gran/test/TestDeviceManagerGRanImpl.java b/sdnr/wt/devicemanager-gran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/gran/test/TestDeviceManagerGRanImpl.java
new file mode 100644
index 000000000..bf0a098d8
--- /dev/null
+++ b/sdnr/wt/devicemanager-gran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/gran/test/TestDeviceManagerGRanImpl.java
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. All rights reserved.
+ * =================================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ * ============LICENSE_END==========================================================================
+ ******************************************************************************/
+package org.onap.ccsdk.features.sdnr.wt.devicemanager.gran.test;
+
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import org.eclipse.jdt.annotation.NonNull;
+import org.junit.Test;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.gran.GRanNetworkElementFactory;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.gran.impl.DeviceManagerGRanImpl;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.AaiService;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.EquipmentService;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.EventHandlingService;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.FaultService;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.MaintenanceService;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.NetconfNetworkElementService;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.NotificationService;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.PerformanceManager;
+
+public class TestDeviceManagerGRanImpl {
+ GRanNetworkElementFactory factory = new GRanNetworkElementFactory();
+ DeviceManagerServiceProvider serviceProvider;
+
+ @Test
+ public void test() throws Exception {
+ serviceProvider = mock(DeviceManagerServiceProvider.class);
+ NetconfNetworkElementService netconfNetworkElementService = mock(NetconfNetworkElementService.class);
+ when(netconfNetworkElementService.registerNetworkElementFactory(factory)).thenReturn(null);
+ when(netconfNetworkElementService.getServiceProvider()).thenReturn(serviceProvider);
+
+ DeviceManagerGRanImpl devMgrGRan = new DeviceManagerGRanImpl();
+
+ devMgrGRan.setNetconfNetworkElementService(netconfNetworkElementService);
+ devMgrGRan.init();
+ devMgrGRan.close();
+
+ }
+
+}
diff --git a/sdnr/wt/devicemanager-gran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/gran/test/TestGRanNetworkElement.java b/sdnr/wt/devicemanager-gran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/gran/test/TestGRanNetworkElement.java
new file mode 100644
index 000000000..1b381ee00
--- /dev/null
+++ b/sdnr/wt/devicemanager-gran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/gran/test/TestGRanNetworkElement.java
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. All rights reserved.
+ * =================================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ * ============LICENSE_END==========================================================================
+ ******************************************************************************/
+package org.onap.ccsdk.features.sdnr.wt.devicemanager.gran.test;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import org.junit.Test;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.gran.GRanNetworkElement;
+import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
+
+public class TestGRanNetworkElement {
+
+ private static final String NODEID = "node1";
+
+ @Test
+ public void test() {
+ NetconfAccessor netconfAccessor = mock(NetconfAccessor.class);
+ DataProvider databaseService = mock(DataProvider.class);
+
+ when(netconfAccessor.getNodeId()).thenReturn(new NodeId(NODEID));
+
+ GRanNetworkElement gRanNe = new GRanNetworkElement(netconfAccessor, databaseService);
+ assertEquals(gRanNe.getDeviceType().getIntValue(), 3);
+ assertEquals(gRanNe.getDeviceType().getName(), "RAN3GPP");
+ assertEquals(gRanNe.getNodeId().getValue(), NODEID);
+
+ gRanNe.register();
+ gRanNe.deregister();
+ gRanNe.warmstart();
+ gRanNe.getAcessor();
+ gRanNe.getService(null);
+
+ }
+
+
+}
diff --git a/sdnr/wt/devicemanager-gran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/gran/test/TestGRanNetworkElementFactory.java b/sdnr/wt/devicemanager-gran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/gran/test/TestGRanNetworkElementFactory.java
new file mode 100644
index 000000000..db25465eb
--- /dev/null
+++ b/sdnr/wt/devicemanager-gran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/gran/test/TestGRanNetworkElementFactory.java
@@ -0,0 +1,68 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. All rights reserved.
+ * =================================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ * ============LICENSE_END==========================================================================
+ ******************************************************************************/
+package org.onap.ccsdk.features.sdnr.wt.devicemanager.gran.test;
+
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.gran.GRanNetworkElementFactory;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider;
+import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.Capabilities;
+import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor;
+import org.opendaylight.yang.gen.v1.urn._3gpp.tsg.sa5.nrm.top.rev180731.TopGrp;
+
+
+public class TestGRanNetworkElementFactory {
+
+ Capabilities capabilities;
+ NetconfAccessor netconfAccessor;
+ DeviceManagerServiceProvider devMgrService;
+
+ @SuppressWarnings("unused")
+ @Before
+ public void init() {
+ capabilities = mock(Capabilities.class);
+ netconfAccessor = mock(NetconfAccessor.class);
+ devMgrService = mock(DeviceManagerServiceProvider.class);
+
+ when(netconfAccessor.getCapabilites()).thenReturn(capabilities);
+ when(devMgrService.getDataProvider()).thenReturn(null);
+
+ }
+
+ @Test
+ public void testCreate() throws Exception {
+ when(netconfAccessor.getCapabilites().isSupportingNamespace(TopGrp.QNAME)).thenReturn(true);
+
+ GRanNetworkElementFactory gRanNeFactory = new GRanNetworkElementFactory();
+ assertTrue((gRanNeFactory.create(netconfAccessor, devMgrService)).isPresent());
+ }
+
+ @Test
+ public void testCreateNone() throws Exception {
+ when(netconfAccessor.getCapabilites().isSupportingNamespace(TopGrp.QNAME)).thenReturn(false);
+
+ GRanNetworkElementFactory gRanNeFactory = new GRanNetworkElementFactory();
+ assertTrue(!(gRanNeFactory.create(netconfAccessor, devMgrService).isPresent()));
+ }
+
+}