diff options
author | alex.stancu <alexandru.stancu@highstreet-technologies.com> | 2020-11-04 15:34:45 +0200 |
---|---|---|
committer | Alex Stancu <alexandru.stancu@highstreet-technologies.com> | 2020-11-12 09:19:50 +0000 |
commit | 8a54c69dd415f73f948d77f414ae92b0f5ab0fa7 (patch) | |
tree | 46e25c367bb052a1014d63caf4d254877bb606c9 /sdnr/wt/devicemanager-onf14/provider/src/test | |
parent | 1d9becc737e698f3f06bca34c94fd63254052154 (diff) |
Improve device manager 1.4
Add device manager support for ONF Core Model 1.4 notications: AttributeValueChanged, ObjectCreation, ObjectDeletion
Issue-ID: SDNC-1397
Change-Id: I6557f151bc0322b3cef64bc9bf139d352843a7f2
Signed-off-by: alex.stancu <alexandru.stancu@highstreet-technologies.com>
Diffstat (limited to 'sdnr/wt/devicemanager-onf14/provider/src/test')
4 files changed, 412 insertions, 1 deletions
diff --git a/sdnr/wt/devicemanager-onf14/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/TestOnf14AirInterfaceNotificationListener.java b/sdnr/wt/devicemanager-onf14/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/TestOnf14AirInterfaceNotificationListener.java index 0cfd5ae01..7dbbc22b3 100644 --- a/sdnr/wt/devicemanager-onf14/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/TestOnf14AirInterfaceNotificationListener.java +++ b/sdnr/wt/devicemanager-onf14/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/TestOnf14AirInterfaceNotificationListener.java @@ -22,10 +22,12 @@ import org.junit.Test; import org.mockito.Mockito; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider; import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.impl.Onf14AirInterfaceNotificationListener; import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.test.mock.NetconfAccessorMock; 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.devicemanager.service.NotificationService; import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime; import org.opendaylight.yang.gen.v1.urn.onf.yang.air._interface._2._0.rev200121.AttributeValueChangedNotification; @@ -46,6 +48,8 @@ public class TestOnf14AirInterfaceNotificationListener extends Mockito { private NodeId nodeId; private DeviceManagerServiceProvider serviceProvider; private FaultService faultService; + private DataProvider databaseService; + private NotificationService notificationService; private ObjectDeletionNotification deletionNotif; private ObjectCreationNotification creationNotif; @@ -58,6 +62,8 @@ public class TestOnf14AirInterfaceNotificationListener extends Mockito { nodeId = mock(NodeId.class); serviceProvider = mock(DeviceManagerServiceProvider.class); faultService = mock(FaultService.class); + databaseService = mock(DataProvider.class); + notificationService = mock(NotificationService.class); problemNotif = mock(ProblemNotification.class); deletionNotif = mock(ObjectDeletionNotification.class); @@ -70,7 +76,24 @@ public class TestOnf14AirInterfaceNotificationListener extends Mockito { when(problemNotif.getObjectIdRef()).thenReturn(new UniversalId("12345678-0123-0abc-abcd-0123456789AB")); when(problemNotif.getProblem()).thenReturn("modulationIsDownShifted"); + when(attrValChangedNotif.getAttributeName()).thenReturn("12345678-0123-2345-abcd-0123456789AB"); + when(attrValChangedNotif.getCounter()).thenReturn(20); + when(attrValChangedNotif.getNewValue()).thenReturn("new-value"); + when(attrValChangedNotif.getObjectIdRef()).thenReturn(new UniversalId("12345678-0123-1234-abcd-0123456789AB")); + when(attrValChangedNotif.getTimestamp()).thenReturn(new DateAndTime("2020-02-05T12:30:45.283Z")); + + when(creationNotif.getObjectType()).thenReturn("air-interface-name"); + when(creationNotif.getCounter()).thenReturn(20); + when(creationNotif.getObjectIdRef()).thenReturn(new UniversalId("12345678-0123-1234-abcd-0123456789AB")); + when(creationNotif.getTimestamp()).thenReturn(new DateAndTime("2020-02-05T12:30:45.283Z")); + + when(deletionNotif.getCounter()).thenReturn(20); + when(deletionNotif.getObjectIdRef()).thenReturn(new UniversalId("12345678-0123-1234-abcd-0123456789AB")); + when(deletionNotif.getTimestamp()).thenReturn(new DateAndTime("2020-02-05T12:30:45.283Z")); + when(serviceProvider.getFaultService()).thenReturn(faultService); + when(serviceProvider.getDataProvider()).thenReturn(databaseService); + when(serviceProvider.getNotificationService()).thenReturn(notificationService); } @Test diff --git a/sdnr/wt/devicemanager-onf14/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/TestOnf14EthernetContainerNotificationListener.java b/sdnr/wt/devicemanager-onf14/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/TestOnf14EthernetContainerNotificationListener.java new file mode 100644 index 000000000..dedcf79c8 --- /dev/null +++ b/sdnr/wt/devicemanager-onf14/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/TestOnf14EthernetContainerNotificationListener.java @@ -0,0 +1,194 @@ +/* + * ============LICENSE_START======================================================================== + * ONAP : ccsdk feature sdnr wt + * ================================================================================================= + * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. All rights reserved. + * ================================================================================================= + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + * ============LICENSE_END========================================================================== + */ +package org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14; + +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mockito; +import org.mockito.invocation.InvocationOnMock; +import org.mockito.stubbing.Answer; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.impl.Onf14EthernetContainerNotificationListener; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.test.mock.NetconfAccessorMock; +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.devicemanager.service.NotificationService; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime; +import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.UniversalId; +import org.opendaylight.yang.gen.v1.urn.onf.yang.ethernet.container._2._0.rev200121.AttributeValueChangedNotification; +import org.opendaylight.yang.gen.v1.urn.onf.yang.ethernet.container._2._0.rev200121.ObjectCreationNotification; +import org.opendaylight.yang.gen.v1.urn.onf.yang.ethernet.container._2._0.rev200121.ObjectDeletionNotification; +import org.opendaylight.yang.gen.v1.urn.onf.yang.ethernet.container._2._0.rev200121.ProblemNotification; +import org.opendaylight.yang.gen.v1.urn.onf.yang.ethernet.container._2._0.rev200121.SEVERITYTYPE; +import org.opendaylight.yang.gen.v1.urn.onf.yang.ethernet.container._2._0.rev200121.SEVERITYTYPECRITICAL; +import org.opendaylight.yang.gen.v1.urn.onf.yang.ethernet.container._2._0.rev200121.SEVERITYTYPEMAJOR; +import org.opendaylight.yang.gen.v1.urn.onf.yang.ethernet.container._2._0.rev200121.SEVERITYTYPEMINOR; +import org.opendaylight.yang.gen.v1.urn.onf.yang.ethernet.container._2._0.rev200121.SEVERITYTYPENONALARMED; +import org.opendaylight.yang.gen.v1.urn.onf.yang.ethernet.container._2._0.rev200121.SEVERITYTYPEWARNING; +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; + +public class TestOnf14EthernetContainerNotificationListener extends Mockito { + private NetconfAccessor accessor; + private NodeId nodeId; + private DeviceManagerServiceProvider serviceProvider; + private FaultService faultService; + private DataProvider databaseService; + private NotificationService notificationService; + + private ObjectDeletionNotification deletionNotif; + private ObjectCreationNotification creationNotif; + private ProblemNotification problemNotif; + private AttributeValueChangedNotification attrValChangedNotif; + + @Before + public void init() { + accessor = mock(NetconfAccessorMock.class); + nodeId = mock(NodeId.class); + serviceProvider = mock(DeviceManagerServiceProvider.class); + faultService = mock(FaultService.class); + databaseService = mock(DataProvider.class); + notificationService = mock(NotificationService.class); + + problemNotif = mock(ProblemNotification.class); + deletionNotif = mock(ObjectDeletionNotification.class); + creationNotif = mock(ObjectCreationNotification.class); + attrValChangedNotif = mock(AttributeValueChangedNotification.class); + + when(accessor.getNodeId()).thenReturn(nodeId); + when(problemNotif.getCounter()).thenReturn(new Long(10)); + when(problemNotif.getTimestamp()).thenReturn(new DateAndTime("2020-02-05T12:30:45.283Z")); + when(problemNotif.getObjectIdRef()).thenReturn(new UniversalId("12345678-0123-0abc-abcd-0123456789AB")); + when(problemNotif.getProblem()).thenReturn("modulationIsDownShifted"); + + when(attrValChangedNotif.getAttributeName()).thenReturn("12345678-0123-2345-abcd-0123456789AB"); + when(attrValChangedNotif.getCounter()).thenReturn(new Long(20)); + when(attrValChangedNotif.getNewValue()).thenReturn("new-value"); + when(attrValChangedNotif.getObjectIdRef()).thenReturn(new UniversalId("12345678-0123-1234-abcd-0123456789AB")); + when(attrValChangedNotif.getTimestamp()).thenReturn(new DateAndTime("2020-02-05T12:30:45.283Z")); + + when(creationNotif.getObjectType()).thenReturn("air-interface-name"); + when(creationNotif.getCounter()).thenReturn(new Long(20)); + when(creationNotif.getObjectIdRef()).thenReturn(new UniversalId("12345678-0123-1234-abcd-0123456789AB")); + when(creationNotif.getTimestamp()).thenReturn(new DateAndTime("2020-02-05T12:30:45.283Z")); + + when(deletionNotif.getCounter()).thenReturn(new Long(20)); + when(deletionNotif.getObjectIdRef()).thenReturn(new UniversalId("12345678-0123-1234-abcd-0123456789AB")); + when(deletionNotif.getTimestamp()).thenReturn(new DateAndTime("2020-02-05T12:30:45.283Z")); + + when(serviceProvider.getFaultService()).thenReturn(faultService); + when(serviceProvider.getDataProvider()).thenReturn(databaseService); + when(serviceProvider.getNotificationService()).thenReturn(notificationService); + } + + @Test + public void testOtherNotif() { + Onf14EthernetContainerNotificationListener notifListener = + new Onf14EthernetContainerNotificationListener(accessor, serviceProvider); + + notifListener.onObjectDeletionNotification(deletionNotif); + notifListener.onObjectCreationNotification(creationNotif); + notifListener.onAttributeValueChangedNotification(attrValChangedNotif); + } + + @Test + public void testProblemNotifCritical() { + Onf14EthernetContainerNotificationListener notifListener = + new Onf14EthernetContainerNotificationListener(accessor, serviceProvider); + + when(problemNotif.getSeverity()).thenAnswer(new Answer<Class<? extends SEVERITYTYPE>>() { + @Override + public Class<? extends SEVERITYTYPE> answer(InvocationOnMock invocation) throws Throwable { + return SEVERITYTYPECRITICAL.class; + } + }); + + notifListener.onProblemNotification(problemNotif); + } + + @Test + public void testProblemNotifMajor() { + Onf14EthernetContainerNotificationListener notifListener = + new Onf14EthernetContainerNotificationListener(accessor, serviceProvider); + + when(problemNotif.getSeverity()).thenAnswer(new Answer<Class<? extends SEVERITYTYPE>>() { + @Override + public Class<? extends SEVERITYTYPE> answer(InvocationOnMock invocation) throws Throwable { + return SEVERITYTYPEMAJOR.class; + } + }); + + notifListener.onProblemNotification(problemNotif); + } + + @Test + public void testProblemNotifMinor() { + Onf14EthernetContainerNotificationListener notifListener = + new Onf14EthernetContainerNotificationListener(accessor, serviceProvider); + + when(problemNotif.getSeverity()).thenAnswer(new Answer<Class<? extends SEVERITYTYPE>>() { + @Override + public Class<? extends SEVERITYTYPE> answer(InvocationOnMock invocation) throws Throwable { + return SEVERITYTYPEMINOR.class; + } + }); + + notifListener.onProblemNotification(problemNotif); + } + + @Test + public void testProblemNotifWarning() { + Onf14EthernetContainerNotificationListener notifListener = + new Onf14EthernetContainerNotificationListener(accessor, serviceProvider); + + when(problemNotif.getSeverity()).thenAnswer(new Answer<Class<? extends SEVERITYTYPE>>() { + @Override + public Class<? extends SEVERITYTYPE> answer(InvocationOnMock invocation) throws Throwable { + return SEVERITYTYPEWARNING.class; + } + }); + + notifListener.onProblemNotification(problemNotif); + } + + @Test + public void testProblemNotifNonalarmed() { + Onf14EthernetContainerNotificationListener notifListener = + new Onf14EthernetContainerNotificationListener(accessor, serviceProvider); + + when(problemNotif.getSeverity()).thenAnswer(new Answer<Class<? extends SEVERITYTYPE>>() { + @Override + public Class<? extends SEVERITYTYPE> answer(InvocationOnMock invocation) throws Throwable { + return SEVERITYTYPENONALARMED.class; + } + }); + + notifListener.onProblemNotification(problemNotif); + } + + @Test + public void testProblemNotifNull() { + Onf14EthernetContainerNotificationListener notifListener = + new Onf14EthernetContainerNotificationListener(accessor, serviceProvider); + + when(problemNotif.getSeverity()).thenReturn(null); + + notifListener.onProblemNotification(problemNotif); + } + +} diff --git a/sdnr/wt/devicemanager-onf14/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/TestOnf14NetworkElement.java b/sdnr/wt/devicemanager-onf14/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/TestOnf14NetworkElement.java index ff4d1e1e2..d87e6d232 100644 --- a/sdnr/wt/devicemanager-onf14/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/TestOnf14NetworkElement.java +++ b/sdnr/wt/devicemanager-onf14/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/TestOnf14NetworkElement.java @@ -78,7 +78,7 @@ public class TestOnf14NetworkElement extends Mockito { InstanceIdentifier<ControlConstruct> CONTROLCONSTRUCT_IID = InstanceIdentifier.builder(ControlConstruct.class).build(); - when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL, + when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), LogicalDatastoreType.CONFIGURATION, CONTROLCONSTRUCT_IID)).thenReturn(controlConstruct); List<UniversalId> topLevelEqList = null; diff --git a/sdnr/wt/devicemanager-onf14/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/TestOnf14WireInterfaceNotificationListener.java b/sdnr/wt/devicemanager-onf14/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/TestOnf14WireInterfaceNotificationListener.java new file mode 100644 index 000000000..267e9a813 --- /dev/null +++ b/sdnr/wt/devicemanager-onf14/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/TestOnf14WireInterfaceNotificationListener.java @@ -0,0 +1,194 @@ +/* + * ============LICENSE_START======================================================================== + * ONAP : ccsdk feature sdnr wt + * ================================================================================================= + * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. All rights reserved. + * ================================================================================================= + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + * ============LICENSE_END========================================================================== + */ +package org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14; + +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mockito; +import org.mockito.invocation.InvocationOnMock; +import org.mockito.stubbing.Answer; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.impl.Onf14WireInterfaceNotificationListener; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.test.mock.NetconfAccessorMock; +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.devicemanager.service.NotificationService; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime; +import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.UniversalId; +import org.opendaylight.yang.gen.v1.urn.onf.yang.wire._interface._2._0.rev200123.AttributeValueChangedNotification; +import org.opendaylight.yang.gen.v1.urn.onf.yang.wire._interface._2._0.rev200123.ObjectCreationNotification; +import org.opendaylight.yang.gen.v1.urn.onf.yang.wire._interface._2._0.rev200123.ObjectDeletionNotification; +import org.opendaylight.yang.gen.v1.urn.onf.yang.wire._interface._2._0.rev200123.ProblemNotification; +import org.opendaylight.yang.gen.v1.urn.onf.yang.wire._interface._2._0.rev200123.SEVERITYTYPE; +import org.opendaylight.yang.gen.v1.urn.onf.yang.wire._interface._2._0.rev200123.SEVERITYTYPECRITICAL; +import org.opendaylight.yang.gen.v1.urn.onf.yang.wire._interface._2._0.rev200123.SEVERITYTYPEMAJOR; +import org.opendaylight.yang.gen.v1.urn.onf.yang.wire._interface._2._0.rev200123.SEVERITYTYPEMINOR; +import org.opendaylight.yang.gen.v1.urn.onf.yang.wire._interface._2._0.rev200123.SEVERITYTYPENONALARMED; +import org.opendaylight.yang.gen.v1.urn.onf.yang.wire._interface._2._0.rev200123.SEVERITYTYPEWARNING; +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; + +public class TestOnf14WireInterfaceNotificationListener extends Mockito { + private NetconfAccessor accessor; + private NodeId nodeId; + private DeviceManagerServiceProvider serviceProvider; + private FaultService faultService; + private DataProvider databaseService; + private NotificationService notificationService; + + private ObjectDeletionNotification deletionNotif; + private ObjectCreationNotification creationNotif; + private ProblemNotification problemNotif; + private AttributeValueChangedNotification attrValChangedNotif; + + @Before + public void init() { + accessor = mock(NetconfAccessorMock.class); + nodeId = mock(NodeId.class); + serviceProvider = mock(DeviceManagerServiceProvider.class); + faultService = mock(FaultService.class); + databaseService = mock(DataProvider.class); + notificationService = mock(NotificationService.class); + + problemNotif = mock(ProblemNotification.class); + deletionNotif = mock(ObjectDeletionNotification.class); + creationNotif = mock(ObjectCreationNotification.class); + attrValChangedNotif = mock(AttributeValueChangedNotification.class); + + when(accessor.getNodeId()).thenReturn(nodeId); + when(problemNotif.getCounter()).thenReturn(10); + when(problemNotif.getTimestamp()).thenReturn(new DateAndTime("2020-02-05T12:30:45.283Z")); + when(problemNotif.getObjectIdRef()).thenReturn(new UniversalId("12345678-0123-0abc-abcd-0123456789AB")); + when(problemNotif.getProblem()).thenReturn("modulationIsDownShifted"); + + when(attrValChangedNotif.getAttributeName()).thenReturn("12345678-0123-2345-abcd-0123456789AB"); + when(attrValChangedNotif.getCounter()).thenReturn(20); + when(attrValChangedNotif.getNewValue()).thenReturn("new-value"); + when(attrValChangedNotif.getObjectIdRef()).thenReturn(new UniversalId("12345678-0123-1234-abcd-0123456789AB")); + when(attrValChangedNotif.getTimestamp()).thenReturn(new DateAndTime("2020-02-05T12:30:45.283Z")); + + when(creationNotif.getObjectType()).thenReturn("air-interface-name"); + when(creationNotif.getCounter()).thenReturn(20); + when(creationNotif.getObjectIdRef()).thenReturn(new UniversalId("12345678-0123-1234-abcd-0123456789AB")); + when(creationNotif.getTimestamp()).thenReturn(new DateAndTime("2020-02-05T12:30:45.283Z")); + + when(deletionNotif.getCounter()).thenReturn(20); + when(deletionNotif.getObjectIdRef()).thenReturn(new UniversalId("12345678-0123-1234-abcd-0123456789AB")); + when(deletionNotif.getTimestamp()).thenReturn(new DateAndTime("2020-02-05T12:30:45.283Z")); + + when(serviceProvider.getFaultService()).thenReturn(faultService); + when(serviceProvider.getDataProvider()).thenReturn(databaseService); + when(serviceProvider.getNotificationService()).thenReturn(notificationService); + } + + @Test + public void testOtherNotif() { + Onf14WireInterfaceNotificationListener notifListener = + new Onf14WireInterfaceNotificationListener(accessor, serviceProvider); + + notifListener.onObjectDeletionNotification(deletionNotif); + notifListener.onObjectCreationNotification(creationNotif); + notifListener.onAttributeValueChangedNotification(attrValChangedNotif); + } + + @Test + public void testProblemNotifCritical() { + Onf14WireInterfaceNotificationListener notifListener = + new Onf14WireInterfaceNotificationListener(accessor, serviceProvider); + + when(problemNotif.getSeverity()).thenAnswer(new Answer<Class<? extends SEVERITYTYPE>>() { + @Override + public Class<? extends SEVERITYTYPE> answer(InvocationOnMock invocation) throws Throwable { + return SEVERITYTYPECRITICAL.class; + } + }); + + notifListener.onProblemNotification(problemNotif); + } + + @Test + public void testProblemNotifMajor() { + Onf14WireInterfaceNotificationListener notifListener = + new Onf14WireInterfaceNotificationListener(accessor, serviceProvider); + + when(problemNotif.getSeverity()).thenAnswer(new Answer<Class<? extends SEVERITYTYPE>>() { + @Override + public Class<? extends SEVERITYTYPE> answer(InvocationOnMock invocation) throws Throwable { + return SEVERITYTYPEMAJOR.class; + } + }); + + notifListener.onProblemNotification(problemNotif); + } + + @Test + public void testProblemNotifMinor() { + Onf14WireInterfaceNotificationListener notifListener = + new Onf14WireInterfaceNotificationListener(accessor, serviceProvider); + + when(problemNotif.getSeverity()).thenAnswer(new Answer<Class<? extends SEVERITYTYPE>>() { + @Override + public Class<? extends SEVERITYTYPE> answer(InvocationOnMock invocation) throws Throwable { + return SEVERITYTYPEMINOR.class; + } + }); + + notifListener.onProblemNotification(problemNotif); + } + + @Test + public void testProblemNotifWarning() { + Onf14WireInterfaceNotificationListener notifListener = + new Onf14WireInterfaceNotificationListener(accessor, serviceProvider); + + when(problemNotif.getSeverity()).thenAnswer(new Answer<Class<? extends SEVERITYTYPE>>() { + @Override + public Class<? extends SEVERITYTYPE> answer(InvocationOnMock invocation) throws Throwable { + return SEVERITYTYPEWARNING.class; + } + }); + + notifListener.onProblemNotification(problemNotif); + } + + @Test + public void testProblemNotifNonalarmed() { + Onf14WireInterfaceNotificationListener notifListener = + new Onf14WireInterfaceNotificationListener(accessor, serviceProvider); + + when(problemNotif.getSeverity()).thenAnswer(new Answer<Class<? extends SEVERITYTYPE>>() { + @Override + public Class<? extends SEVERITYTYPE> answer(InvocationOnMock invocation) throws Throwable { + return SEVERITYTYPENONALARMED.class; + } + }); + + notifListener.onProblemNotification(problemNotif); + } + + @Test + public void testProblemNotifNull() { + Onf14WireInterfaceNotificationListener notifListener = + new Onf14WireInterfaceNotificationListener(accessor, serviceProvider); + + when(problemNotif.getSeverity()).thenReturn(null); + + notifListener.onProblemNotification(problemNotif); + } + +} |