diff options
author | KAPIL SINGAL <ks220y@att.com> | 2020-02-14 15:44:03 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2020-02-14 15:44:03 +0000 |
commit | 1c924ae13ed9a0fc9b6afd4d16b8becdf8d0b44c (patch) | |
tree | d77720d11ba921781164ee53c9dac550f238a60b /sdnr | |
parent | 9751ab7122a05e9ca10dde1348869f06899fa0cc (diff) | |
parent | d2d661eeb66a7a2dc8ceadfe47dc3493ef07d671 (diff) |
Merge "Add Unit tests"
Diffstat (limited to 'sdnr')
5 files changed, 214 insertions, 11 deletions
diff --git a/sdnr/wt/devicemanager-gran/model/src/main/yang/devicemanager-gran.yang b/sdnr/wt/devicemanager-gran/model/src/main/yang/devicemanager-gran.yang index ca52678dd..4272892a7 100644 --- a/sdnr/wt/devicemanager-gran/model/src/main/yang/devicemanager-gran.yang +++ b/sdnr/wt/devicemanager-gran/model/src/main/yang/devicemanager-gran.yang @@ -1,15 +1,37 @@ module devicemanager-gran { - yang-version 1; - namespace "urn:opendaylight:params:xml:ns:yang:devicemanager-gran"; - prefix "devicemanager-gran"; - description - "DeviceManager 3gpp Api Module"; + yang-version 1; + namespace "urn:opendaylight:params:xml:ns:yang:devicemanager-gran"; + prefix devicemanager-gran; + + organization + "highstreet technologies GmbH"; + contact + "Web: <https://highstreet-technologies.com> + O-RAN1: <https://wiki.o-ran-sc.org/display/OAM/Operations+and+Maintenance"; + + description + "DeviceManager 3gpp Api Module - revision "2019-11-29" { - description - "Initial revision"; - } + Copyright 2019 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."; + + revision 2019-11-29 { + description + "Initial revision"; + reference + "https://jira.onap.org/browse/SDNC-877"; + } +} 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())); + } + +} |