From 10f412eccf092677b2b1095661afb806909b9338 Mon Sep 17 00:00:00 2001 From: Ravi Pendurty Date: Thu, 20 Aug 2020 08:12:40 +0200 Subject: [PATCH] Upgrade devicemanager-oran minus NTSim functionality Upgrade devicemanager-oran minus NTSim functionality Issue-ID: OAM-151 Signed-off-by: Ravi Pendurty Change-Id: I41078b0beb23c9cc49679c7f4c6f8598aa437890 Signed-off-by: Ravi Pendurty --- .../oran/impl/DeviceManagerORanImpl.java | 6 +- .../devicemanager/oran/impl/NtsNetworkElement.java | 83 ---------------- .../oran/impl/ORanChangeNotificationListener.java | 6 +- .../oran/impl/ORanFaultNotificationListener.java | 4 +- .../oran/impl/ORanNetworkElement.java | 21 ++--- .../oran/impl/ORanNetworkElementFactory.java | 26 ++--- .../oran/impl/ORanToInternalDataModel.java | 4 +- .../oran/test/TestDeviceManagerORanImpl.java | 105 +++++++-------------- .../devicemanager/oran/test/TestHardwareClass.java | 17 ++++ .../test/TestORanChangeNotificationListener.java | 80 ++++++++-------- .../test/TestORanFaultNotificationListener.java | 12 +-- .../oran/test/TestORanNetworkElement.java | 11 +-- .../oran/test/TestORanNetworkElementFactory.java | 74 ++++++--------- .../oran/test/TestORanToInternalDataModel.java | 77 +++++++-------- .../oran/test/mock/NetconfAccessorMock.java | 2 +- .../oran/test/mock/TransactionUtilsMock.java | 29 +++--- 16 files changed, 221 insertions(+), 336 deletions(-) delete mode 100644 features/devicemanager/o-ran/ru-fh/provider/src/main/java/org/oransc/oam/features/devicemanager/oran/impl/NtsNetworkElement.java diff --git a/features/devicemanager/o-ran/ru-fh/provider/src/main/java/org/oransc/oam/features/devicemanager/oran/impl/DeviceManagerORanImpl.java b/features/devicemanager/o-ran/ru-fh/provider/src/main/java/org/oransc/oam/features/devicemanager/oran/impl/DeviceManagerORanImpl.java index aeaf312..e580426 100644 --- a/features/devicemanager/o-ran/ru-fh/provider/src/main/java/org/oransc/oam/features/devicemanager/oran/impl/DeviceManagerORanImpl.java +++ b/features/devicemanager/o-ran/ru-fh/provider/src/main/java/org/oransc/oam/features/devicemanager/oran/impl/DeviceManagerORanImpl.java @@ -1,8 +1,8 @@ /* * ============LICENSE_START======================================================================== - * ONAP : ccsdk feature sdnr wt + * O-RAN-SC : oam/ccsdk feature sdnr wt * ================================================================================================= - * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved. + * 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 @@ -23,7 +23,7 @@ import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.NetconfNetworkEleme import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class DeviceManagerORanImpl implements AutoCloseable { +public class DeviceManagerORanImpl implements AutoCloseable { private static final Logger LOG = LoggerFactory.getLogger(DeviceManagerORanImpl.class); private static final String APPLICATION_NAME = "DeviceManagerORan"; diff --git a/features/devicemanager/o-ran/ru-fh/provider/src/main/java/org/oransc/oam/features/devicemanager/oran/impl/NtsNetworkElement.java b/features/devicemanager/o-ran/ru-fh/provider/src/main/java/org/oransc/oam/features/devicemanager/oran/impl/NtsNetworkElement.java deleted file mode 100644 index f718442..0000000 --- a/features/devicemanager/o-ran/ru-fh/provider/src/main/java/org/oransc/oam/features/devicemanager/oran/impl/NtsNetworkElement.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * ============LICENSE_START======================================================================== - * ONAP : ccsdk feature sdnr wt - * ================================================================================================= - * Copyright (C) 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. - * ============LICENSE_END========================================================================== - */ -/** - * - */ -package org.oransc.oam.features.devicemanager.oran.impl; - -import java.util.Optional; -import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.ne.service.NetworkElement; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.ne.service.NetworkElementService; -import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.NetworkElementDeviceType; -import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @author herbert - * - */ -public class NtsNetworkElement implements NetworkElement { - - private static final Logger LOG = LoggerFactory.getLogger(NtsNetworkElement.class); - - private final NetconfAccessor netconfAccessor; - - @SuppressWarnings("unused") - private final DataProvider databaseService; - - NtsNetworkElement(NetconfAccessor netconfAccess, DataProvider databaseService) { - LOG.info("Create {}",NtsNetworkElement.class.getSimpleName()); - this.netconfAccessor = netconfAccess; - this.databaseService = databaseService; - } - - @Override - public void deregister() { - } - - @Override - public NodeId getNodeId() { - return netconfAccessor.getNodeId(); - } - - @Override - public Optional getService(Class clazz) { - return Optional.empty(); - } - - @Override - public void warmstart() { - } - - @Override - public void register() { - } - - @Override - public NetworkElementDeviceType getDeviceType() { - return NetworkElementDeviceType.NtsManager; - } - - @Override - public Optional getAcessor() { - return Optional.of(this.netconfAccessor); - } -} diff --git a/features/devicemanager/o-ran/ru-fh/provider/src/main/java/org/oransc/oam/features/devicemanager/oran/impl/ORanChangeNotificationListener.java b/features/devicemanager/o-ran/ru-fh/provider/src/main/java/org/oransc/oam/features/devicemanager/oran/impl/ORanChangeNotificationListener.java index 2b413f6..5c35f85 100644 --- a/features/devicemanager/o-ran/ru-fh/provider/src/main/java/org/oransc/oam/features/devicemanager/oran/impl/ORanChangeNotificationListener.java +++ b/features/devicemanager/o-ran/ru-fh/provider/src/main/java/org/oransc/oam/features/devicemanager/oran/impl/ORanChangeNotificationListener.java @@ -1,8 +1,8 @@ /* * ============LICENSE_START======================================================================== - * ONAP : ccsdk feature sdnr wt + * O-RAN-SC : oam/ccsdk feature sdnr wt * ================================================================================================= - * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved. + * 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 @@ -36,7 +36,7 @@ import org.slf4j.LoggerFactory; /** * Listener for change notifications */ -public class ORanChangeNotificationListener implements IetfNetconfNotificationsListener { +public class ORanChangeNotificationListener implements IetfNetconfNotificationsListener { private static final Logger log = LoggerFactory.getLogger(ORanChangeNotificationListener.class); diff --git a/features/devicemanager/o-ran/ru-fh/provider/src/main/java/org/oransc/oam/features/devicemanager/oran/impl/ORanFaultNotificationListener.java b/features/devicemanager/o-ran/ru-fh/provider/src/main/java/org/oransc/oam/features/devicemanager/oran/impl/ORanFaultNotificationListener.java index 6197cf1..b460f16 100644 --- a/features/devicemanager/o-ran/ru-fh/provider/src/main/java/org/oransc/oam/features/devicemanager/oran/impl/ORanFaultNotificationListener.java +++ b/features/devicemanager/o-ran/ru-fh/provider/src/main/java/org/oransc/oam/features/devicemanager/oran/impl/ORanFaultNotificationListener.java @@ -1,8 +1,8 @@ /* * ============LICENSE_START======================================================================== - * ONAP : ccsdk feature sdnr wt + * O-RAN-SC : oam/ccsdk feature sdnr wt * ================================================================================================= - * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved. + * 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 diff --git a/features/devicemanager/o-ran/ru-fh/provider/src/main/java/org/oransc/oam/features/devicemanager/oran/impl/ORanNetworkElement.java b/features/devicemanager/o-ran/ru-fh/provider/src/main/java/org/oransc/oam/features/devicemanager/oran/impl/ORanNetworkElement.java index 0c7f6b8..1404c34 100644 --- a/features/devicemanager/o-ran/ru-fh/provider/src/main/java/org/oransc/oam/features/devicemanager/oran/impl/ORanNetworkElement.java +++ b/features/devicemanager/o-ran/ru-fh/provider/src/main/java/org/oransc/oam/features/devicemanager/oran/impl/ORanNetworkElement.java @@ -1,8 +1,8 @@ /* * ============LICENSE_START======================================================================== - * ONAP : ccsdk feature sdnr wt + * O-RAN-SC : oam/ccsdk feature sdnr wt * ================================================================================================= - * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved. + * 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 @@ -53,7 +53,7 @@ public class ORanNetworkElement implements NetworkElement { private @NonNull final ORanFaultNotificationListener oRanFaultListener; ORanNetworkElement(NetconfAccessor netconfAccess, DataProvider databaseService) { - log.info("Create {}",ORanNetworkElement.class.getSimpleName()); + log.info("Create {}", ORanNetworkElement.class.getSimpleName()); this.netconfAccessor = netconfAccess; this.databaseService = databaseService; @@ -73,7 +73,8 @@ public class ORanNetworkElement implements NetworkElement { List componentList = hardware.getComponent(); if (componentList != null) { for (Component component : componentList) { - databaseService.writeInventory( oRanMapper.getInternalEquipment(netconfAccessor.getNodeId(), component)); + databaseService + .writeInventory(oRanMapper.getInternalEquipment(netconfAccessor.getNodeId(), component)); } } } @@ -91,11 +92,10 @@ public class ORanNetworkElement implements NetworkElement { log.info("DBRead Get equipment for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(), accessData.getNodeId().getValue()); - InstanceIdentifier hardwareIID = - InstanceIdentifier.builder(clazzPac).build(); + InstanceIdentifier hardwareIID = InstanceIdentifier.builder(clazzPac).build(); - Hardware res = accessData.getTransactionUtils().readData(accessData.getDataBroker(), LogicalDatastoreType.OPERATIONAL, - hardwareIID); + Hardware res = accessData.getTransactionUtils().readData(accessData.getDataBroker(), + LogicalDatastoreType.OPERATIONAL, hardwareIID); return res; } @@ -120,7 +120,7 @@ public class ORanNetworkElement implements NetworkElement { } if (oRanFaultListenerRegistrationResult != null) { this.oRanFaultListenerRegistrationResult.close(); - }; + } ; } @@ -135,8 +135,7 @@ public class ORanNetworkElement implements NetworkElement { } @Override - public void warmstart() { - } + public void warmstart() {} @Override public Optional getAcessor() { diff --git a/features/devicemanager/o-ran/ru-fh/provider/src/main/java/org/oransc/oam/features/devicemanager/oran/impl/ORanNetworkElementFactory.java b/features/devicemanager/o-ran/ru-fh/provider/src/main/java/org/oransc/oam/features/devicemanager/oran/impl/ORanNetworkElementFactory.java index f0f9815..bc9da71 100644 --- a/features/devicemanager/o-ran/ru-fh/provider/src/main/java/org/oransc/oam/features/devicemanager/oran/impl/ORanNetworkElementFactory.java +++ b/features/devicemanager/o-ran/ru-fh/provider/src/main/java/org/oransc/oam/features/devicemanager/oran/impl/ORanNetworkElementFactory.java @@ -1,8 +1,8 @@ /* * ============LICENSE_START======================================================================== - * ONAP : ccsdk feature sdnr wt + * O-RAN-SC : oam/ccsdk feature sdnr wt * ================================================================================================= - * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved. + * 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 @@ -22,26 +22,30 @@ import java.util.Optional; import org.onap.ccsdk.features.sdnr.wt.devicemanager.ne.factory.NetworkElementFactory; import org.onap.ccsdk.features.sdnr.wt.devicemanager.ne.service.NetworkElement; 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.o.ran.hardware._1._0.rev190328.ORANHWCOMPONENT; -import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.network.topology.simulator.rev191025.SimulatorStatus; +import org.opendaylight.yangtools.yang.common.QName; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class ORanNetworkElementFactory implements NetworkElementFactory { private static final Logger log = LoggerFactory.getLogger(ORanNetworkElementFactory.class); + //Workaround + private static final QName OneCell = + QName.create("urn:onf:otcc:wireless:yang:radio-access:commscope-onecell", "2020-06-22", "onecell").intern(); + @Override public Optional create(NetconfAccessor acessor, DeviceManagerServiceProvider serviceProvider) { - if (acessor.getCapabilites().isSupportingNamespace(ORANHWCOMPONENT.QNAME)) { - log.info("Create device {} ",ORanNetworkElement.class.getName()); - return Optional.of(new ORanNetworkElement(acessor, serviceProvider.getDataProvider())); - } else if (acessor.getCapabilites().isSupportingNamespace(SimulatorStatus.QNAME)) { - log.info("Create device {} ",NtsNetworkElement.class.getName()); - return Optional.of(new NtsNetworkElement(acessor, serviceProvider.getDataProvider())); - } else { - return Optional.empty(); + Capabilities capabilites = acessor.getCapabilites(); + if (!capabilites.isSupportingNamespace(OneCell)) { + if (capabilites.isSupportingNamespace(ORANHWCOMPONENT.QNAME)) { + log.info("Create device {} ", ORanNetworkElement.class.getName()); + return Optional.of(new ORanNetworkElement(acessor, serviceProvider.getDataProvider())); + } } + return Optional.empty(); } } diff --git a/features/devicemanager/o-ran/ru-fh/provider/src/main/java/org/oransc/oam/features/devicemanager/oran/impl/ORanToInternalDataModel.java b/features/devicemanager/o-ran/ru-fh/provider/src/main/java/org/oransc/oam/features/devicemanager/oran/impl/ORanToInternalDataModel.java index e9e8520..0864b8f 100644 --- a/features/devicemanager/o-ran/ru-fh/provider/src/main/java/org/oransc/oam/features/devicemanager/oran/impl/ORanToInternalDataModel.java +++ b/features/devicemanager/o-ran/ru-fh/provider/src/main/java/org/oransc/oam/features/devicemanager/oran/impl/ORanToInternalDataModel.java @@ -1,8 +1,8 @@ /** * ============LICENSE_START======================================================================== - * ONAP : ccsdk feature sdnr wt + * O-RAN-SC : oam/ccsdk feature sdnr wt * ================================================================================================= - * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved. + * 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 diff --git a/features/devicemanager/o-ran/ru-fh/provider/src/test/java/org/oransc/oam/features/devicemanager/oran/test/TestDeviceManagerORanImpl.java b/features/devicemanager/o-ran/ru-fh/provider/src/test/java/org/oransc/oam/features/devicemanager/oran/test/TestDeviceManagerORanImpl.java index 93459f6..c9476be 100644 --- a/features/devicemanager/o-ran/ru-fh/provider/src/test/java/org/oransc/oam/features/devicemanager/oran/test/TestDeviceManagerORanImpl.java +++ b/features/devicemanager/o-ran/ru-fh/provider/src/test/java/org/oransc/oam/features/devicemanager/oran/test/TestDeviceManagerORanImpl.java @@ -1,84 +1,51 @@ +/* + * ============LICENSE_START======================================================================== + * O-RAN-SC : oam/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.oransc.oam.features.devicemanager.oran.test; -import java.io.File; -import java.io.FileNotFoundException; +import static org.mockito.Mockito.mock; import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; - import org.junit.After; import org.junit.Before; import org.junit.Test; import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.NetconfNetworkElementService; import org.oransc.oam.features.devicemanager.oran.impl.DeviceManagerORanImpl; -import org.oransc.oam.features.devicemanager.oran.impl.ORanNetworkElementFactory; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; public class TestDeviceManagerORanImpl { - private static Path KARAF_ETC = Paths.get("etc"); - private static final Logger LOG = LoggerFactory.getLogger(TestDeviceManagerORanImpl.class); - DeviceManagerORanImpl devMgrOran; - - @Before - public void init() throws InterruptedException, IOException { - /*System.out.println("Logger: " + LOG.getClass().getName() + " " + LOG.getName()); - Path etc = KARAF_ETC; - delete(etc); - - System.out.println("Create empty:" + etc.toString()); - Files.createDirectories(etc);*/ - } - - @Test - public void test() throws Exception { - devMgrOran = new DeviceManagerORanImpl(); - /*DeviceManagerImpl devMgr = new DeviceManagerImpl(); - - try { - devMgr.init(); - devMgrOran.setNetconfNetworkElementService(devMgr); - devMgrOran.init(); - } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); - }*/ - /* - * devMgrOran.setNetconfNetworkElementService(null); devMgrOran.init(); - * NetconfNetworkElementService netConfNetworkElementService = - * mock(NetconfNetworkElementService.class); devMgrOran = - * mock(DeviceManagerORanImpl.class); - * when(netConfNetworkElementService.registerNetworkElementFactory(new - * ORanNetworkElementFactory())).thenReturn(null); - */ - - - } - - @After - public void cleanUp() throws Exception { - devMgrOran.close(); - } - - private static void delete(Path etc) throws IOException { - if (Files.exists(etc)) { - System.out.println("Found, removing:" + etc.toString()); - delete(etc.toFile()); + DeviceManagerORanImpl devMgrOran; + + @Before + public void init() throws InterruptedException, IOException {} + + @Test + public void test() throws Exception { + devMgrOran = new DeviceManagerORanImpl(); + NetconfNetworkElementService netconfNetworkElementService = mock(NetconfNetworkElementService.class); + + try { + devMgrOran.setNetconfNetworkElementService(netconfNetworkElementService); + devMgrOran.init(); + } catch (Exception e) { + throw e; } } - private static void delete(File f) throws IOException { - if (f.isDirectory()) { - for (File c : f.listFiles()) { - delete(c); - } - } - if (!f.delete()) { - throw new FileNotFoundException("Failed to delete file: " + f); - } + @After + public void cleanUp() throws Exception { + devMgrOran.close(); } } diff --git a/features/devicemanager/o-ran/ru-fh/provider/src/test/java/org/oransc/oam/features/devicemanager/oran/test/TestHardwareClass.java b/features/devicemanager/o-ran/ru-fh/provider/src/test/java/org/oransc/oam/features/devicemanager/oran/test/TestHardwareClass.java index 67c91ca..4d259cd 100644 --- a/features/devicemanager/o-ran/ru-fh/provider/src/test/java/org/oransc/oam/features/devicemanager/oran/test/TestHardwareClass.java +++ b/features/devicemanager/o-ran/ru-fh/provider/src/test/java/org/oransc/oam/features/devicemanager/oran/test/TestHardwareClass.java @@ -1,3 +1,20 @@ +/* + * ============LICENSE_START======================================================================== + * O-RAN-SC : oam/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.oransc.oam.features.devicemanager.oran.test; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana.hardware.rev180313.HardwareClass; diff --git a/features/devicemanager/o-ran/ru-fh/provider/src/test/java/org/oransc/oam/features/devicemanager/oran/test/TestORanChangeNotificationListener.java b/features/devicemanager/o-ran/ru-fh/provider/src/test/java/org/oransc/oam/features/devicemanager/oran/test/TestORanChangeNotificationListener.java index 9bf71bb..435d565 100644 --- a/features/devicemanager/o-ran/ru-fh/provider/src/test/java/org/oransc/oam/features/devicemanager/oran/test/TestORanChangeNotificationListener.java +++ b/features/devicemanager/o-ran/ru-fh/provider/src/test/java/org/oransc/oam/features/devicemanager/oran/test/TestORanChangeNotificationListener.java @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================================== - * ONAP : ccsdk feature sdnr wt + * O-RAN-SC : oam/ccsdk feature sdnr wt * ================================================================================================= * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. All rights reserved. * ================================================================================================= @@ -18,11 +18,11 @@ package org.oransc.oam.features.devicemanager.oran.test; -import static org.mockito.Mockito.*; - +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; import java.util.Arrays; import java.util.List; - import org.eclipse.jdt.annotation.NonNull; import org.junit.Test; import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider; @@ -41,47 +41,47 @@ import org.oransc.oam.features.devicemanager.oran.impl.ORanChangeNotificationLis public class TestORanChangeNotificationListener { - private static final String NODEID = "node1"; + private static final String NODEID = "node1"; + + @Test + public void test() { - @Test - public void test() { + NetconfAccessor netconfAccessor = mock(NetconfAccessor.class); + DataProvider databaseService = mock(DataProvider.class); + ORanChangeNotificationListener notifListener = + new ORanChangeNotificationListener(netconfAccessor, databaseService); + when(netconfAccessor.getNodeId()).thenReturn(new NodeId(NODEID)); + Iterable pathArguments = Arrays.asList(new PathArgument() { - NetconfAccessor netconfAccessor = mock(NetconfAccessor.class); - DataProvider databaseService = mock(DataProvider.class); - ORanChangeNotificationListener notifListener = new ORanChangeNotificationListener(netconfAccessor, - databaseService); - when(netconfAccessor.getNodeId()).thenReturn(new NodeId(NODEID)); - Iterable pathArguments = Arrays.asList(new PathArgument() { + @Override + public int compareTo(PathArgument arg0) { + return 0; + } - @Override - public int compareTo(PathArgument arg0) { - return 0; - } + @Override + public Class getType() { + return DataObject.class; + } + }); + InstanceIdentifier target = InstanceIdentifier.create(pathArguments); - @Override - public Class getType() { - return DataObject.class; - } - }); - InstanceIdentifier target = InstanceIdentifier.create(pathArguments); + notifListener.onNetconfConfigChange(createNotification(EditOperationType.Create, target)); + EventlogEntity event = new EventlogBuilder().setNodeId(NODEID) + .setNewValue(String.valueOf(EditOperationType.Create)).setObjectId(target.toString()).build(); + verify(databaseService).writeEventLog(event); - notifListener.onNetconfConfigChange(createNotification(EditOperationType.Create,target)); - EventlogEntity event = new EventlogBuilder().setNodeId(NODEID) - .setNewValue(String.valueOf(EditOperationType.Create)).setObjectId(target.toString()).build(); - verify(databaseService).writeEventLog(event); + } - } + /** + * @param type + * @return + */ + private static NetconfConfigChange createNotification(EditOperationType type, InstanceIdentifier target) { + NetconfConfigChange change = mock(NetconfConfigChange.class); - /** - * @param type - * @return - */ - private static NetconfConfigChange createNotification(EditOperationType type,InstanceIdentifier target) { - NetconfConfigChange change = mock(NetconfConfigChange.class); - - @SuppressWarnings("null") - final @NonNull List edits = Arrays.asList(new EditBuilder().setOperation(type).setTarget(target).build()); - when(change.nonnullEdit()).thenReturn(edits); - return change; - } + @SuppressWarnings("null") + final @NonNull List edits = Arrays.asList(new EditBuilder().setOperation(type).setTarget(target).build()); + when(change.nonnullEdit()).thenReturn(edits); + return change; + } } diff --git a/features/devicemanager/o-ran/ru-fh/provider/src/test/java/org/oransc/oam/features/devicemanager/oran/test/TestORanFaultNotificationListener.java b/features/devicemanager/o-ran/ru-fh/provider/src/test/java/org/oransc/oam/features/devicemanager/oran/test/TestORanFaultNotificationListener.java index 247982a..61e5d1b 100644 --- a/features/devicemanager/o-ran/ru-fh/provider/src/test/java/org/oransc/oam/features/devicemanager/oran/test/TestORanFaultNotificationListener.java +++ b/features/devicemanager/o-ran/ru-fh/provider/src/test/java/org/oransc/oam/features/devicemanager/oran/test/TestORanFaultNotificationListener.java @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================================== - * ONAP : ccsdk feature sdnr wt + * O-RAN-SC : oam/ccsdk feature sdnr wt * ================================================================================================= * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. All rights reserved. * ================================================================================================= @@ -22,9 +22,9 @@ import org.oransc.oam.features.devicemanager.oran.impl.ORanFaultNotificationList public class TestORanFaultNotificationListener { - @Test - public void test() { - ORanFaultNotificationListener faultListener = new ORanFaultNotificationListener(); - faultListener.onAlarmNotif(null); - } + @Test + public void test() { + ORanFaultNotificationListener faultListener = new ORanFaultNotificationListener(); + faultListener.onAlarmNotif(null); + } } diff --git a/features/devicemanager/o-ran/ru-fh/provider/src/test/java/org/oransc/oam/features/devicemanager/oran/test/TestORanNetworkElement.java b/features/devicemanager/o-ran/ru-fh/provider/src/test/java/org/oransc/oam/features/devicemanager/oran/test/TestORanNetworkElement.java index 6ae6d75..845e24c 100644 --- a/features/devicemanager/o-ran/ru-fh/provider/src/test/java/org/oransc/oam/features/devicemanager/oran/test/TestORanNetworkElement.java +++ b/features/devicemanager/o-ran/ru-fh/provider/src/test/java/org/oransc/oam/features/devicemanager/oran/test/TestORanNetworkElement.java @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================================== - * ONAP : ccsdk feature sdnr wt + * O-RAN-SC : oam/ccsdk feature sdnr wt * ================================================================================================= * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. All rights reserved. * ================================================================================================= @@ -20,16 +20,17 @@ package org.oransc.oam.features.devicemanager.oran.test; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.spy; import static org.mockito.Mockito.when; -import static org.mockito.Mockito.*; - -import java.util.Optional; import java.io.IOException; +import java.util.Optional; import org.junit.After; import org.junit.BeforeClass; import org.junit.Test; import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider; import org.onap.ccsdk.features.sdnr.wt.devicemanager.ne.service.NetworkElement; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.Capabilities; import org.opendaylight.yang.gen.v1.urn.o.ran.hardware._1._0.rev190328.ORANHWCOMPONENT; import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.network.topology.simulator.rev191025.SimulatorStatus; import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; @@ -37,8 +38,6 @@ import org.opendaylight.yangtools.yang.common.QName; import org.oransc.oam.features.devicemanager.oran.impl.ORanNetworkElementFactory; import org.oransc.oam.features.devicemanager.oran.test.mock.NetconfAccessorMock; import org.oransc.oam.features.devicemanager.oran.test.mock.TransactionUtilsMock; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider; -import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.Capabilities; public class TestORanNetworkElement { diff --git a/features/devicemanager/o-ran/ru-fh/provider/src/test/java/org/oransc/oam/features/devicemanager/oran/test/TestORanNetworkElementFactory.java b/features/devicemanager/o-ran/ru-fh/provider/src/test/java/org/oransc/oam/features/devicemanager/oran/test/TestORanNetworkElementFactory.java index 8f32670..ca61d44 100644 --- a/features/devicemanager/o-ran/ru-fh/provider/src/test/java/org/oransc/oam/features/devicemanager/oran/test/TestORanNetworkElementFactory.java +++ b/features/devicemanager/o-ran/ru-fh/provider/src/test/java/org/oransc/oam/features/devicemanager/oran/test/TestORanNetworkElementFactory.java @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================================== - * ONAP : ccsdk feature sdnr wt + * O-RAN-SC : oam/ccsdk feature sdnr wt * ================================================================================================= * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. All rights reserved. * ================================================================================================= @@ -20,7 +20,6 @@ package org.oransc.oam.features.devicemanager.oran.test; import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; - import java.io.IOException; import org.junit.After; import org.junit.BeforeClass; @@ -29,57 +28,46 @@ import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServic 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.o.ran.hardware._1._0.rev190328.ORANHWCOMPONENT; -import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.network.topology.simulator.rev191025.SimulatorStatus; import org.opendaylight.yangtools.yang.common.QName; import org.oransc.oam.features.devicemanager.oran.impl.ORanNetworkElementFactory; import org.oransc.oam.features.devicemanager.oran.test.mock.NetconfAccessorMock; public class TestORanNetworkElementFactory { - static NetconfAccessor accessor; - static DeviceManagerServiceProvider serviceProvider; - static Capabilities capabilities; - QName qCapability; + static NetconfAccessor accessor; + static DeviceManagerServiceProvider serviceProvider; + static Capabilities capabilities; + QName qCapability; + + @BeforeClass + public static void init() throws InterruptedException, IOException { + capabilities = mock(Capabilities.class); + accessor = mock(NetconfAccessorMock.class); + serviceProvider = mock(DeviceManagerServiceProvider.class); + + when(accessor.getCapabilites()).thenReturn(capabilities); + when(serviceProvider.getDataProvider()).thenReturn(null); + - @BeforeClass - public static void init() throws InterruptedException, IOException { - capabilities = mock(Capabilities.class); - accessor = mock(NetconfAccessorMock.class); - serviceProvider = mock(DeviceManagerServiceProvider.class); - - when(accessor.getCapabilites()).thenReturn(capabilities); - when(serviceProvider.getDataProvider()).thenReturn(null); + } - - } + @Test + public void testCreateORANHWComponent() throws Exception { + when(accessor.getCapabilites().isSupportingNamespace(ORANHWCOMPONENT.QNAME)).thenReturn(true); + ORanNetworkElementFactory factory = new ORanNetworkElementFactory(); + assertTrue((factory.create(accessor, serviceProvider)).isPresent()); + } - @Test - public void testCreateORANHWComponent() throws Exception { - when(accessor.getCapabilites().isSupportingNamespace(ORANHWCOMPONENT.QNAME)).thenReturn(true); - when(accessor.getCapabilites().isSupportingNamespace(SimulatorStatus.QNAME)).thenReturn(false); - ORanNetworkElementFactory factory = new ORanNetworkElementFactory(); - assertTrue((factory.create(accessor, serviceProvider)).isPresent()); - } + @Test + public void testCreateNone() throws Exception { + when(accessor.getCapabilites().isSupportingNamespace(ORANHWCOMPONENT.QNAME)).thenReturn(false); + ORanNetworkElementFactory factory = new ORanNetworkElementFactory(); + assertTrue(!(factory.create(accessor, serviceProvider).isPresent())); + } - @Test - public void testCreateSimulator() throws Exception { - when(accessor.getCapabilites().isSupportingNamespace(ORANHWCOMPONENT.QNAME)).thenReturn(false); - when(accessor.getCapabilites().isSupportingNamespace(SimulatorStatus.QNAME)).thenReturn(true); - ORanNetworkElementFactory factory = new ORanNetworkElementFactory(); - assertTrue(factory.create(accessor, serviceProvider).isPresent()); - } - - @Test - public void testCreateNone() throws Exception { - when(accessor.getCapabilites().isSupportingNamespace(ORANHWCOMPONENT.QNAME)).thenReturn(false); - when(accessor.getCapabilites().isSupportingNamespace(SimulatorStatus.QNAME)).thenReturn(false); - ORanNetworkElementFactory factory = new ORanNetworkElementFactory(); - assertTrue(!(factory.create(accessor, serviceProvider).isPresent())); - } - - @After - public void cleanUp() throws Exception { + @After + public void cleanUp() throws Exception { - } + } } diff --git a/features/devicemanager/o-ran/ru-fh/provider/src/test/java/org/oransc/oam/features/devicemanager/oran/test/TestORanToInternalDataModel.java b/features/devicemanager/o-ran/ru-fh/provider/src/test/java/org/oransc/oam/features/devicemanager/oran/test/TestORanToInternalDataModel.java index 07cff9d..f35bcb4 100644 --- a/features/devicemanager/o-ran/ru-fh/provider/src/test/java/org/oransc/oam/features/devicemanager/oran/test/TestORanToInternalDataModel.java +++ b/features/devicemanager/o-ran/ru-fh/provider/src/test/java/org/oransc/oam/features/devicemanager/oran/test/TestORanToInternalDataModel.java @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================================== - * ONAP : ccsdk feature sdnr wt + * O-RAN-SC : oam/ccsdk feature sdnr wt * ================================================================================================= * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. All rights reserved. * ================================================================================================= @@ -20,13 +20,9 @@ package org.oransc.oam.features.devicemanager.oran.test; import static org.junit.Assert.assertEquals; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; - -import java.util.List; -import java.util.Optional; import java.io.IOException; import java.util.ArrayList; - -import org.eclipse.jdt.annotation.Nullable; +import java.util.List; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -37,50 +33,49 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types. import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid; import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; import org.oransc.oam.features.devicemanager.oran.impl.ORanToInternalDataModel; -import org.oransc.oam.features.devicemanager.oran.test.TestHardwareClass; public class TestORanToInternalDataModel { - NodeId nodeId; - Component component; + NodeId nodeId; + Component component; + + @SuppressWarnings("unchecked") + @Before + public void init() throws InterruptedException, IOException { + nodeId = mock(NodeId.class); + component = mock(Component.class); + + when(nodeId.getValue()).thenReturn("ORan-1000"); + when(component.getParent()).thenReturn("Shelf"); + when(component.getParentRelPos()).thenReturn(0); + when(component.getUuid()).thenReturn(new Uuid("0Aabcdef-0abc-0cfD-0abC-0123456789AB")); - @SuppressWarnings("unchecked") - @Before - public void init() throws InterruptedException, IOException { - nodeId = mock(NodeId.class); - component = mock(Component.class); + List list = new ArrayList(); + list.add("Card-01A"); + list.add("Card-01B"); - when(nodeId.getValue()).thenReturn("ORan-1000"); - when(component.getParent()).thenReturn("Shelf"); - when(component.getParentRelPos()).thenReturn(0); - when(component.getUuid()).thenReturn(new Uuid("0Aabcdef-0abc-0cfD-0abC-0123456789AB")); + when(component.getContainsChild()).thenReturn(list); + when(component.getName()).thenReturn("Nokia"); + when(component.getDescription()).thenReturn("ORAN Network Element NO-456"); + Class hwClass = TestHardwareClass.class; + Mockito.>when(component.getXmlClass()).thenReturn(hwClass); - List list = new ArrayList(); - list.add("Card-01A"); - list.add("Card-01B"); + DateAndTime dt = new DateAndTime("2020-02-05T12:30:45.283Z"); + when(component.getMfgDate()).thenReturn(dt); - when (component.getContainsChild()).thenReturn(list); - when (component.getName()).thenReturn("Nokia"); - when (component.getDescription()).thenReturn("ORAN Network Element NO-456"); - Class hwClass = TestHardwareClass.class; - Mockito.>when(component.getXmlClass()).thenReturn(hwClass); - - DateAndTime dt = new DateAndTime("2020-02-05T12:30:45.283Z"); - when (component.getMfgDate()).thenReturn(dt); - - } + } - @Test - public void test() throws Exception { - ORanToInternalDataModel model = new ORanToInternalDataModel(); - model.getInternalEquipment(nodeId, component); - assertEquals(component.getUuid().getValue(), "0Aabcdef-0abc-0cfD-0abC-0123456789AB"); - assertEquals(component.getMfgDate().getValue(), "2020-02-05T12:30:45.283Z"); + @Test + public void test() throws Exception { + ORanToInternalDataModel model = new ORanToInternalDataModel(); + model.getInternalEquipment(nodeId, component); + assertEquals(component.getUuid().getValue(), "0Aabcdef-0abc-0cfD-0abC-0123456789AB"); + assertEquals(component.getMfgDate().getValue(), "2020-02-05T12:30:45.283Z"); - } + } - @After - public void cleanUp() throws Exception { + @After + public void cleanUp() throws Exception { - } + } } diff --git a/features/devicemanager/o-ran/ru-fh/provider/src/test/java/org/oransc/oam/features/devicemanager/oran/test/mock/NetconfAccessorMock.java b/features/devicemanager/o-ran/ru-fh/provider/src/test/java/org/oransc/oam/features/devicemanager/oran/test/mock/NetconfAccessorMock.java index 84cae04..165ad0f 100644 --- a/features/devicemanager/o-ran/ru-fh/provider/src/test/java/org/oransc/oam/features/devicemanager/oran/test/mock/NetconfAccessorMock.java +++ b/features/devicemanager/o-ran/ru-fh/provider/src/test/java/org/oransc/oam/features/devicemanager/oran/test/mock/NetconfAccessorMock.java @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================================== - * ONAP : ccsdk feature sdnr wt + * O-RAN-SC : oam/ccsdk feature sdnr wt * ================================================================================================= * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. All rights reserved. * ================================================================================================= diff --git a/features/devicemanager/o-ran/ru-fh/provider/src/test/java/org/oransc/oam/features/devicemanager/oran/test/mock/TransactionUtilsMock.java b/features/devicemanager/o-ran/ru-fh/provider/src/test/java/org/oransc/oam/features/devicemanager/oran/test/mock/TransactionUtilsMock.java index cfd01d9..e07fce1 100644 --- a/features/devicemanager/o-ran/ru-fh/provider/src/test/java/org/oransc/oam/features/devicemanager/oran/test/mock/TransactionUtilsMock.java +++ b/features/devicemanager/o-ran/ru-fh/provider/src/test/java/org/oransc/oam/features/devicemanager/oran/test/mock/TransactionUtilsMock.java @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================================== - * ONAP : ccsdk feature sdnr wt + * O-RAN-SC : oam/ccsdk feature sdnr wt * ================================================================================================= * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. All rights reserved. * ================================================================================================= @@ -19,7 +19,6 @@ package org.oransc.oam.features.devicemanager.oran.test.mock; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicReference; - import org.eclipse.jdt.annotation.Nullable; import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.TransactionUtils; import org.opendaylight.mdsal.binding.api.DataBroker; @@ -29,19 +28,19 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; public class TransactionUtilsMock implements TransactionUtils { - @Override - public @Nullable T readData(DataBroker dataBroker, LogicalDatastoreType dataStoreType, - InstanceIdentifier iid) { - // TODO Auto-generated method stub - return null; - } + @Override + public @Nullable T readData(DataBroker dataBroker, LogicalDatastoreType dataStoreType, + InstanceIdentifier iid) { + // TODO Auto-generated method stub + return null; + } - @Override - public @Nullable T readDataOptionalWithStatus(DataBroker dataBroker, - LogicalDatastoreType dataStoreType, InstanceIdentifier iid, AtomicBoolean noErrorIndication, - AtomicReference statusIndicator) { - // TODO Auto-generated method stub - return null; - } + @Override + public @Nullable T readDataOptionalWithStatus(DataBroker dataBroker, + LogicalDatastoreType dataStoreType, InstanceIdentifier iid, AtomicBoolean noErrorIndication, + AtomicReference statusIndicator) { + // TODO Auto-generated method stub + return null; + } } -- 2.16.6