From 3a99817145131f356721aa16554db5766a97bcee Mon Sep 17 00:00:00 2001 From: Ravi Pendurty Date: Mon, 9 Aug 2021 16:14:00 +0530 Subject: Update Junit tests Also renamed java package for unit tests Issue-ID: CCSDK-3420 Change-Id: Ie932c8aad6d0c7496f5b96f7db40ab75e67c572a Signed-off-by: Ravi Pendurty --- .../openroadm71/impl/OpenroadmNetworkElement.java | 2 +- .../test/TestChangeNotificationListener.java | 92 ------ .../test/TestDeviceManagerOpenRoadmImpl.java | 54 ---- .../test/TestOpenRoadmAlarmNotification.java | 110 -------- .../TestOpenRoadmDeviceChangeNotification.java | 120 -------- .../openroadm/test/TestOpenRoadmInventory.java | 144 ---------- .../test/TestOpenRoadmNetworkElement.java | 310 -------------------- .../test/TestOpenRoadmNetworkElementFactory.java | 101 ------- .../openroadm/test/TestOpenRoadmPMDataBuilder.java | 221 --------------- .../test/TestOpenroadmNetworkElementBase.java | 62 ---- .../test/TestChangeNotificationListener.java | 92 ++++++ .../test/TestDeviceManagerOpenRoadmImpl.java | 54 ++++ .../test/TestOpenRoadmAlarmNotification.java | 110 ++++++++ .../TestOpenRoadmDeviceChangeNotification.java | 120 ++++++++ .../openroadm71/test/TestOpenRoadmInventory.java | 144 ++++++++++ .../test/TestOpenRoadmNetworkElement.java | 311 +++++++++++++++++++++ .../test/TestOpenRoadmNetworkElementFactory.java | 101 +++++++ .../test/TestOpenRoadmPMDataBuilder.java | 221 +++++++++++++++ .../test/TestOpenroadmNetworkElementBase.java | 62 ++++ 19 files changed, 1216 insertions(+), 1215 deletions(-) delete mode 100644 sdnr/wt/devicemanager-onap/openroadm71/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/test/TestChangeNotificationListener.java delete mode 100644 sdnr/wt/devicemanager-onap/openroadm71/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/test/TestDeviceManagerOpenRoadmImpl.java delete mode 100644 sdnr/wt/devicemanager-onap/openroadm71/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/test/TestOpenRoadmAlarmNotification.java delete mode 100644 sdnr/wt/devicemanager-onap/openroadm71/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/test/TestOpenRoadmDeviceChangeNotification.java delete mode 100644 sdnr/wt/devicemanager-onap/openroadm71/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/test/TestOpenRoadmInventory.java delete mode 100644 sdnr/wt/devicemanager-onap/openroadm71/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/test/TestOpenRoadmNetworkElement.java delete mode 100644 sdnr/wt/devicemanager-onap/openroadm71/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/test/TestOpenRoadmNetworkElementFactory.java delete mode 100644 sdnr/wt/devicemanager-onap/openroadm71/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/test/TestOpenRoadmPMDataBuilder.java delete mode 100644 sdnr/wt/devicemanager-onap/openroadm71/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/test/TestOpenroadmNetworkElementBase.java create mode 100644 sdnr/wt/devicemanager-onap/openroadm71/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm71/test/TestChangeNotificationListener.java create mode 100644 sdnr/wt/devicemanager-onap/openroadm71/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm71/test/TestDeviceManagerOpenRoadmImpl.java create mode 100644 sdnr/wt/devicemanager-onap/openroadm71/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm71/test/TestOpenRoadmAlarmNotification.java create mode 100644 sdnr/wt/devicemanager-onap/openroadm71/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm71/test/TestOpenRoadmDeviceChangeNotification.java create mode 100644 sdnr/wt/devicemanager-onap/openroadm71/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm71/test/TestOpenRoadmInventory.java create mode 100644 sdnr/wt/devicemanager-onap/openroadm71/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm71/test/TestOpenRoadmNetworkElement.java create mode 100644 sdnr/wt/devicemanager-onap/openroadm71/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm71/test/TestOpenRoadmNetworkElementFactory.java create mode 100644 sdnr/wt/devicemanager-onap/openroadm71/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm71/test/TestOpenRoadmPMDataBuilder.java create mode 100644 sdnr/wt/devicemanager-onap/openroadm71/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm71/test/TestOpenroadmNetworkElementBase.java (limited to 'sdnr') diff --git a/sdnr/wt/devicemanager-onap/openroadm71/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm71/impl/OpenroadmNetworkElement.java b/sdnr/wt/devicemanager-onap/openroadm71/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm71/impl/OpenroadmNetworkElement.java index 87fd14b72..180091718 100644 --- a/sdnr/wt/devicemanager-onap/openroadm71/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm71/impl/OpenroadmNetworkElement.java +++ b/sdnr/wt/devicemanager-onap/openroadm71/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm71/impl/OpenroadmNetworkElement.java @@ -62,7 +62,7 @@ import org.slf4j.LoggerFactory; public class OpenroadmNetworkElement extends OpenroadmNetworkElementBase { // variables - private final long EQUIPMENTLEVEL_BASE = 1; + private final long EQUIPMENTLEVEL_BASE = 0; private static final Logger LOG = LoggerFactory.getLogger(OpenroadmNetworkElement.class); private Hashtable circuitPacksRecord; private Hashtable shelfProvisionedcircuitPacks; diff --git a/sdnr/wt/devicemanager-onap/openroadm71/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/test/TestChangeNotificationListener.java b/sdnr/wt/devicemanager-onap/openroadm71/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/test/TestChangeNotificationListener.java deleted file mode 100644 index 1fb39864a..000000000 --- a/sdnr/wt/devicemanager-onap/openroadm71/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/test/TestChangeNotificationListener.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP : ccsdk features - * ================================================================================ - * 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.openroadm.test; - -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; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.openroadm71.impl.OpenroadmChangeNotificationListener; -import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor; -import org.onap.ccsdk.features.sdnr.wt.websocketmanager.model.WebsocketManagerService; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.base._1._0.rev110601.EditOperationType; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.NetconfConfigChange; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.netconf.config.change.Edit; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.netconf.config.change.EditBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.EventlogBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.EventlogEntity; -import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; -import org.opendaylight.yangtools.yang.binding.DataObject; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.PathArgument; - -public class TestChangeNotificationListener { - - private static final String NODEID = "node1"; - - @Test - public void test() { - - NetconfAccessor netconfAccessor = mock(NetconfAccessor.class); - DataProvider databaseService = mock(DataProvider.class); - WebsocketManagerService notificationService = mock(WebsocketManagerService.class); - OpenroadmChangeNotificationListener notifListener = - new OpenroadmChangeNotificationListener(netconfAccessor, databaseService, notificationService); - when(netconfAccessor.getNodeId()).thenReturn(new NodeId(NODEID)); - Iterable pathArguments = Arrays.asList(new PathArgument() { - - @Override - public int compareTo(PathArgument arg0) { - return 0; - } - - @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); - - } - - /** - * @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; - } -} diff --git a/sdnr/wt/devicemanager-onap/openroadm71/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/test/TestDeviceManagerOpenRoadmImpl.java b/sdnr/wt/devicemanager-onap/openroadm71/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/test/TestDeviceManagerOpenRoadmImpl.java deleted file mode 100644 index e9d58b486..000000000 --- a/sdnr/wt/devicemanager-onap/openroadm71/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/test/TestDeviceManagerOpenRoadmImpl.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP : ccsdk features - * ================================================================================ - * 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.openroadm.test; - -import static org.junit.Assert.assertNotNull; -import static org.mockito.Mockito.mock; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.openroadm71.impl.DeviceManagerOpenroadmImpl; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.NetconfNetworkElementService; - -public class TestDeviceManagerOpenRoadmImpl { - DeviceManagerOpenroadmImpl devMgrOpenRdmImpl; - NetconfNetworkElementService netcnfNtwrkElmntSrvc; - - @Before - public void init() { - netcnfNtwrkElmntSrvc = mock(NetconfNetworkElementService.class); - devMgrOpenRdmImpl = new DeviceManagerOpenroadmImpl(); - } - - @Test - public void test() throws Exception { - devMgrOpenRdmImpl.setNetconfNetworkElementService(netcnfNtwrkElmntSrvc); - assertNotNull(devMgrOpenRdmImpl); - - } - - @After - public void cleanUp() throws Exception { - devMgrOpenRdmImpl.close(); - } - -} diff --git a/sdnr/wt/devicemanager-onap/openroadm71/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/test/TestOpenRoadmAlarmNotification.java b/sdnr/wt/devicemanager-onap/openroadm71/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/test/TestOpenRoadmAlarmNotification.java deleted file mode 100644 index 674c9d0de..000000000 --- a/sdnr/wt/devicemanager-onap/openroadm71/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/test/TestOpenRoadmAlarmNotification.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP : ccsdk features - * ================================================================================ - * 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.openroadm.test; - -import static org.junit.Assert.assertEquals; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; -import java.io.IOException; -import org.eclipse.jdt.annotation.NonNull; -import org.junit.BeforeClass; -import org.junit.Test; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.openroadm71.impl.OpenroadmFaultNotificationListener; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.FaultService; -import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfBindingAccessor; -import org.onap.ccsdk.features.sdnr.wt.websocketmanager.model.WebsocketManagerService; -import org.opendaylight.yang.gen.v1.http.org.openroadm.alarm.rev200529.AlarmNotification; -import org.opendaylight.yang.gen.v1.http.org.openroadm.alarm.rev200529.Severity; -import org.opendaylight.yang.gen.v1.http.org.openroadm.alarm.rev200529.alarm.ProbableCause; -import org.opendaylight.yang.gen.v1.http.org.openroadm.alarm.rev200529.alarm.ProbableCauseBuilder; -import org.opendaylight.yang.gen.v1.http.org.openroadm.alarm.rev200529.alarm.Resource; -import org.opendaylight.yang.gen.v1.http.org.openroadm.alarm.rev200529.alarm.ResourceBuilder; -import org.opendaylight.yang.gen.v1.http.org.openroadm.common.node.types.rev191129.NodeIdType; -import org.opendaylight.yang.gen.v1.http.org.openroadm.probablecause.rev200529.ProbableCauseEnum; -import org.opendaylight.yang.gen.v1.http.org.openroadm.resource.rev200529.resource.Device; -import org.opendaylight.yang.gen.v1.http.org.openroadm.resource.rev200529.resource.DeviceBuilder; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime; -import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; - -public class TestOpenRoadmAlarmNotification { - private static final String myCircuitId = "Test_Id"; - private static final String myId = "Alarm_Id"; - DateAndTime myRaiseTime = new DateAndTime("2020-02-25T10:08:06.7Z"); - ProbableCause myProbableCause = - new ProbableCauseBuilder().setCause(ProbableCauseEnum.AutomaticLaserShutdown).build(); - Device device = new DeviceBuilder().setNodeId(NodeIdType.getDefaultInstance("zNhe2i5")).build(); - org.opendaylight.yang.gen.v1.http.org.openroadm.resource.rev200529.resource.resource.resource.CircuitPack resVal = - new org.opendaylight.yang.gen.v1.http.org.openroadm.resource.rev200529.resource.resource.resource.CircuitPackBuilder() - .setCircuitPackName("Slot-0-Port-A").build(); - org.opendaylight.yang.gen.v1.http.org.openroadm.resource.rev200529.resource.Resource affectedResource = - new org.opendaylight.yang.gen.v1.http.org.openroadm.resource.rev200529.resource.ResourceBuilder().setResource(resVal).build(); - Resource myResource = new ResourceBuilder().setResource(affectedResource).setDevice(device).build(); - - - static DeviceManagerServiceProvider serviceProvider; - static @NonNull FaultService faultService; - static AlarmNotification notification; - Severity severity; - static NetconfBindingAccessor accessor; - static WebsocketManagerService notificationService; - static NodeId nNodeId = new NodeId("nSky"); - @BeforeClass - public static void init() throws InterruptedException, IOException { - - accessor = mock(NetconfBindingAccessor.class); - serviceProvider = mock(DeviceManagerServiceProvider.class); - faultService = mock(FaultService.class); - notificationService = mock(WebsocketManagerService.class); - } - - - - @Test - public void testNotification() { - severity = Severity.Critical; - when(accessor.getNodeId()).thenReturn(nNodeId); - when(serviceProvider.getFaultService()).thenReturn(faultService); - when(serviceProvider.getWebsocketService()).thenReturn(notificationService); - OpenroadmFaultNotificationListener alarmListener = - new OpenroadmFaultNotificationListener(accessor, serviceProvider); - notification = mock(AlarmNotification.class); - - when(notification.getId()).thenReturn(myId); - when(notification.getCircuitId()).thenReturn(myCircuitId); - when(notification.getRaiseTime()).thenReturn(myRaiseTime); - when(notification.getProbableCause()).thenReturn(myProbableCause); - when(notification.getResource()).thenReturn(myResource); - when(notification.getSeverity()).thenReturn(severity); - alarmListener.onAlarmNotification(notification); - System.out.println(notification.getId()); - assertEquals(myId, notification.getId()); - assertEquals(myCircuitId, notification.getCircuitId()); - assertEquals(myRaiseTime, notification.getRaiseTime()); - assertEquals(myProbableCause, notification.getProbableCause()); - assertEquals(myResource, notification.getResource()); - assertEquals(severity, notification.getSeverity()); - - - } - -} diff --git a/sdnr/wt/devicemanager-onap/openroadm71/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/test/TestOpenRoadmDeviceChangeNotification.java b/sdnr/wt/devicemanager-onap/openroadm71/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/test/TestOpenRoadmDeviceChangeNotification.java deleted file mode 100644 index c3ef7d9ba..000000000 --- a/sdnr/wt/devicemanager-onap/openroadm71/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/test/TestOpenRoadmDeviceChangeNotification.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP : ccsdk features - * ================================================================================ - * 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.openroadm.test; - -import static org.mockito.ArgumentMatchers.any; -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; -import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.NetconfTimeStamp; -import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.types.NetconfTimeStampImpl; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.openroadm71.impl.OpenroadmDeviceChangeNotificationListener; -import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor; -import org.onap.ccsdk.features.sdnr.wt.websocketmanager.model.WebsocketManagerService; -import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev200529.RpcStatus; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.ChangeNotification; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.CreateTechInfoNotification; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.CreateTechInfoNotificationBuilder; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.change.notification.Edit; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.change.notification.EditBuilder; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.base._1._0.rev110601.EditOperationType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.EventlogBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.EventlogEntity; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.SourceType; -import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; -import org.opendaylight.yangtools.yang.binding.DataObject; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.PathArgument; - - - -public class TestOpenRoadmDeviceChangeNotification { - private static final String NODEID = "Roadm1"; - private NetconfAccessor netconfAccessor = mock(NetconfAccessor.class); - private DataProvider databaseService = mock(DataProvider.class); - WebsocketManagerService notificationService = mock(WebsocketManagerService.class); - private OpenroadmDeviceChangeNotificationListener deviceChangeListener = - new OpenroadmDeviceChangeNotificationListener(netconfAccessor, databaseService, notificationService); - private static final NetconfTimeStamp ncTimeConverter = NetconfTimeStampImpl.getConverter(); - - @Test - public void testOnChangeNotification() { - - when(netconfAccessor.getNodeId()).thenReturn(new NodeId(NODEID)); - Iterable pathArguments = Arrays.asList(new PathArgument() { - - @Override - public int compareTo(PathArgument arg0) { - return 0; - } - - @Override - public Class getType() { - return DataObject.class; - } - }); - InstanceIdentifier target = InstanceIdentifier.create(pathArguments); - - deviceChangeListener.onChangeNotification(createNotification(EditOperationType.Create, target)); - EventlogEntity event = - new EventlogBuilder().setNodeId(NODEID).setNewValue(String.valueOf(EditOperationType.Create)) - .setObjectId(target.getPathArguments().toString()).setCounter(1) - .setAttributeName(target.getTargetType().getName()).setSourceType(SourceType.Netconf).build(); - verify(databaseService).writeEventLog(event); - - } - - @Test - public void testOnCreateTechInfoNotification() { - when(netconfAccessor.getNodeId()).thenReturn(new NodeId(NODEID)); - deviceChangeListener.onCreateTechInfoNotification(createTechInfoNotification()); - verify(databaseService).writeEventLog(any(EventlogEntity.class)); - } - - /** - * @param type - * @return - */ - private static ChangeNotification createNotification(EditOperationType type, InstanceIdentifier target) { - ChangeNotification change = mock(ChangeNotification.class); - - @SuppressWarnings("null") - final @NonNull List edits = Arrays.asList(new EditBuilder().setOperation(type).setTarget(target).build()); - when(change.nonnullEdit()).thenReturn(edits); - return change; - } - - private static CreateTechInfoNotification createTechInfoNotification() { - CreateTechInfoNotificationBuilder techInfoNotificationBuilder = new CreateTechInfoNotificationBuilder(); - techInfoNotificationBuilder.setLogFileName("shjkdjld/EHJkk").setShelfId("dsjhdukdgkzw") - .setStatus(RpcStatus.Successful).setStatusMessage("TestSuccessful"); - return techInfoNotificationBuilder.build(); - - } - - -} diff --git a/sdnr/wt/devicemanager-onap/openroadm71/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/test/TestOpenRoadmInventory.java b/sdnr/wt/devicemanager-onap/openroadm71/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/test/TestOpenRoadmInventory.java deleted file mode 100644 index 22c9c11dd..000000000 --- a/sdnr/wt/devicemanager-onap/openroadm71/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/test/TestOpenRoadmInventory.java +++ /dev/null @@ -1,144 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP : ccsdk features - * ================================================================================ - * 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.openroadm.test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; -import org.junit.Test; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.openroadm71.impl.OpenroadmInventoryInput; -import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor; -import org.opendaylight.yang.gen.v1.http.org.openroadm.common.node.types.rev191129.NodeIdType; -import org.opendaylight.yang.gen.v1.http.org.openroadm.common.state.types.rev191129.LifecycleState; -import org.opendaylight.yang.gen.v1.http.org.openroadm.common.state.types.rev191129.State; -import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev200529.OpenroadmVersionType; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.circuit.packs.CircuitPacks; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.interfaces.grp.Interface; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.org.openroadm.device.container.OrgOpenroadmDevice; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.org.openroadm.device.container.org.openroadm.device.Info; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.org.openroadm.device.container.org.openroadm.device.InfoBuilder; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.org.openroadm.device.container.org.openroadm.device.Xponder; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.shelves.Shelves; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.types.rev191129.NodeTypes; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.types.rev191129.XpdrNodeTypes; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime; -import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; -import org.opendaylight.yangtools.yang.common.Uint16; -import org.opendaylight.yangtools.yang.common.Uint32; -import org.opendaylight.yangtools.yang.common.Uint8; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class TestOpenRoadmInventory { - private static final Logger LOG = LoggerFactory.getLogger(OpenroadmInventoryInput.class); - private NetconfAccessor accessor = mock(NetconfAccessor.class); - private long value1 = 1; - private IpAddress ipAddress = new IpAddress(new Ipv4Address("127.0.0.11")); - private NodeId nodeId = new NodeId("RoadmA2"); - private Info info = new InfoBuilder().setNodeId(NodeIdType.getDefaultInstance("zNhe2i5")).setClli("NodeB") - .setSerialId("0002").setModel("model2").setVendor("VendorA").setCurrentIpAddress(ipAddress) - .setCurrentIpAddress(ipAddress).setCurrentDefaultGateway(new IpAddress(new Ipv4Address("127.0.0.20"))) - .setCurrentDefaultGateway(new IpAddress(new Ipv4Address("127.0.0.20"))).setNodeType(NodeTypes.Rdm) - .setCurrentDatetime(new DateAndTime("2017-10-22T15:23:43Z")).setSoftwareVersion("swversion1234") - .setPrefixLength(Uint8.valueOf(28)).setMaxDegrees(Uint16.valueOf(2)).setMaxSrgs(Uint16.valueOf(3)) - .setMaxNumBin15minHistoricalPm(Uint16.valueOf(32)).setMaxNumBin24hourHistoricalPm(Uint16.valueOf(7)) - .setOpenroadmVersion(OpenroadmVersionType._20).build(); - - private OrgOpenroadmDevice device = mock(OrgOpenroadmDevice.class);; - private Shelves shelf = mock(Shelves.class); - private Interface interfaces = mock(Interface.class); - private CircuitPacks cp = mock(CircuitPacks.class); - private Xponder xpdr = mock(Xponder.class); - OpenroadmInventoryInput roadmInventory = new OpenroadmInventoryInput(accessor, device); - - @Test - public void TestDevice() { - when(accessor.getNodeId()).thenReturn(nodeId); - when(device.getInfo()).thenReturn(info); - - roadmInventory.getInventoryData(Uint32.valueOf(value1)); - assertEquals(info, device.getInfo()); - - } - - @Test - public void TestShelves() { - when(accessor.getNodeId()).thenReturn(nodeId); - when(device.getInfo()).thenReturn(info); - when(shelf.getShelfPosition()).thenReturn("10"); - when(shelf.getOperationalState()).thenReturn(State.InService); - when(shelf.getSerialId()).thenReturn("nodeid-1"); - when(shelf.getShelfName()).thenReturn("Shelf1"); - when(shelf.getShelfType()).thenReturn("Shelf"); - when(shelf.getClei()).thenReturn("1234567890"); - when(shelf.getVendor()).thenReturn("vendorA"); - when(shelf.getModel()).thenReturn("1"); - when(shelf.getHardwareVersion()).thenReturn("0.1"); - when(shelf.getManufactureDate()).thenReturn(new DateAndTime("2017-10-22T15:23:43Z")); - assertNotNull(roadmInventory.getShelvesInventory(shelf, Uint32.valueOf(value1 + 1))); - - LOG.info("Shelves test completed"); - - } - - @Test - public void TestCircuitPacks() { - when(accessor.getNodeId()).thenReturn(nodeId); - when(cp.getCircuitPackName()).thenReturn("1/0"); - when(cp.getVendor()).thenReturn("VendorA"); - when(cp.getModel()).thenReturn("Model1"); - when(cp.getSerialId()).thenReturn("46277sgh6"); - when(cp.getClei()).thenReturn("136268785"); - when(cp.getHardwareVersion()).thenReturn("0.1"); - when(cp.getType()).thenReturn("WSS"); - when(cp.getProductCode()).thenReturn("oooooo"); - when(cp.getCircuitPackMode()).thenReturn("inServiceMode"); - when(device.getInfo()).thenReturn(info); - assertNotNull(roadmInventory.getCircuitPackInventory(cp, Uint32.valueOf(value1 + 1))); - - } - - @Test - public void TestInterfaces() { - when(accessor.getNodeId()).thenReturn(nodeId); - when(interfaces.getName()).thenReturn("1GE-interface-1"); - when(interfaces.getDescription()).thenReturn("Ethernet Interface"); - when(interfaces.getSupportingCircuitPackName()).thenReturn("1/0"); - when(device.getInfo()).thenReturn(info); - assertNotNull(roadmInventory.getInterfacesInventory(interfaces, Uint32.valueOf(value1 + 2))); - } - - @Test - public void TestXponder() { - when(xpdr.getXpdrNumber()).thenReturn(Uint16.valueOf(1)); - when(xpdr.getXpdrType()).thenReturn(XpdrNodeTypes.Mpdr); - when(xpdr.getLifecycleState()).thenReturn(LifecycleState.Deployed); - when(accessor.getNodeId()).thenReturn(nodeId); - when(device.getInfo()).thenReturn(info); - assertNotNull(roadmInventory.getXponderInventory(xpdr, Uint32.valueOf(value1 + 1))); - - } - -} diff --git a/sdnr/wt/devicemanager-onap/openroadm71/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/test/TestOpenRoadmNetworkElement.java b/sdnr/wt/devicemanager-onap/openroadm71/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/test/TestOpenRoadmNetworkElement.java deleted file mode 100644 index 9304356e6..000000000 --- a/sdnr/wt/devicemanager-onap/openroadm71/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/test/TestOpenRoadmNetworkElement.java +++ /dev/null @@ -1,310 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP : ccsdk features - * ================================================================================ - * 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.openroadm.test; - -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.HashMap; -import java.util.Map; -import org.eclipse.jdt.annotation.Nullable; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; -import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.openroadm71.impl.OpenroadmInventoryInput; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.openroadm71.impl.OpenroadmNetworkElement; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.FaultService; -import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.Capabilities; -import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfBindingAccessor; -import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.TransactionUtils; -import org.opendaylight.mdsal.binding.api.DataBroker; -import org.opendaylight.mdsal.common.api.LogicalDatastoreType; -import org.opendaylight.yang.gen.v1.http.org.openroadm.alarm.rev200529.ActiveAlarmList; -import org.opendaylight.yang.gen.v1.http.org.openroadm.alarm.rev200529.Severity; -import org.opendaylight.yang.gen.v1.http.org.openroadm.alarm.rev200529.active.alarm.list.ActiveAlarms; -import org.opendaylight.yang.gen.v1.http.org.openroadm.alarm.rev200529.active.alarm.list.ActiveAlarmsKey; -import org.opendaylight.yang.gen.v1.http.org.openroadm.alarm.rev200529.alarm.ProbableCauseBuilder; -import org.opendaylight.yang.gen.v1.http.org.openroadm.alarm.rev200529.alarm.ResourceBuilder; -import org.opendaylight.yang.gen.v1.http.org.openroadm.common.node.types.rev191129.NodeIdType; -import org.opendaylight.yang.gen.v1.http.org.openroadm.common.state.types.rev191129.LifecycleState; -import org.opendaylight.yang.gen.v1.http.org.openroadm.common.state.types.rev191129.State; -import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev200529.OpenroadmVersionType; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.circuit.pack.ParentCircuitPack; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.circuit.packs.CircuitPacks; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.circuit.packs.CircuitPacksKey; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.interfaces.grp.Interface; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.interfaces.grp.InterfaceKey; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.org.openroadm.device.container.OrgOpenroadmDevice; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.org.openroadm.device.container.org.openroadm.device.Info; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.org.openroadm.device.container.org.openroadm.device.InfoBuilder; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.org.openroadm.device.container.org.openroadm.device.Xponder; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.org.openroadm.device.container.org.openroadm.device.XponderKey; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.shelf.Slots; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.shelf.SlotsKey; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.shelves.Shelves; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.shelves.ShelvesKey; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.types.rev191129.NodeTypes; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.types.rev191129.XpdrNodeTypes; -import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.rev200529.HistoricalPmList; -import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.rev200529.historical.pm.group.HistoricalPm; -import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.rev200529.historical.pm.group.HistoricalPmKey; -import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.rev200529.historical.pm.list.HistoricalPmEntry; -import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.rev200529.historical.pm.list.HistoricalPmEntryKey; -import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.rev200529.historical.pm.val.group.Measurement; -import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.rev200529.historical.pm.val.group.MeasurementKey; -import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.types.rev200327.PmDataType; -import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.types.rev200327.PmGranularity; -import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.types.rev200327.PmNamesEnum; -import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.types.rev200327.Validity; -import org.opendaylight.yang.gen.v1.http.org.openroadm.probablecause.rev200529.ProbableCauseEnum; -import org.opendaylight.yang.gen.v1.http.org.openroadm.resource.rev200529.resource.DeviceBuilder; -import org.opendaylight.yang.gen.v1.http.org.openroadm.resource.types.rev191129.ResourceTypeEnum; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime; -import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.common.Uint16; -import org.opendaylight.yangtools.yang.common.Uint32; -import org.opendaylight.yangtools.yang.common.Uint64; -import org.opendaylight.yangtools.yang.common.Uint8; - -public class TestOpenRoadmNetworkElement { - - NetconfBindingAccessor accessor = mock(NetconfBindingAccessor.class); - DeviceManagerServiceProvider serviceProvider = mock(DeviceManagerServiceProvider.class); - DataProvider dataprovider = mock(DataProvider.class); - Capabilities capabilities = mock(Capabilities.class); - TransactionUtils transactionUtils = mock(TransactionUtils.class); - DataBroker dataBroker = mock(DataBroker.class); - FaultService faultService = mock(FaultService.class); - OrgOpenroadmDevice device; - OpenroadmInventoryInput inventoryData; - long level = 1; - private Shelves shelf = mock(Shelves.class); - private @Nullable Map shelfList; - private CircuitPacks cp, cp1, cp2, cp3; - private Interface interfaces = mock(Interface.class); - private Xponder xpdr = mock(Xponder.class); - private IpAddress ipAddress = new IpAddress(new Ipv4Address("127.0.0.11")); - private Info info = new InfoBuilder().setNodeId(NodeIdType.getDefaultInstance("zNhe2i5")).setClli("NodeB") - .setSerialId("0002").setModel("model2").setVendor("VendorA").setCurrentIpAddress(ipAddress) - .setCurrentIpAddress(ipAddress).setCurrentDefaultGateway(new IpAddress(new Ipv4Address("127.0.0.20"))) - .setCurrentDefaultGateway(new IpAddress(new Ipv4Address("127.0.0.20"))).setNodeType(NodeTypes.Rdm) - .setCurrentDatetime(new DateAndTime("2017-10-22T15:23:43Z")).setSoftwareVersion("swversion1234") - .setCurrentPrefixLength(Uint8.valueOf(45)).setMaxDegrees(Uint16.valueOf(56)).setMaxSrgs(Uint16.valueOf(251)) - .setMaxNumBin15minHistoricalPm(Uint16.valueOf(324)).setMaxNumBin24hourHistoricalPm(Uint16.valueOf(142)) - .setOpenroadmVersion(OpenroadmVersionType._20).build(); - private ActiveAlarmList alarmList = mock(ActiveAlarmList.class); - private ActiveAlarms activeAlarms = mock(ActiveAlarms.class); - private HistoricalPmList pmDataList = mock(HistoricalPmList.class); - private HistoricalPm historicalPm = mock(HistoricalPm.class); - - @Before - public void init() { - when(accessor.getCapabilites()).thenReturn(capabilities); - when(serviceProvider.getFaultService()).thenReturn(faultService); - when(serviceProvider.getDataProvider()).thenReturn(dataprovider); - NodeId nNodeId = new NodeId("RoadmA"); - when(accessor.getNodeId()).thenReturn(nNodeId); - when(accessor.getDataBroker()).thenReturn(dataBroker); - when(accessor.getTransactionUtils()).thenReturn(transactionUtils); - when(accessor.getCapabilites().isSupportingNamespaceAndRevision(OrgOpenroadmDevice.QNAME)).thenReturn(true); - final Class openRoadmDev = OrgOpenroadmDevice.class; - // Reading data from device - InstanceIdentifier deviceId = InstanceIdentifier.create(openRoadmDev); - device = mock(OrgOpenroadmDevice.class); - when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL, - deviceId)).thenReturn(device); - - when(device.getInfo()).thenReturn(info); - inventoryData = new OpenroadmInventoryInput(accessor, device); - // Reading the shelfs data; - when(shelf.getShelfPosition()).thenReturn("10"); - when(shelf.getOperationalState()).thenReturn(State.InService); - when(shelf.getSerialId()).thenReturn("nodeid-1"); - when(shelf.getShelfName()).thenReturn("Shelf1"); - when(shelf.getShelfType()).thenReturn("Shelf"); - when(shelf.getClei()).thenReturn("1234567890"); - when(shelf.getVendor()).thenReturn("vendorA"); - when(shelf.getModel()).thenReturn("1"); - when(shelf.getHardwareVersion()).thenReturn("0.1"); - when(shelf.getManufactureDate()).thenReturn(new DateAndTime("2017-10-22T15:23:43Z")); - @Nullable - Map slotList = null; - Slots slots = mock(Slots.class); - when(slots.getLabel()).thenReturn("Slot56746"); - when(slots.getSlotName()).thenReturn("slotofRoadmA"); - when(slots.getProvisionedCircuitPack()).thenReturn("1/0"); - slotList = new HashMap<>(); - slotList.put(slots.key(), slots); - when(shelf.getSlots()).thenReturn(slotList); - shelfList = new HashMap<>(); - shelfList.put(shelf.key(), shelf); - when(device.getShelves()).thenReturn(shelfList); - - // Reading data from CircuitPacks - cp = mock(CircuitPacks.class); - when(cp.getCircuitPackName()).thenReturn("1/0"); - when(cp.getVendor()).thenReturn("VendorA"); - when(cp.getModel()).thenReturn("Model1"); - when(cp.getSerialId()).thenReturn("46277sgh6"); - when(cp.getClei()).thenReturn("136268785"); - when(cp.getHardwareVersion()).thenReturn("0.1"); - when(cp.getType()).thenReturn("WSS"); - when(cp.getProductCode()).thenReturn("oooooo"); - when(cp.getCircuitPackMode()).thenReturn("inServiceMode"); - - ParentCircuitPack parentCp = mock(ParentCircuitPack.class); - when(parentCp.getCircuitPackName()).thenReturn("1/0"); - when(parentCp.getCpSlotName()).thenReturn("Slot1"); - cp1 = mock(CircuitPacks.class); - when(cp1.getCircuitPackName()).thenReturn("1/0 EThernet"); - when(cp1.getVendor()).thenReturn("VendorA"); - when(cp1.getModel()).thenReturn("Model1678"); - when(cp1.getSerialId()).thenReturn("4627dgs7sgh6"); - when(cp1.getClei()).thenReturn("1362d68785"); - when(cp1.getHardwareVersion()).thenReturn("0.1"); - when(cp1.getType()).thenReturn("EthPlug"); - when(cp1.getProductCode()).thenReturn("oooooo"); - when(cp1.getCircuitPackMode()).thenReturn("inServiceMode"); - when(cp1.getParentCircuitPack()).thenReturn(parentCp); - - cp2 = mock(CircuitPacks.class); - when(cp2.getCircuitPackName()).thenReturn("2/0"); - when(cp2.getVendor()).thenReturn("VendorA"); - when(cp2.getModel()).thenReturn("Model1678"); - when(cp2.getSerialId()).thenReturn("4sads7sgh6"); - when(cp2.getClei()).thenReturn("1wew362d68785"); - when(cp2.getHardwareVersion()).thenReturn("0.1"); - when(cp2.getType()).thenReturn("WSS"); - when(cp2.getProductCode()).thenReturn("osooooo"); - when(cp2.getCircuitPackMode()).thenReturn("inServiceMode"); - - cp3 = mock(CircuitPacks.class); - when(parentCp.getCircuitPackName()).thenReturn("2/0"); - when(parentCp.getCpSlotName()).thenReturn("Slot1"); - when(cp3.getCircuitPackName()).thenReturn("2/0 OCS"); - when(cp3.getVendor()).thenReturn("VendorA"); - when(cp3.getModel()).thenReturn("Model1678"); - when(cp3.getSerialId()).thenReturn("dswsads7sgh6"); - when(cp3.getClei()).thenReturn("1ew62d68785"); - when(cp3.getHardwareVersion()).thenReturn("0.1"); - when(cp3.getType()).thenReturn("OCS Plug"); - when(cp3.getProductCode()).thenReturn("osooooo"); - when(cp3.getCircuitPackMode()).thenReturn("inServiceMode"); - when(cp3.getParentCircuitPack()).thenReturn(parentCp); - @Nullable - Map cpList = new HashMap<>(); - cpList.put(cp.key(), cp); - cpList.put(cp1.key(), cp1); - cpList.put(cp2.key(), cp2); - cpList.put(cp3.key(), cp3); - when(device.getCircuitPacks()).thenReturn(cpList); - - // Reading Interface Data - when(interfaces.getName()).thenReturn("1GE-interface-1"); - when(interfaces.getDescription()).thenReturn("Ethernet Interface"); - when(interfaces.getSupportingCircuitPackName()).thenReturn("1/0 EThernet"); - @Nullable - Map interfacesList = new HashMap<>(); - interfacesList.put(interfaces.key(), interfaces); - when(device.getInterface()).thenReturn(interfacesList); - - // Reading Xponder Data - when(xpdr.getXpdrNumber()).thenReturn(Uint16.valueOf(1)); - when(xpdr.getXpdrType()).thenReturn(XpdrNodeTypes.Mpdr); - when(xpdr.getLifecycleState()).thenReturn(LifecycleState.Deployed); - @Nullable - Map xpnderList = new HashMap<>(); - xpnderList.put(xpdr.key(), xpdr); - when(device.getXponder()).thenReturn(xpnderList); - - // Read initial Alarm data - final Class classAlarm = ActiveAlarmList.class; - InstanceIdentifier alarmDataIid = InstanceIdentifier.builder(classAlarm).build(); - when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL, - alarmDataIid)).thenReturn(alarmList); - when(activeAlarms.getId()).thenReturn("Alarm1"); - when(activeAlarms.getCircuitId()).thenReturn("1/0"); - when(activeAlarms.getRaiseTime()).thenReturn(new DateAndTime("2017-10-22T15:23:43Z")); - when(activeAlarms.getSeverity()).thenReturn(Severity.Critical); - when(activeAlarms.getProbableCause()) - .thenReturn(new ProbableCauseBuilder().setCause(ProbableCauseEnum.AutomaticLaserShutdown).build()); - when(activeAlarms.getAdditionalDetail()).thenReturn("LaserShutdown"); - when(activeAlarms.getResource()).thenReturn(new ResourceBuilder() - .setDevice(new DeviceBuilder().setNodeId(NodeIdType.getDefaultInstance("zNhe2i5")).build()).build()); - @Nullable - Map activeAlarmlist = new HashMap<>(); - activeAlarmlist.put(activeAlarms.key(), activeAlarms); - when(alarmList.getActiveAlarms()).thenReturn(activeAlarmlist); - - // Read PM Data - final Class pmDataClass = HistoricalPmList.class; - InstanceIdentifier pmDataIid = InstanceIdentifier.builder(pmDataClass).build(); - when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL, - pmDataIid)).thenReturn(pmDataList); - - Measurement measurement = mock(Measurement.class); - PmDataType pmDataType = mock(PmDataType.class); - when(pmDataType.getUint64()).thenReturn(Uint64.valueOf(2425425)); - when(measurement.getBinNumber()).thenReturn(Uint16.valueOf(1452)); - when(measurement.getCompletionTime()).thenReturn(new DateAndTime("2018-10-22T15:23:43Z")); - when(measurement.getGranularity()).thenReturn(PmGranularity._24Hour); - when(measurement.getPmParameterUnit()).thenReturn("6824545199534863756"); - when(measurement.getPmParameterValue()).thenReturn(pmDataType); - when(measurement.getValidity()).thenReturn(Validity.Partial); - - @Nullable - Map measurementList = new HashMap<>(); - measurementList.put(measurement.key(), measurement); - when(historicalPm.getMeasurement()).thenReturn(measurementList); - when(historicalPm.getType()).thenReturn(PmNamesEnum.ErroredSeconds); - when(historicalPm.getExtension()).thenReturn("OpticalPowerOutput"); - @Nullable - Map historicalPmList = new HashMap<>(); - historicalPmList.put(historicalPm.key(), historicalPm); - HistoricalPmEntry histPmEntry = mock(HistoricalPmEntry.class); - when(histPmEntry.getHistoricalPm()).thenReturn(historicalPmList); - when(histPmEntry.getPmResourceType()).thenReturn(ResourceTypeEnum.CircuitPack); - @Nullable - Map histPmList = new HashMap<>(); - histPmList.put(histPmEntry.key(), histPmEntry); - when(pmDataList.getHistoricalPmEntry()).thenReturn(histPmList); - - } - - - - @Ignore - @Test - public void test() { - OpenroadmNetworkElement optionalNe = new OpenroadmNetworkElement(accessor, serviceProvider); - optionalNe.initialReadFromNetworkElement(); - verify(dataprovider).writeInventory(accessor.getNodeId().getValue(), - Arrays.asList(inventoryData.getInventoryData(Uint32.valueOf(1)))); - } - -} diff --git a/sdnr/wt/devicemanager-onap/openroadm71/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/test/TestOpenRoadmNetworkElementFactory.java b/sdnr/wt/devicemanager-onap/openroadm71/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/test/TestOpenRoadmNetworkElementFactory.java deleted file mode 100644 index bcf2bf71f..000000000 --- a/sdnr/wt/devicemanager-onap/openroadm71/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/test/TestOpenRoadmNetworkElementFactory.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP : ccsdk features - * ================================================================================ - * 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.openroadm.test; - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; -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.devicemanager.openroadm71.impl.OpenroadmNetworkElementFactory; -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.NetconfBindingAccessor; -import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.TransactionUtils; -import org.opendaylight.mdsal.binding.api.DataBroker; -import org.opendaylight.mdsal.common.api.LogicalDatastoreType; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.org.openroadm.device.container.OrgOpenroadmDevice; -import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; - -public class TestOpenRoadmNetworkElementFactory { - - private static NetconfBindingAccessor accessor; - private static DeviceManagerServiceProvider serviceProvider; - private static Capabilities capabilities; - private static TransactionUtils transactionUtils; - private static DataBroker dataBroker; - - @BeforeClass - public static void init() throws InterruptedException, IOException { - accessor = mock(NetconfBindingAccessor.class); - capabilities = mock(Capabilities.class); - dataBroker = mock(DataBroker.class); - transactionUtils = mock(TransactionUtils.class); - serviceProvider = mock(DeviceManagerServiceProvider.class); - when(accessor.getNodeId()).thenReturn(new NodeId("RoadmA2")); - when(accessor.getCapabilites()).thenReturn(capabilities); - when(accessor.getDataBroker()).thenReturn(dataBroker); - when(accessor.getTransactionUtils()).thenReturn(transactionUtils); - when(accessor.getNetconfBindingAccessor()).thenReturn(Optional.of(accessor)); - when(serviceProvider.getDataProvider()).thenReturn(null); - - final Class openRoadmDev = OrgOpenroadmDevice.class; - InstanceIdentifier deviceId = InstanceIdentifier.create(openRoadmDev); - when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL, - deviceId)).thenReturn(mock(OrgOpenroadmDevice.class)); - - when(accessor.getTransactionUtils()).thenReturn(mock(TransactionUtils.class)); - } - - @Test - public void testCapabiltiesAvailable1() { - when(accessor.getCapabilites().isSupportingNamespaceAndRevision(OrgOpenroadmDevice.QNAME)).thenReturn(true); - OpenroadmNetworkElementFactory factory = new OpenroadmNetworkElementFactory(); - assertTrue((factory.create(accessor, serviceProvider)).isPresent()); - } - - @Test - public void testCapabiltiesAvailable2() { - when(accessor.getCapabilites().isSupportingNamespaceAndRevision("http://org/openroadm/device", "2018-10-19")) - .thenReturn(true); - OpenroadmNetworkElementFactory factory = new OpenroadmNetworkElementFactory(); - assertTrue((factory.create(accessor, serviceProvider)).isPresent()); - } - - @Test - public void testCapabiltiesNotAvailable() throws Exception { - when(accessor.getCapabilites().isSupportingNamespaceAndRevision(OrgOpenroadmDevice.QNAME)).thenReturn(false); - OpenroadmNetworkElementFactory factory = new OpenroadmNetworkElementFactory(); - assertFalse(factory.create(accessor, serviceProvider).isPresent()); - } - - @After - public void cleanUp() throws Exception { - - } - -} diff --git a/sdnr/wt/devicemanager-onap/openroadm71/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/test/TestOpenRoadmPMDataBuilder.java b/sdnr/wt/devicemanager-onap/openroadm71/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/test/TestOpenRoadmPMDataBuilder.java deleted file mode 100644 index cb58410fe..000000000 --- a/sdnr/wt/devicemanager-onap/openroadm71/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/test/TestOpenRoadmPMDataBuilder.java +++ /dev/null @@ -1,221 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP : ccsdk features - * ================================================================================ - * 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.openroadm.test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import org.eclipse.jdt.annotation.NonNull; -import org.junit.Before; -import org.junit.Test; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.openroadm71.impl.PmDataBuilderOpenRoadm; -import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfBindingAccessor; -import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.TransactionUtils; -import org.opendaylight.mdsal.binding.api.DataBroker; -import org.opendaylight.mdsal.common.api.LogicalDatastoreType; -import org.opendaylight.yang.gen.v1.http.org.openroadm.common.alarm.pm.types.rev191129.Direction; -import org.opendaylight.yang.gen.v1.http.org.openroadm.common.alarm.pm.types.rev191129.Location; -import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.rev200529.HistoricalPmList; -import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.rev200529.historical.pm.group.HistoricalPm; -import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.rev200529.historical.pm.group.HistoricalPmBuilder; -import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.rev200529.historical.pm.group.HistoricalPmKey; -import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.rev200529.historical.pm.list.HistoricalPmEntry; -import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.rev200529.historical.pm.list.HistoricalPmEntryBuilder; -import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.rev200529.historical.pm.list.HistoricalPmEntryKey; -import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.rev200529.historical.pm.val.group.Measurement; -import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.rev200529.historical.pm.val.group.MeasurementBuilder; -import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.rev200529.historical.pm.val.group.MeasurementKey; -import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.types.rev200327.PmDataType; -import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.types.rev200327.PmGranularity; -import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.types.rev200327.PmNamesEnum; -import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.types.rev200327.Validity; -import org.opendaylight.yang.gen.v1.http.org.openroadm.resource.types.rev191129.ResourceTypeEnum; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.Pmdata15mEntity; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.units.rev200413.Celsius; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.units.rev200413.PerformanceMeasurementUnitId; -import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; -import org.opendaylight.yangtools.yang.binding.DataObject; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.PathArgument; -import org.opendaylight.yangtools.yang.common.Uint16; -import org.opendaylight.yangtools.yang.common.Uint64; - - -public class TestOpenRoadmPMDataBuilder { - // variables - // end of variables - private NetconfBindingAccessor acessor = mock(NetconfBindingAccessor.class); - private DataBroker dataBroker = mock(DataBroker.class); - private TransactionUtils transactionUtils = mock(TransactionUtils.class); - // String nodeId = "RdmA"; - private PmDataBuilderOpenRoadm pmDataBuilderORoadm; - private NodeId nodeId = new NodeId("RoadmA"); - private HistoricalPmList historicalPmDatalist = mock(HistoricalPmList.class); - private HistoricalPm historicalPm = mock(HistoricalPm.class); - private PmDataType pmDataType = new PmDataType(Uint64.valueOf(67508)); - private MeasurementBuilder measurementBuilder = new MeasurementBuilder(); - private HistoricalPmBuilder historicalPmBuilder = new HistoricalPmBuilder(); - private HistoricalPmEntryBuilder historicalPmEntryBuiler = new HistoricalPmEntryBuilder(); - private List> performanceMeasUnitList = - new ArrayList>(); - private Map measurementData = new HashMap(); - private Map historicalPMCollection = new HashMap(); - private Map historicalPmEntryCollection = - new HashMap(); - - - - // public methods - @Before - public void init() { - when(acessor.getDataBroker()).thenReturn(dataBroker); - when(acessor.getTransactionUtils()).thenReturn(transactionUtils); - - - - } - - @Test - public void testGetPmData() { - when(acessor.getNodeId()).thenReturn(nodeId); - pmDataBuilderORoadm = new PmDataBuilderOpenRoadm(acessor); - - final Class pmDataClass = HistoricalPmList.class; - InstanceIdentifier pmDataListId = InstanceIdentifier.builder(pmDataClass).build(); - when(acessor.getTransactionUtils().readData(acessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL, - pmDataListId)).thenReturn(historicalPmDatalist); - - assertEquals(historicalPmDatalist,pmDataBuilderORoadm.getPmData(acessor)); - - } - - @Test - public void testBuildPmDataEntity() { - when(acessor.getNodeId()).thenReturn(nodeId); - pmDataBuilderORoadm = new PmDataBuilderOpenRoadm(acessor); - - performanceMeasUnitList.add(Celsius.class); - measurementBuilder.setBinNumber(Uint16.valueOf(24657)) - .setCompletionTime(new DateAndTime("2020-10-22T15:23:43Z")).setGranularity(PmGranularity._24Hour) - .setPmParameterUnit("dBm").setPmParameterValue(pmDataType).setValidity(Validity.Suspect); - - measurementData.put(measurementBuilder.key(), measurementBuilder.build()); - historicalPmBuilder.setType(PmNamesEnum.SeverelyErroredSeconds).setDirection(Direction.Bidirectional) - .setExtension("sajhsiwiduwugdhegdeuz").setLocation(Location.NearEnd).setMeasurement(measurementData); - when(historicalPm.getMeasurement()).thenReturn(measurementData); - - historicalPMCollection.put(historicalPmBuilder.key(), historicalPmBuilder.build()); - PathArgument pa =new PathArgument() { - - @Override - public int compareTo(PathArgument o) { - // TODO Auto-generated method stub - return 0; - } - - @Override - public @NonNull Class getType() { - // TODO Auto-generated method stub - return Pmdata15mEntity.class; - } - }; - historicalPmEntryBuiler.setPmResourceInstance(InstanceIdentifier.create(Arrays.asList(pa))) - .setPmResourceTypeExtension("dshjdekjdewkk") - .setPmResourceType(ResourceTypeEnum.CircuitPack).setHistoricalPm(historicalPMCollection); - - historicalPmEntryCollection.put(historicalPmEntryBuiler.key(), historicalPmEntryBuiler.build()); - when(historicalPmDatalist.getHistoricalPmEntry()).thenReturn(historicalPmEntryCollection); - - assertNotNull(pmDataBuilderORoadm.buildPmDataEntity(historicalPmDatalist)); - } - @Test - public void testBuildPmDataEntity1() { - when(acessor.getNodeId()).thenReturn(nodeId); - pmDataBuilderORoadm = new PmDataBuilderOpenRoadm(acessor); - - performanceMeasUnitList.add(Celsius.class); - measurementBuilder.setBinNumber(Uint16.valueOf(24657)) - .setCompletionTime(new DateAndTime("2020-10-22T15:23:43Z")).setGranularity(PmGranularity._15min) - .setPmParameterUnit("celsius").setPmParameterValue(pmDataType).setValidity(Validity.Suspect); - - measurementData.put(measurementBuilder.key(), measurementBuilder.build()); - historicalPmBuilder.setType(PmNamesEnum.ErroredSeconds).setDirection(Direction.Rx) - .setExtension("sajhsiwiduwugdhegdeuz").setLocation(Location.FarEnd).setMeasurement(measurementData); - when(historicalPm.getMeasurement()).thenReturn(measurementData); - PathArgument pa =new PathArgument() { - - @Override - public int compareTo(PathArgument o) { - // TODO Auto-generated method stub - return 0; - } - - @Override - public Class getType() { - // TODO Auto-generated method stub - return Pmdata15mEntity.class; - } - }; - historicalPMCollection.put(historicalPmBuilder.key(), historicalPmBuilder.build()); - historicalPmEntryBuiler.setPmResourceInstance(InstanceIdentifier.create(Arrays.asList(pa))) - .setPmResourceTypeExtension("dshjdekjdewkk") - .setPmResourceType(ResourceTypeEnum.Device).setHistoricalPm(historicalPMCollection); - - historicalPmEntryCollection.put(historicalPmEntryBuiler.key(), historicalPmEntryBuiler.build()); - when(historicalPmDatalist.getHistoricalPmEntry()).thenReturn(historicalPmEntryCollection); - - assertNotNull(pmDataBuilderORoadm.buildPmDataEntity(historicalPmDatalist)); - } - // end of public methods - - - // constants - // end of constants - - // variables - // end of variables - - // constructors - // end of constructors - - // getters and setters - // end of getters and setters - - // private methods - // end of private methods - - - // end of public methods - - // static methods - // end of static methods - - // private classes - // end of private classes -} diff --git a/sdnr/wt/devicemanager-onap/openroadm71/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/test/TestOpenroadmNetworkElementBase.java b/sdnr/wt/devicemanager-onap/openroadm71/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/test/TestOpenroadmNetworkElementBase.java deleted file mode 100644 index e3ebac605..000000000 --- a/sdnr/wt/devicemanager-onap/openroadm71/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/test/TestOpenroadmNetworkElementBase.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP : ccsdk features - * ================================================================================ - * 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.openroadm.test; - -import static org.junit.Assert.assertNotNull; -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.dataprovider.model.DataProvider; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.openroadm71.impl.OpenroadmNetworkElementBase; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider; -import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfBindingAccessor; -import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; -public class TestOpenroadmNetworkElementBase { - // variables - private NetconfBindingAccessor netconfAccessor = mock(NetconfBindingAccessor.class); - private DeviceManagerServiceProvider deviceManagerSvcProvider = mock(DeviceManagerServiceProvider.class); - private DataProvider databaseService = mock(DataProvider.class); - private NodeId nodeId = new NodeId("RoadmA"); - private OpenroadmNetworkElementBase openRoadmNetElementBase = new OpenroadmNetworkElementBase(netconfAccessor,deviceManagerSvcProvider); - // end of variables - - // public methods - @Before - public void init() { - - when(netconfAccessor.getNodeId()).thenReturn(nodeId); - - } - - @Test - public void testGetNodeId() { - assertNotNull(openRoadmNetElementBase.getNodeId()); - - } - - @Test - public void testGetDeviceType() { - assertNotNull(openRoadmNetElementBase.getDeviceType()); - } - -} diff --git a/sdnr/wt/devicemanager-onap/openroadm71/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm71/test/TestChangeNotificationListener.java b/sdnr/wt/devicemanager-onap/openroadm71/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm71/test/TestChangeNotificationListener.java new file mode 100644 index 000000000..f7732c7af --- /dev/null +++ b/sdnr/wt/devicemanager-onap/openroadm71/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm71/test/TestChangeNotificationListener.java @@ -0,0 +1,92 @@ +/* + * ============LICENSE_START======================================================= + * ONAP : ccsdk features + * ================================================================================ + * 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.openroadm71.test; + +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; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.openroadm71.impl.OpenroadmChangeNotificationListener; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor; +import org.onap.ccsdk.features.sdnr.wt.websocketmanager.model.WebsocketManagerService; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.base._1._0.rev110601.EditOperationType; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.NetconfConfigChange; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.netconf.config.change.Edit; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.netconf.config.change.EditBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.EventlogBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.EventlogEntity; +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; +import org.opendaylight.yangtools.yang.binding.DataObject; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.PathArgument; + +public class TestChangeNotificationListener { + + private static final String NODEID = "node1"; + + @Test + public void test() { + + NetconfAccessor netconfAccessor = mock(NetconfAccessor.class); + DataProvider databaseService = mock(DataProvider.class); + WebsocketManagerService notificationService = mock(WebsocketManagerService.class); + OpenroadmChangeNotificationListener notifListener = + new OpenroadmChangeNotificationListener(netconfAccessor, databaseService, notificationService); + when(netconfAccessor.getNodeId()).thenReturn(new NodeId(NODEID)); + Iterable pathArguments = Arrays.asList(new PathArgument() { + + @Override + public int compareTo(PathArgument arg0) { + return 0; + } + + @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); + + } + + /** + * @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; + } +} diff --git a/sdnr/wt/devicemanager-onap/openroadm71/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm71/test/TestDeviceManagerOpenRoadmImpl.java b/sdnr/wt/devicemanager-onap/openroadm71/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm71/test/TestDeviceManagerOpenRoadmImpl.java new file mode 100644 index 000000000..671bd4a18 --- /dev/null +++ b/sdnr/wt/devicemanager-onap/openroadm71/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm71/test/TestDeviceManagerOpenRoadmImpl.java @@ -0,0 +1,54 @@ +/* + * ============LICENSE_START======================================================= + * ONAP : ccsdk features + * ================================================================================ + * 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.openroadm71.test; + +import static org.junit.Assert.assertNotNull; +import static org.mockito.Mockito.mock; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.openroadm71.impl.DeviceManagerOpenroadmImpl; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.NetconfNetworkElementService; + +public class TestDeviceManagerOpenRoadmImpl { + DeviceManagerOpenroadmImpl devMgrOpenRdmImpl; + NetconfNetworkElementService netcnfNtwrkElmntSrvc; + + @Before + public void init() { + netcnfNtwrkElmntSrvc = mock(NetconfNetworkElementService.class); + devMgrOpenRdmImpl = new DeviceManagerOpenroadmImpl(); + } + + @Test + public void test() throws Exception { + devMgrOpenRdmImpl.setNetconfNetworkElementService(netcnfNtwrkElmntSrvc); + assertNotNull(devMgrOpenRdmImpl); + + } + + @After + public void cleanUp() throws Exception { + devMgrOpenRdmImpl.close(); + } + +} diff --git a/sdnr/wt/devicemanager-onap/openroadm71/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm71/test/TestOpenRoadmAlarmNotification.java b/sdnr/wt/devicemanager-onap/openroadm71/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm71/test/TestOpenRoadmAlarmNotification.java new file mode 100644 index 000000000..b9206deea --- /dev/null +++ b/sdnr/wt/devicemanager-onap/openroadm71/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm71/test/TestOpenRoadmAlarmNotification.java @@ -0,0 +1,110 @@ +/* + * ============LICENSE_START======================================================= + * ONAP : ccsdk features + * ================================================================================ + * 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.openroadm71.test; + +import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; +import java.io.IOException; +import org.eclipse.jdt.annotation.NonNull; +import org.junit.BeforeClass; +import org.junit.Test; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.openroadm71.impl.OpenroadmFaultNotificationListener; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.FaultService; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfBindingAccessor; +import org.onap.ccsdk.features.sdnr.wt.websocketmanager.model.WebsocketManagerService; +import org.opendaylight.yang.gen.v1.http.org.openroadm.alarm.rev200529.AlarmNotification; +import org.opendaylight.yang.gen.v1.http.org.openroadm.alarm.rev200529.Severity; +import org.opendaylight.yang.gen.v1.http.org.openroadm.alarm.rev200529.alarm.ProbableCause; +import org.opendaylight.yang.gen.v1.http.org.openroadm.alarm.rev200529.alarm.ProbableCauseBuilder; +import org.opendaylight.yang.gen.v1.http.org.openroadm.alarm.rev200529.alarm.Resource; +import org.opendaylight.yang.gen.v1.http.org.openroadm.alarm.rev200529.alarm.ResourceBuilder; +import org.opendaylight.yang.gen.v1.http.org.openroadm.common.node.types.rev191129.NodeIdType; +import org.opendaylight.yang.gen.v1.http.org.openroadm.probablecause.rev200529.ProbableCauseEnum; +import org.opendaylight.yang.gen.v1.http.org.openroadm.resource.rev200529.resource.Device; +import org.opendaylight.yang.gen.v1.http.org.openroadm.resource.rev200529.resource.DeviceBuilder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime; +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; + +public class TestOpenRoadmAlarmNotification { + private static final String myCircuitId = "Test_Id"; + private static final String myId = "Alarm_Id"; + DateAndTime myRaiseTime = new DateAndTime("2020-02-25T10:08:06.7Z"); + ProbableCause myProbableCause = + new ProbableCauseBuilder().setCause(ProbableCauseEnum.AutomaticLaserShutdown).build(); + Device device = new DeviceBuilder().setNodeId(NodeIdType.getDefaultInstance("zNhe2i5")).build(); + org.opendaylight.yang.gen.v1.http.org.openroadm.resource.rev200529.resource.resource.resource.CircuitPack resVal = + new org.opendaylight.yang.gen.v1.http.org.openroadm.resource.rev200529.resource.resource.resource.CircuitPackBuilder() + .setCircuitPackName("Slot-0-Port-A").build(); + org.opendaylight.yang.gen.v1.http.org.openroadm.resource.rev200529.resource.Resource affectedResource = + new org.opendaylight.yang.gen.v1.http.org.openroadm.resource.rev200529.resource.ResourceBuilder().setResource(resVal).build(); + Resource myResource = new ResourceBuilder().setResource(affectedResource).setDevice(device).build(); + + + static DeviceManagerServiceProvider serviceProvider; + static @NonNull FaultService faultService; + static AlarmNotification notification; + Severity severity; + static NetconfBindingAccessor accessor; + static WebsocketManagerService notificationService; + static NodeId nNodeId = new NodeId("nSky"); + @BeforeClass + public static void init() throws InterruptedException, IOException { + + accessor = mock(NetconfBindingAccessor.class); + serviceProvider = mock(DeviceManagerServiceProvider.class); + faultService = mock(FaultService.class); + notificationService = mock(WebsocketManagerService.class); + } + + + + @Test + public void testNotification() { + severity = Severity.Critical; + when(accessor.getNodeId()).thenReturn(nNodeId); + when(serviceProvider.getFaultService()).thenReturn(faultService); + when(serviceProvider.getWebsocketService()).thenReturn(notificationService); + OpenroadmFaultNotificationListener alarmListener = + new OpenroadmFaultNotificationListener(accessor, serviceProvider); + notification = mock(AlarmNotification.class); + + when(notification.getId()).thenReturn(myId); + when(notification.getCircuitId()).thenReturn(myCircuitId); + when(notification.getRaiseTime()).thenReturn(myRaiseTime); + when(notification.getProbableCause()).thenReturn(myProbableCause); + when(notification.getResource()).thenReturn(myResource); + when(notification.getSeverity()).thenReturn(severity); + alarmListener.onAlarmNotification(notification); + System.out.println(notification.getId()); + assertEquals(myId, notification.getId()); + assertEquals(myCircuitId, notification.getCircuitId()); + assertEquals(myRaiseTime, notification.getRaiseTime()); + assertEquals(myProbableCause, notification.getProbableCause()); + assertEquals(myResource, notification.getResource()); + assertEquals(severity, notification.getSeverity()); + + + } + +} diff --git a/sdnr/wt/devicemanager-onap/openroadm71/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm71/test/TestOpenRoadmDeviceChangeNotification.java b/sdnr/wt/devicemanager-onap/openroadm71/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm71/test/TestOpenRoadmDeviceChangeNotification.java new file mode 100644 index 000000000..6188cc5e6 --- /dev/null +++ b/sdnr/wt/devicemanager-onap/openroadm71/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm71/test/TestOpenRoadmDeviceChangeNotification.java @@ -0,0 +1,120 @@ +/* + * ============LICENSE_START======================================================= + * ONAP : ccsdk features + * ================================================================================ + * 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.openroadm71.test; + +import static org.mockito.ArgumentMatchers.any; +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; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.NetconfTimeStamp; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.types.NetconfTimeStampImpl; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.openroadm71.impl.OpenroadmDeviceChangeNotificationListener; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor; +import org.onap.ccsdk.features.sdnr.wt.websocketmanager.model.WebsocketManagerService; +import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev200529.RpcStatus; +import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.ChangeNotification; +import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.CreateTechInfoNotification; +import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.CreateTechInfoNotificationBuilder; +import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.change.notification.Edit; +import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.change.notification.EditBuilder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.base._1._0.rev110601.EditOperationType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.EventlogBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.EventlogEntity; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.SourceType; +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; +import org.opendaylight.yangtools.yang.binding.DataObject; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.PathArgument; + + + +public class TestOpenRoadmDeviceChangeNotification { + private static final String NODEID = "Roadm1"; + private NetconfAccessor netconfAccessor = mock(NetconfAccessor.class); + private DataProvider databaseService = mock(DataProvider.class); + WebsocketManagerService notificationService = mock(WebsocketManagerService.class); + private OpenroadmDeviceChangeNotificationListener deviceChangeListener = + new OpenroadmDeviceChangeNotificationListener(netconfAccessor, databaseService, notificationService); + private static final NetconfTimeStamp ncTimeConverter = NetconfTimeStampImpl.getConverter(); + + @Test + public void testOnChangeNotification() { + + when(netconfAccessor.getNodeId()).thenReturn(new NodeId(NODEID)); + Iterable pathArguments = Arrays.asList(new PathArgument() { + + @Override + public int compareTo(PathArgument arg0) { + return 0; + } + + @Override + public Class getType() { + return DataObject.class; + } + }); + InstanceIdentifier target = InstanceIdentifier.create(pathArguments); + + deviceChangeListener.onChangeNotification(createNotification(EditOperationType.Create, target)); + EventlogEntity event = + new EventlogBuilder().setNodeId(NODEID).setNewValue(String.valueOf(EditOperationType.Create)) + .setObjectId(target.getPathArguments().toString()).setCounter(1) + .setAttributeName(target.getTargetType().getName()).setSourceType(SourceType.Netconf).build(); + verify(databaseService).writeEventLog(event); + + } + + @Test + public void testOnCreateTechInfoNotification() { + when(netconfAccessor.getNodeId()).thenReturn(new NodeId(NODEID)); + deviceChangeListener.onCreateTechInfoNotification(createTechInfoNotification()); + verify(databaseService).writeEventLog(any(EventlogEntity.class)); + } + + /** + * @param type + * @return + */ + private static ChangeNotification createNotification(EditOperationType type, InstanceIdentifier target) { + ChangeNotification change = mock(ChangeNotification.class); + + @SuppressWarnings("null") + final @NonNull List edits = Arrays.asList(new EditBuilder().setOperation(type).setTarget(target).build()); + when(change.nonnullEdit()).thenReturn(edits); + return change; + } + + private static CreateTechInfoNotification createTechInfoNotification() { + CreateTechInfoNotificationBuilder techInfoNotificationBuilder = new CreateTechInfoNotificationBuilder(); + techInfoNotificationBuilder.setLogFileName("shjkdjld/EHJkk").setShelfId("dsjhdukdgkzw") + .setStatus(RpcStatus.Successful).setStatusMessage("TestSuccessful"); + return techInfoNotificationBuilder.build(); + + } + + +} diff --git a/sdnr/wt/devicemanager-onap/openroadm71/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm71/test/TestOpenRoadmInventory.java b/sdnr/wt/devicemanager-onap/openroadm71/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm71/test/TestOpenRoadmInventory.java new file mode 100644 index 000000000..2b2b2c618 --- /dev/null +++ b/sdnr/wt/devicemanager-onap/openroadm71/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm71/test/TestOpenRoadmInventory.java @@ -0,0 +1,144 @@ +/* + * ============LICENSE_START======================================================= + * ONAP : ccsdk features + * ================================================================================ + * 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.openroadm71.test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; +import org.junit.Test; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.openroadm71.impl.OpenroadmInventoryInput; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor; +import org.opendaylight.yang.gen.v1.http.org.openroadm.common.node.types.rev191129.NodeIdType; +import org.opendaylight.yang.gen.v1.http.org.openroadm.common.state.types.rev191129.LifecycleState; +import org.opendaylight.yang.gen.v1.http.org.openroadm.common.state.types.rev191129.State; +import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev200529.OpenroadmVersionType; +import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.circuit.packs.CircuitPacks; +import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.interfaces.grp.Interface; +import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.org.openroadm.device.container.OrgOpenroadmDevice; +import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.org.openroadm.device.container.org.openroadm.device.Info; +import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.org.openroadm.device.container.org.openroadm.device.InfoBuilder; +import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.org.openroadm.device.container.org.openroadm.device.Xponder; +import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.shelves.Shelves; +import org.opendaylight.yang.gen.v1.http.org.openroadm.device.types.rev191129.NodeTypes; +import org.opendaylight.yang.gen.v1.http.org.openroadm.device.types.rev191129.XpdrNodeTypes; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime; +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; +import org.opendaylight.yangtools.yang.common.Uint16; +import org.opendaylight.yangtools.yang.common.Uint32; +import org.opendaylight.yangtools.yang.common.Uint8; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class TestOpenRoadmInventory { + private static final Logger LOG = LoggerFactory.getLogger(OpenroadmInventoryInput.class); + private NetconfAccessor accessor = mock(NetconfAccessor.class); + private long value1 = 1; + private IpAddress ipAddress = new IpAddress(new Ipv4Address("127.0.0.11")); + private NodeId nodeId = new NodeId("RoadmA2"); + private Info info = new InfoBuilder().setNodeId(NodeIdType.getDefaultInstance("zNhe2i5")).setClli("NodeB") + .setSerialId("0002").setModel("model2").setVendor("VendorA").setCurrentIpAddress(ipAddress) + .setCurrentIpAddress(ipAddress).setCurrentDefaultGateway(new IpAddress(new Ipv4Address("127.0.0.20"))) + .setCurrentDefaultGateway(new IpAddress(new Ipv4Address("127.0.0.20"))).setNodeType(NodeTypes.Rdm) + .setCurrentDatetime(new DateAndTime("2017-10-22T15:23:43Z")).setSoftwareVersion("swversion1234") + .setPrefixLength(Uint8.valueOf(28)).setMaxDegrees(Uint16.valueOf(2)).setMaxSrgs(Uint16.valueOf(3)) + .setMaxNumBin15minHistoricalPm(Uint16.valueOf(32)).setMaxNumBin24hourHistoricalPm(Uint16.valueOf(7)) + .setOpenroadmVersion(OpenroadmVersionType._20).build(); + + private OrgOpenroadmDevice device = mock(OrgOpenroadmDevice.class);; + private Shelves shelf = mock(Shelves.class); + private Interface interfaces = mock(Interface.class); + private CircuitPacks cp = mock(CircuitPacks.class); + private Xponder xpdr = mock(Xponder.class); + OpenroadmInventoryInput roadmInventory = new OpenroadmInventoryInput(accessor, device); + + @Test + public void TestDevice() { + when(accessor.getNodeId()).thenReturn(nodeId); + when(device.getInfo()).thenReturn(info); + + roadmInventory.getInventoryData(Uint32.valueOf(value1)); + assertEquals(info, device.getInfo()); + + } + + @Test + public void TestShelves() { + when(accessor.getNodeId()).thenReturn(nodeId); + when(device.getInfo()).thenReturn(info); + when(shelf.getShelfPosition()).thenReturn("10"); + when(shelf.getOperationalState()).thenReturn(State.InService); + when(shelf.getSerialId()).thenReturn("nodeid-1"); + when(shelf.getShelfName()).thenReturn("Shelf1"); + when(shelf.getShelfType()).thenReturn("Shelf"); + when(shelf.getClei()).thenReturn("1234567890"); + when(shelf.getVendor()).thenReturn("vendorA"); + when(shelf.getModel()).thenReturn("1"); + when(shelf.getHardwareVersion()).thenReturn("0.1"); + when(shelf.getManufactureDate()).thenReturn(new DateAndTime("2017-10-22T15:23:43Z")); + assertNotNull(roadmInventory.getShelvesInventory(shelf, Uint32.valueOf(value1 + 1))); + + LOG.info("Shelves test completed"); + + } + + @Test + public void TestCircuitPacks() { + when(accessor.getNodeId()).thenReturn(nodeId); + when(cp.getCircuitPackName()).thenReturn("1/0"); + when(cp.getVendor()).thenReturn("VendorA"); + when(cp.getModel()).thenReturn("Model1"); + when(cp.getSerialId()).thenReturn("46277sgh6"); + when(cp.getClei()).thenReturn("136268785"); + when(cp.getHardwareVersion()).thenReturn("0.1"); + when(cp.getType()).thenReturn("WSS"); + when(cp.getProductCode()).thenReturn("oooooo"); + when(cp.getCircuitPackMode()).thenReturn("inServiceMode"); + when(device.getInfo()).thenReturn(info); + assertNotNull(roadmInventory.getCircuitPackInventory(cp, Uint32.valueOf(value1 + 1))); + + } + + @Test + public void TestInterfaces() { + when(accessor.getNodeId()).thenReturn(nodeId); + when(interfaces.getName()).thenReturn("1GE-interface-1"); + when(interfaces.getDescription()).thenReturn("Ethernet Interface"); + when(interfaces.getSupportingCircuitPackName()).thenReturn("1/0"); + when(device.getInfo()).thenReturn(info); + assertNotNull(roadmInventory.getInterfacesInventory(interfaces, Uint32.valueOf(value1 + 2))); + } + + @Test + public void TestXponder() { + when(xpdr.getXpdrNumber()).thenReturn(Uint16.valueOf(1)); + when(xpdr.getXpdrType()).thenReturn(XpdrNodeTypes.Mpdr); + when(xpdr.getLifecycleState()).thenReturn(LifecycleState.Deployed); + when(accessor.getNodeId()).thenReturn(nodeId); + when(device.getInfo()).thenReturn(info); + assertNotNull(roadmInventory.getXponderInventory(xpdr, Uint32.valueOf(value1 + 1))); + + } + +} diff --git a/sdnr/wt/devicemanager-onap/openroadm71/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm71/test/TestOpenRoadmNetworkElement.java b/sdnr/wt/devicemanager-onap/openroadm71/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm71/test/TestOpenRoadmNetworkElement.java new file mode 100644 index 000000000..9ef0f6474 --- /dev/null +++ b/sdnr/wt/devicemanager-onap/openroadm71/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm71/test/TestOpenRoadmNetworkElement.java @@ -0,0 +1,311 @@ +/* + * ============LICENSE_START======================================================= + * ONAP : ccsdk features + * ================================================================================ + * 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.openroadm71.test; + +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.HashMap; +import java.util.Map; +import org.eclipse.jdt.annotation.Nullable; +import org.junit.Before; +import org.junit.Test; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.openroadm71.impl.OpenroadmInventoryInput; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.openroadm71.impl.OpenroadmNetworkElement; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.FaultService; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.Capabilities; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfBindingAccessor; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.TransactionUtils; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; +import org.opendaylight.yang.gen.v1.http.org.openroadm.alarm.rev200529.ActiveAlarmList; +import org.opendaylight.yang.gen.v1.http.org.openroadm.alarm.rev200529.Severity; +import org.opendaylight.yang.gen.v1.http.org.openroadm.alarm.rev200529.active.alarm.list.ActiveAlarms; +import org.opendaylight.yang.gen.v1.http.org.openroadm.alarm.rev200529.active.alarm.list.ActiveAlarmsKey; +import org.opendaylight.yang.gen.v1.http.org.openroadm.alarm.rev200529.alarm.ProbableCauseBuilder; +import org.opendaylight.yang.gen.v1.http.org.openroadm.alarm.rev200529.alarm.ResourceBuilder; +import org.opendaylight.yang.gen.v1.http.org.openroadm.common.node.types.rev191129.NodeIdType; +import org.opendaylight.yang.gen.v1.http.org.openroadm.common.state.types.rev191129.LifecycleState; +import org.opendaylight.yang.gen.v1.http.org.openroadm.common.state.types.rev191129.State; +import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev200529.OpenroadmVersionType; +import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.circuit.pack.ParentCircuitPack; +import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.circuit.packs.CircuitPacks; +import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.circuit.packs.CircuitPacksKey; +import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.interfaces.grp.Interface; +import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.interfaces.grp.InterfaceKey; +import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.org.openroadm.device.container.OrgOpenroadmDevice; +import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.org.openroadm.device.container.org.openroadm.device.Info; +import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.org.openroadm.device.container.org.openroadm.device.InfoBuilder; +import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.org.openroadm.device.container.org.openroadm.device.Xponder; +import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.org.openroadm.device.container.org.openroadm.device.XponderKey; +import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.shelf.Slots; +import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.shelf.SlotsKey; +import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.shelves.Shelves; +import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.shelves.ShelvesKey; +import org.opendaylight.yang.gen.v1.http.org.openroadm.device.types.rev191129.NodeTypes; +import org.opendaylight.yang.gen.v1.http.org.openroadm.device.types.rev191129.XpdrNodeTypes; +import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.rev200529.HistoricalPmList; +import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.rev200529.historical.pm.group.HistoricalPm; +import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.rev200529.historical.pm.group.HistoricalPmKey; +import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.rev200529.historical.pm.list.HistoricalPmEntry; +import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.rev200529.historical.pm.list.HistoricalPmEntryKey; +import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.rev200529.historical.pm.val.group.Measurement; +import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.rev200529.historical.pm.val.group.MeasurementKey; +import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.types.rev200327.PmDataType; +import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.types.rev200327.PmGranularity; +import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.types.rev200327.PmNamesEnum; +import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.types.rev200327.Validity; +import org.opendaylight.yang.gen.v1.http.org.openroadm.probablecause.rev200529.ProbableCauseEnum; +import org.opendaylight.yang.gen.v1.http.org.openroadm.resource.rev200529.resource.DeviceBuilder; +import org.opendaylight.yang.gen.v1.http.org.openroadm.resource.types.rev191129.ResourceTypeEnum; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime; +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; +import org.opendaylight.yangtools.yang.common.Uint16; +import org.opendaylight.yangtools.yang.common.Uint32; +import org.opendaylight.yangtools.yang.common.Uint64; +import org.opendaylight.yangtools.yang.common.Uint8; + +public class TestOpenRoadmNetworkElement { + + NetconfBindingAccessor accessor = mock(NetconfBindingAccessor.class); + DeviceManagerServiceProvider serviceProvider = mock(DeviceManagerServiceProvider.class); + DataProvider dataprovider = mock(DataProvider.class); + Capabilities capabilities = mock(Capabilities.class); + TransactionUtils transactionUtils = mock(TransactionUtils.class); + DataBroker dataBroker = mock(DataBroker.class); + FaultService faultService = mock(FaultService.class); + OrgOpenroadmDevice device; + OpenroadmInventoryInput inventoryData; + long level = 1; + private Shelves shelf = mock(Shelves.class); + private @Nullable Map shelfList; + private CircuitPacks cp, cp1, cp2, cp3; + private Interface interfaces = mock(Interface.class); + private Xponder xpdr = mock(Xponder.class); + private IpAddress ipAddress = new IpAddress(new Ipv4Address("127.0.0.11")); + private Info info = new InfoBuilder().setNodeId(NodeIdType.getDefaultInstance("zNhe2i5")).setClli("NodeB") + .setSerialId("0002").setModel("model2").setVendor("VendorA").setCurrentIpAddress(ipAddress) + .setCurrentIpAddress(ipAddress).setCurrentDefaultGateway(new IpAddress(new Ipv4Address("127.0.0.20"))) + .setCurrentDefaultGateway(new IpAddress(new Ipv4Address("127.0.0.20"))).setNodeType(NodeTypes.Rdm) + .setCurrentDatetime(new DateAndTime("2017-10-22T15:23:43Z")).setSoftwareVersion("swversion1234") + .setCurrentPrefixLength(Uint8.valueOf(45)).setMaxDegrees(Uint16.valueOf(56)).setMaxSrgs(Uint16.valueOf(251)) + .setMaxNumBin15minHistoricalPm(Uint16.valueOf(324)).setMaxNumBin24hourHistoricalPm(Uint16.valueOf(142)) + .setOpenroadmVersion(OpenroadmVersionType._20).build(); + private ActiveAlarmList alarmList = mock(ActiveAlarmList.class); + private ActiveAlarms activeAlarms = mock(ActiveAlarms.class); + private HistoricalPmList pmDataList = mock(HistoricalPmList.class); + private HistoricalPm historicalPm = mock(HistoricalPm.class); + + @Before + public void init() { + when(accessor.getCapabilites()).thenReturn(capabilities); + when(serviceProvider.getFaultService()).thenReturn(faultService); + when(serviceProvider.getDataProvider()).thenReturn(dataprovider); + NodeId nNodeId = new NodeId("RoadmA"); + when(accessor.getNodeId()).thenReturn(nNodeId); + when(accessor.getDataBroker()).thenReturn(dataBroker); + when(accessor.getTransactionUtils()).thenReturn(transactionUtils); + when(accessor.getCapabilites().isSupportingNamespaceAndRevision(OrgOpenroadmDevice.QNAME)).thenReturn(true); + final Class openRoadmDev = OrgOpenroadmDevice.class; + // Reading data from device + InstanceIdentifier deviceId = InstanceIdentifier.create(openRoadmDev); + device = mock(OrgOpenroadmDevice.class); + when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL, + deviceId)).thenReturn(device); + + when(device.getInfo()).thenReturn(info); + inventoryData = new OpenroadmInventoryInput(accessor, device); + // Reading the shelfs data; + when(shelf.getShelfPosition()).thenReturn("10"); + when(shelf.getOperationalState()).thenReturn(State.InService); + when(shelf.getSerialId()).thenReturn("nodeid-1"); + when(shelf.getShelfName()).thenReturn("Shelf1"); + when(shelf.getShelfType()).thenReturn("Shelf"); + when(shelf.getClei()).thenReturn("1234567890"); + when(shelf.getVendor()).thenReturn("vendorA"); + when(shelf.getModel()).thenReturn("1"); + when(shelf.getHardwareVersion()).thenReturn("0.1"); + when(shelf.getManufactureDate()).thenReturn(new DateAndTime("2017-10-22T15:23:43Z")); + @Nullable + Map slotList = null; + Slots slots = mock(Slots.class); + when(slots.getLabel()).thenReturn("Slot56746"); + when(slots.getSlotName()).thenReturn("slotofRoadmA"); + when(slots.getProvisionedCircuitPack()).thenReturn("1/0"); + slotList = new HashMap<>(); + slotList.put(slots.key(), slots); + when(shelf.getSlots()).thenReturn(slotList); + shelfList = new HashMap<>(); + shelfList.put(shelf.key(), shelf); + when(device.getShelves()).thenReturn(shelfList); + + // Reading data from CircuitPacks + cp = mock(CircuitPacks.class); + when(cp.getCircuitPackName()).thenReturn("1/0"); + when(cp.getVendor()).thenReturn("VendorA"); + when(cp.getModel()).thenReturn("Model1"); + when(cp.getSerialId()).thenReturn("46277sgh6"); + when(cp.getClei()).thenReturn("136268785"); + when(cp.getHardwareVersion()).thenReturn("0.1"); + when(cp.getType()).thenReturn("WSS"); + when(cp.getProductCode()).thenReturn("oooooo"); + when(cp.getCircuitPackMode()).thenReturn("inServiceMode"); + + ParentCircuitPack parentCp = mock(ParentCircuitPack.class); + when(parentCp.getCircuitPackName()).thenReturn("1/0"); + when(parentCp.getCpSlotName()).thenReturn("Slot1"); + cp1 = mock(CircuitPacks.class); + when(cp1.getCircuitPackName()).thenReturn("1/0 EThernet"); + when(cp1.getVendor()).thenReturn("VendorA"); + when(cp1.getModel()).thenReturn("Model1678"); + when(cp1.getSerialId()).thenReturn("4627dgs7sgh6"); + when(cp1.getClei()).thenReturn("1362d68785"); + when(cp1.getHardwareVersion()).thenReturn("0.1"); + when(cp1.getType()).thenReturn("EthPlug"); + when(cp1.getProductCode()).thenReturn("oooooo"); + when(cp1.getCircuitPackMode()).thenReturn("inServiceMode"); + when(cp1.getParentCircuitPack()).thenReturn(parentCp); + + cp2 = mock(CircuitPacks.class); + when(cp2.getCircuitPackName()).thenReturn("2/0"); + when(cp2.getVendor()).thenReturn("VendorA"); + when(cp2.getModel()).thenReturn("Model1678"); + when(cp2.getSerialId()).thenReturn("4sads7sgh6"); + when(cp2.getClei()).thenReturn("1wew362d68785"); + when(cp2.getHardwareVersion()).thenReturn("0.1"); + when(cp2.getType()).thenReturn("WSS"); + when(cp2.getProductCode()).thenReturn("osooooo"); + when(cp2.getCircuitPackMode()).thenReturn("inServiceMode"); + + cp3 = mock(CircuitPacks.class); + when(parentCp.getCircuitPackName()).thenReturn("2/0"); + when(parentCp.getCpSlotName()).thenReturn("Slot1"); + when(cp3.getCircuitPackName()).thenReturn("2/0 OCS"); + when(cp3.getVendor()).thenReturn("VendorA"); + when(cp3.getModel()).thenReturn("Model1678"); + when(cp3.getSerialId()).thenReturn("dswsads7sgh6"); + when(cp3.getClei()).thenReturn("1ew62d68785"); + when(cp3.getHardwareVersion()).thenReturn("0.1"); + when(cp3.getType()).thenReturn("OCS Plug"); + when(cp3.getProductCode()).thenReturn("osooooo"); + when(cp3.getCircuitPackMode()).thenReturn("inServiceMode"); + when(cp3.getParentCircuitPack()).thenReturn(parentCp); + @Nullable + Map cpList = new HashMap<>(); + cpList.put(cp.key(), cp); + cpList.put(cp1.key(), cp1); + cpList.put(cp2.key(), cp2); + cpList.put(cp3.key(), cp3); + when(device.getCircuitPacks()).thenReturn(cpList); + + // Reading Interface Data + when(interfaces.getName()).thenReturn("1GE-interface-1"); + when(interfaces.getDescription()).thenReturn("Ethernet Interface"); + when(interfaces.getSupportingCircuitPackName()).thenReturn("1/0 EThernet"); + @Nullable + Map interfacesList = new HashMap<>(); + interfacesList.put(interfaces.key(), interfaces); + when(device.getInterface()).thenReturn(interfacesList); + + // Reading Xponder Data + when(xpdr.getXpdrNumber()).thenReturn(Uint16.valueOf(1)); + when(xpdr.getXpdrType()).thenReturn(XpdrNodeTypes.Mpdr); + when(xpdr.getLifecycleState()).thenReturn(LifecycleState.Deployed); + @Nullable + Map xpnderList = new HashMap<>(); + xpnderList.put(xpdr.key(), xpdr); + when(device.getXponder()).thenReturn(xpnderList); + + // Read initial Alarm data + final Class classAlarm = ActiveAlarmList.class; + InstanceIdentifier alarmDataIid = InstanceIdentifier.builder(classAlarm).build(); + when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL, + alarmDataIid)).thenReturn(alarmList); + when(activeAlarms.getId()).thenReturn("Alarm1"); + when(activeAlarms.getCircuitId()).thenReturn("1/0"); + when(activeAlarms.getRaiseTime()).thenReturn(new DateAndTime("2017-10-22T15:23:43Z")); + when(activeAlarms.getSeverity()).thenReturn(Severity.Critical); + when(activeAlarms.getProbableCause()) + .thenReturn(new ProbableCauseBuilder().setCause(ProbableCauseEnum.AutomaticLaserShutdown).build()); + when(activeAlarms.getAdditionalDetail()).thenReturn("LaserShutdown"); + when(activeAlarms.getResource()).thenReturn(new ResourceBuilder() + .setDevice(new DeviceBuilder().setNodeId(NodeIdType.getDefaultInstance("zNhe2i5")).build()).build()); + @Nullable + Map activeAlarmlist = new HashMap<>(); + activeAlarmlist.put(activeAlarms.key(), activeAlarms); + when(alarmList.getActiveAlarms()).thenReturn(activeAlarmlist); + + // Read PM Data + final Class pmDataClass = HistoricalPmList.class; + InstanceIdentifier pmDataIid = InstanceIdentifier.builder(pmDataClass).build(); + when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL, + pmDataIid)).thenReturn(pmDataList); + + Measurement measurement = mock(Measurement.class); + PmDataType pmDataType = mock(PmDataType.class); + when(pmDataType.getUint64()).thenReturn(Uint64.valueOf(2425425)); + when(measurement.getBinNumber()).thenReturn(Uint16.valueOf(1452)); + when(measurement.getCompletionTime()).thenReturn(new DateAndTime("2018-10-22T15:23:43Z")); + when(measurement.getGranularity()).thenReturn(PmGranularity._24Hour); + when(measurement.getPmParameterUnit()).thenReturn("6824545199534863756"); + when(measurement.getPmParameterValue()).thenReturn(pmDataType); + when(measurement.getValidity()).thenReturn(Validity.Partial); + + @Nullable + Map measurementList = new HashMap<>(); + measurementList.put(measurement.key(), measurement); + when(historicalPm.getMeasurement()).thenReturn(measurementList); + when(historicalPm.getType()).thenReturn(PmNamesEnum.ErroredSeconds); + when(historicalPm.getExtension()).thenReturn("OpticalPowerOutput"); + @Nullable + Map historicalPmList = new HashMap<>(); + historicalPmList.put(historicalPm.key(), historicalPm); + HistoricalPmEntry histPmEntry = mock(HistoricalPmEntry.class); + when(histPmEntry.getHistoricalPm()).thenReturn(historicalPmList); + when(histPmEntry.getPmResourceType()).thenReturn(ResourceTypeEnum.CircuitPack); + @Nullable + Map histPmList = new HashMap<>(); + histPmList.put(histPmEntry.key(), histPmEntry); + when(pmDataList.getHistoricalPmEntry()).thenReturn(histPmList); + + } + + + + @Test + public void test() { + OpenroadmNetworkElement optionalNe = new OpenroadmNetworkElement(accessor, serviceProvider); + optionalNe.initialReadFromNetworkElement(); + verify(dataprovider).writeInventory(accessor.getNodeId().getValue(), + Arrays.asList(inventoryData.getInventoryData(Uint32.valueOf(0)), + inventoryData.getShelvesInventory(shelf, Uint32.valueOf(1)), + inventoryData.getXponderInventory(xpdr, Uint32.valueOf(1)), + inventoryData.getCircuitPackInventory(cp3, Uint32.valueOf(2)))); + } + +} diff --git a/sdnr/wt/devicemanager-onap/openroadm71/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm71/test/TestOpenRoadmNetworkElementFactory.java b/sdnr/wt/devicemanager-onap/openroadm71/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm71/test/TestOpenRoadmNetworkElementFactory.java new file mode 100644 index 000000000..a35c5f0ae --- /dev/null +++ b/sdnr/wt/devicemanager-onap/openroadm71/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm71/test/TestOpenRoadmNetworkElementFactory.java @@ -0,0 +1,101 @@ +/* + * ============LICENSE_START======================================================= + * ONAP : ccsdk features + * ================================================================================ + * 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.openroadm71.test; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; +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.devicemanager.openroadm71.impl.OpenroadmNetworkElementFactory; +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.NetconfBindingAccessor; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.TransactionUtils; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; +import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.org.openroadm.device.container.OrgOpenroadmDevice; +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; + +public class TestOpenRoadmNetworkElementFactory { + + private static NetconfBindingAccessor accessor; + private static DeviceManagerServiceProvider serviceProvider; + private static Capabilities capabilities; + private static TransactionUtils transactionUtils; + private static DataBroker dataBroker; + + @BeforeClass + public static void init() throws InterruptedException, IOException { + accessor = mock(NetconfBindingAccessor.class); + capabilities = mock(Capabilities.class); + dataBroker = mock(DataBroker.class); + transactionUtils = mock(TransactionUtils.class); + serviceProvider = mock(DeviceManagerServiceProvider.class); + when(accessor.getNodeId()).thenReturn(new NodeId("RoadmA2")); + when(accessor.getCapabilites()).thenReturn(capabilities); + when(accessor.getDataBroker()).thenReturn(dataBroker); + when(accessor.getTransactionUtils()).thenReturn(transactionUtils); + when(accessor.getNetconfBindingAccessor()).thenReturn(Optional.of(accessor)); + when(serviceProvider.getDataProvider()).thenReturn(null); + + final Class openRoadmDev = OrgOpenroadmDevice.class; + InstanceIdentifier deviceId = InstanceIdentifier.create(openRoadmDev); + when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL, + deviceId)).thenReturn(mock(OrgOpenroadmDevice.class)); + + when(accessor.getTransactionUtils()).thenReturn(mock(TransactionUtils.class)); + } + + @Test + public void testCapabiltiesAvailable1() { + when(accessor.getCapabilites().isSupportingNamespaceAndRevision(OrgOpenroadmDevice.QNAME)).thenReturn(true); + OpenroadmNetworkElementFactory factory = new OpenroadmNetworkElementFactory(); + assertTrue((factory.create(accessor, serviceProvider)).isPresent()); + } + + @Test + public void testCapabiltiesAvailable2() { + when(accessor.getCapabilites().isSupportingNamespaceAndRevision("http://org/openroadm/device", "2018-10-19")) + .thenReturn(true); + OpenroadmNetworkElementFactory factory = new OpenroadmNetworkElementFactory(); + assertTrue((factory.create(accessor, serviceProvider)).isPresent()); + } + + @Test + public void testCapabiltiesNotAvailable() throws Exception { + when(accessor.getCapabilites().isSupportingNamespaceAndRevision(OrgOpenroadmDevice.QNAME)).thenReturn(false); + OpenroadmNetworkElementFactory factory = new OpenroadmNetworkElementFactory(); + assertFalse(factory.create(accessor, serviceProvider).isPresent()); + } + + @After + public void cleanUp() throws Exception { + + } + +} diff --git a/sdnr/wt/devicemanager-onap/openroadm71/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm71/test/TestOpenRoadmPMDataBuilder.java b/sdnr/wt/devicemanager-onap/openroadm71/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm71/test/TestOpenRoadmPMDataBuilder.java new file mode 100644 index 000000000..3a0781e8f --- /dev/null +++ b/sdnr/wt/devicemanager-onap/openroadm71/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm71/test/TestOpenRoadmPMDataBuilder.java @@ -0,0 +1,221 @@ +/* + * ============LICENSE_START======================================================= + * ONAP : ccsdk features + * ================================================================================ + * 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.openroadm71.test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import org.eclipse.jdt.annotation.NonNull; +import org.junit.Before; +import org.junit.Test; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.openroadm71.impl.PmDataBuilderOpenRoadm; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfBindingAccessor; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.TransactionUtils; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; +import org.opendaylight.yang.gen.v1.http.org.openroadm.common.alarm.pm.types.rev191129.Direction; +import org.opendaylight.yang.gen.v1.http.org.openroadm.common.alarm.pm.types.rev191129.Location; +import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.rev200529.HistoricalPmList; +import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.rev200529.historical.pm.group.HistoricalPm; +import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.rev200529.historical.pm.group.HistoricalPmBuilder; +import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.rev200529.historical.pm.group.HistoricalPmKey; +import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.rev200529.historical.pm.list.HistoricalPmEntry; +import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.rev200529.historical.pm.list.HistoricalPmEntryBuilder; +import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.rev200529.historical.pm.list.HistoricalPmEntryKey; +import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.rev200529.historical.pm.val.group.Measurement; +import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.rev200529.historical.pm.val.group.MeasurementBuilder; +import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.rev200529.historical.pm.val.group.MeasurementKey; +import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.types.rev200327.PmDataType; +import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.types.rev200327.PmGranularity; +import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.types.rev200327.PmNamesEnum; +import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.types.rev200327.Validity; +import org.opendaylight.yang.gen.v1.http.org.openroadm.resource.types.rev191129.ResourceTypeEnum; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.Pmdata15mEntity; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.units.rev200413.Celsius; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.units.rev200413.PerformanceMeasurementUnitId; +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; +import org.opendaylight.yangtools.yang.binding.DataObject; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.PathArgument; +import org.opendaylight.yangtools.yang.common.Uint16; +import org.opendaylight.yangtools.yang.common.Uint64; + + +public class TestOpenRoadmPMDataBuilder { + // variables + // end of variables + private NetconfBindingAccessor acessor = mock(NetconfBindingAccessor.class); + private DataBroker dataBroker = mock(DataBroker.class); + private TransactionUtils transactionUtils = mock(TransactionUtils.class); + // String nodeId = "RdmA"; + private PmDataBuilderOpenRoadm pmDataBuilderORoadm; + private NodeId nodeId = new NodeId("RoadmA"); + private HistoricalPmList historicalPmDatalist = mock(HistoricalPmList.class); + private HistoricalPm historicalPm = mock(HistoricalPm.class); + private PmDataType pmDataType = new PmDataType(Uint64.valueOf(67508)); + private MeasurementBuilder measurementBuilder = new MeasurementBuilder(); + private HistoricalPmBuilder historicalPmBuilder = new HistoricalPmBuilder(); + private HistoricalPmEntryBuilder historicalPmEntryBuiler = new HistoricalPmEntryBuilder(); + private List> performanceMeasUnitList = + new ArrayList>(); + private Map measurementData = new HashMap(); + private Map historicalPMCollection = new HashMap(); + private Map historicalPmEntryCollection = + new HashMap(); + + + + // public methods + @Before + public void init() { + when(acessor.getDataBroker()).thenReturn(dataBroker); + when(acessor.getTransactionUtils()).thenReturn(transactionUtils); + + + + } + + @Test + public void testGetPmData() { + when(acessor.getNodeId()).thenReturn(nodeId); + pmDataBuilderORoadm = new PmDataBuilderOpenRoadm(acessor); + + final Class pmDataClass = HistoricalPmList.class; + InstanceIdentifier pmDataListId = InstanceIdentifier.builder(pmDataClass).build(); + when(acessor.getTransactionUtils().readData(acessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL, + pmDataListId)).thenReturn(historicalPmDatalist); + + assertEquals(historicalPmDatalist,pmDataBuilderORoadm.getPmData(acessor)); + + } + + @Test + public void testBuildPmDataEntity() { + when(acessor.getNodeId()).thenReturn(nodeId); + pmDataBuilderORoadm = new PmDataBuilderOpenRoadm(acessor); + + performanceMeasUnitList.add(Celsius.class); + measurementBuilder.setBinNumber(Uint16.valueOf(24657)) + .setCompletionTime(new DateAndTime("2020-10-22T15:23:43Z")).setGranularity(PmGranularity._24Hour) + .setPmParameterUnit("dBm").setPmParameterValue(pmDataType).setValidity(Validity.Suspect); + + measurementData.put(measurementBuilder.key(), measurementBuilder.build()); + historicalPmBuilder.setType(PmNamesEnum.SeverelyErroredSeconds).setDirection(Direction.Bidirectional) + .setExtension("sajhsiwiduwugdhegdeuz").setLocation(Location.NearEnd).setMeasurement(measurementData); + when(historicalPm.getMeasurement()).thenReturn(measurementData); + + historicalPMCollection.put(historicalPmBuilder.key(), historicalPmBuilder.build()); + PathArgument pa =new PathArgument() { + + @Override + public int compareTo(PathArgument o) { + // TODO Auto-generated method stub + return 0; + } + + @Override + public @NonNull Class getType() { + // TODO Auto-generated method stub + return Pmdata15mEntity.class; + } + }; + historicalPmEntryBuiler.setPmResourceInstance(InstanceIdentifier.create(Arrays.asList(pa))) + .setPmResourceTypeExtension("dshjdekjdewkk") + .setPmResourceType(ResourceTypeEnum.CircuitPack).setHistoricalPm(historicalPMCollection); + + historicalPmEntryCollection.put(historicalPmEntryBuiler.key(), historicalPmEntryBuiler.build()); + when(historicalPmDatalist.getHistoricalPmEntry()).thenReturn(historicalPmEntryCollection); + + assertNotNull(pmDataBuilderORoadm.buildPmDataEntity(historicalPmDatalist)); + } + @Test + public void testBuildPmDataEntity1() { + when(acessor.getNodeId()).thenReturn(nodeId); + pmDataBuilderORoadm = new PmDataBuilderOpenRoadm(acessor); + + performanceMeasUnitList.add(Celsius.class); + measurementBuilder.setBinNumber(Uint16.valueOf(24657)) + .setCompletionTime(new DateAndTime("2020-10-22T15:23:43Z")).setGranularity(PmGranularity._15min) + .setPmParameterUnit("celsius").setPmParameterValue(pmDataType).setValidity(Validity.Suspect); + + measurementData.put(measurementBuilder.key(), measurementBuilder.build()); + historicalPmBuilder.setType(PmNamesEnum.ErroredSeconds).setDirection(Direction.Rx) + .setExtension("sajhsiwiduwugdhegdeuz").setLocation(Location.FarEnd).setMeasurement(measurementData); + when(historicalPm.getMeasurement()).thenReturn(measurementData); + PathArgument pa =new PathArgument() { + + @Override + public int compareTo(PathArgument o) { + // TODO Auto-generated method stub + return 0; + } + + @Override + public Class getType() { + // TODO Auto-generated method stub + return Pmdata15mEntity.class; + } + }; + historicalPMCollection.put(historicalPmBuilder.key(), historicalPmBuilder.build()); + historicalPmEntryBuiler.setPmResourceInstance(InstanceIdentifier.create(Arrays.asList(pa))) + .setPmResourceTypeExtension("dshjdekjdewkk") + .setPmResourceType(ResourceTypeEnum.Device).setHistoricalPm(historicalPMCollection); + + historicalPmEntryCollection.put(historicalPmEntryBuiler.key(), historicalPmEntryBuiler.build()); + when(historicalPmDatalist.getHistoricalPmEntry()).thenReturn(historicalPmEntryCollection); + + assertNotNull(pmDataBuilderORoadm.buildPmDataEntity(historicalPmDatalist)); + } + // end of public methods + + + // constants + // end of constants + + // variables + // end of variables + + // constructors + // end of constructors + + // getters and setters + // end of getters and setters + + // private methods + // end of private methods + + + // end of public methods + + // static methods + // end of static methods + + // private classes + // end of private classes +} diff --git a/sdnr/wt/devicemanager-onap/openroadm71/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm71/test/TestOpenroadmNetworkElementBase.java b/sdnr/wt/devicemanager-onap/openroadm71/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm71/test/TestOpenroadmNetworkElementBase.java new file mode 100644 index 000000000..76391f62b --- /dev/null +++ b/sdnr/wt/devicemanager-onap/openroadm71/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm71/test/TestOpenroadmNetworkElementBase.java @@ -0,0 +1,62 @@ +/* + * ============LICENSE_START======================================================= + * ONAP : ccsdk features + * ================================================================================ + * 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.openroadm71.test; + +import static org.junit.Assert.assertNotNull; +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.dataprovider.model.DataProvider; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.openroadm71.impl.OpenroadmNetworkElementBase; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfBindingAccessor; +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; +public class TestOpenroadmNetworkElementBase { + // variables + private NetconfBindingAccessor netconfAccessor = mock(NetconfBindingAccessor.class); + private DeviceManagerServiceProvider deviceManagerSvcProvider = mock(DeviceManagerServiceProvider.class); + private DataProvider databaseService = mock(DataProvider.class); + private NodeId nodeId = new NodeId("RoadmA"); + private OpenroadmNetworkElementBase openRoadmNetElementBase = new OpenroadmNetworkElementBase(netconfAccessor,deviceManagerSvcProvider); + // end of variables + + // public methods + @Before + public void init() { + + when(netconfAccessor.getNodeId()).thenReturn(nodeId); + + } + + @Test + public void testGetNodeId() { + assertNotNull(openRoadmNetElementBase.getNodeId()); + + } + + @Test + public void testGetDeviceType() { + assertNotNull(openRoadmNetElementBase.getDeviceType()); + } + +} -- cgit 1.2.3-korg