X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=nbinotifications%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Ftransportpce%2Fnbinotifications%2Flistener%2FNbiNotificationsListenerImplTest.java;h=c66efdbbc0eff599beb66f7b13ebbafefb041895;hb=274148a8d813140f86e1f9770ba992b072c1a5cd;hp=899baed01718849435cfda050030ae6bb104398d;hpb=1c4b0ba3a2ca77a6acfcd41453b7c9c0f2f2480d;p=transportpce.git diff --git a/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/listener/NbiNotificationsListenerImplTest.java b/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/listener/NbiNotificationsListenerImplTest.java index 899baed01..c66efdbbc 100644 --- a/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/listener/NbiNotificationsListenerImplTest.java +++ b/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/listener/NbiNotificationsListenerImplTest.java @@ -8,6 +8,7 @@ package org.opendaylight.transportpce.nbinotifications.listener; import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; @@ -17,18 +18,21 @@ import org.junit.Test; import org.mockito.Mock; import org.mockito.MockitoAnnotations; import org.opendaylight.transportpce.nbinotifications.producer.Publisher; -import org.opendaylight.transportpce.nbinotifications.producer.PublisherAlarm; import org.opendaylight.transportpce.test.AbstractTest; import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.ConnectionType; import org.opendaylight.yang.gen.v1.http.org.openroadm.common.state.types.rev181130.State; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.PublishNotificationService; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.PublishNotificationServiceBuilder; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.NotificationAlarmService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.NotificationProcessService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.PublishNotificationAlarmService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.PublishNotificationAlarmServiceBuilder; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.PublishNotificationProcessService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.PublishNotificationProcessServiceBuilder; public class NbiNotificationsListenerImplTest extends AbstractTest { @Mock - private Publisher publisher; + private Publisher publisherService; @Mock - private PublisherAlarm publisherAlarm; + private Publisher publisherAlarm; @Before public void setUp() { @@ -37,23 +41,63 @@ public class NbiNotificationsListenerImplTest extends AbstractTest { @Test public void onPublishNotificationServiceTest() { - NbiNotificationsListenerImpl listener = new NbiNotificationsListenerImpl(Map.of("test", publisher), + NbiNotificationsListenerImpl listener = new NbiNotificationsListenerImpl(Map.of("test", publisherService), Map.of("test", publisherAlarm)); - PublishNotificationService notification = new PublishNotificationServiceBuilder().setTopic("test") - .setCommonId("commonId").setConnectionType(ConnectionType.Service).setMessage("Service deleted") - .setOperationalState(State.OutOfService).setServiceName("service name").build(); - listener.onPublishNotificationService(notification); - verify(publisher, times(1)).sendEvent(any()); + PublishNotificationProcessService notification = new PublishNotificationProcessServiceBuilder() + .setPublisherName("test") + .setCommonId("commonId") + .setConnectionType(ConnectionType.Service) + .setMessage("Service deleted") + .setOperationalState(State.OutOfService) + .setServiceName("service name") + .build(); + listener.onPublishNotificationProcessService(notification); + verify(publisherService, times(1)).sendEvent(any(), anyString()); } @Test - public void onPublishNotificationServiceWrongTopicTest() { - NbiNotificationsListenerImpl listener = new NbiNotificationsListenerImpl(Map.of("test", publisher), + public void onPublishNotificationServiceWrongPublisherTest() { + NbiNotificationsListenerImpl listener = new NbiNotificationsListenerImpl(Map.of("test", publisherService), Map.of("test", publisherAlarm)); - PublishNotificationService notification = new PublishNotificationServiceBuilder().setTopic("wrongtopic") - .setCommonId("commonId").setConnectionType(ConnectionType.Service).setMessage("Service deleted") - .setOperationalState(State.OutOfService).setServiceName("service name").build(); - listener.onPublishNotificationService(notification); - verify(publisher, times(0)).sendEvent(any()); + PublishNotificationProcessService notification = new PublishNotificationProcessServiceBuilder() + .setPublisherName("wrongPublisher") + .setCommonId("commonId") + .setConnectionType(ConnectionType.Service) + .setMessage("Service deleted") + .setOperationalState(State.OutOfService) + .setServiceName("service name") + .build(); + listener.onPublishNotificationProcessService(notification); + verify(publisherService, times(0)).sendEvent(any(), anyString()); + } + + @Test + public void onPublishNotificationAlarmServiceTest() { + NbiNotificationsListenerImpl listener = new NbiNotificationsListenerImpl(Map.of("test", publisherService), + Map.of("test", publisherAlarm)); + PublishNotificationAlarmService notification = new PublishNotificationAlarmServiceBuilder() + .setPublisherName("test") + .setConnectionType(ConnectionType.Service) + .setMessage("The service is now inService") + .setOperationalState(State.OutOfService) + .setServiceName("service name") + .build(); + listener.onPublishNotificationAlarmService(notification); + verify(publisherAlarm, times(1)).sendEvent(any(), anyString()); + } + + @Test + public void onPublishNotificationAlarmServiceWrongPublisherTest() { + NbiNotificationsListenerImpl listener = new NbiNotificationsListenerImpl(Map.of("test", publisherService), + Map.of("test", publisherAlarm)); + PublishNotificationAlarmService notification = new PublishNotificationAlarmServiceBuilder() + .setPublisherName("wrongPublisher") + .setConnectionType(ConnectionType.Service) + .setMessage("The service is now inService") + .setOperationalState(State.OutOfService) + .setServiceName("service name") + .build(); + listener.onPublishNotificationAlarmService(notification); + verify(publisherAlarm, times(0)).sendEvent(any(), anyString()); } }