Refactor NBINotifications and serviceHandlerImpl
[transportpce.git] / nbinotifications / src / test / java / org / opendaylight / transportpce / nbinotifications / listener / NbiNotificationsListenerImplTest.java
index d8e832ead06f4a2d1cb8d6f81939a12ab8fddb11..c66efdbbc0eff599beb66f7b13ebbafefb041895 100644 (file)
@@ -21,16 +21,16 @@ import org.opendaylight.transportpce.nbinotifications.producer.Publisher;
 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.NotificationAlarmService;
-import org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.NotificationService;
-import org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.PublishNotificationAlarmService;
-import org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.PublishNotificationAlarmServiceBuilder;
-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<NotificationService> publisherService;
+    private Publisher<NotificationProcessService> publisherService;
     @Mock
     private Publisher<NotificationAlarmService> publisherAlarm;
 
@@ -43,21 +43,31 @@ public class NbiNotificationsListenerImplTest extends AbstractTest {
     public void onPublishNotificationServiceTest() {
         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);
+        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() {
+    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);
+        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());
     }
 
@@ -65,21 +75,28 @@ public class NbiNotificationsListenerImplTest extends AbstractTest {
     public void onPublishNotificationAlarmServiceTest() {
         NbiNotificationsListenerImpl listener = new NbiNotificationsListenerImpl(Map.of("test", publisherService),
                 Map.of("test", publisherAlarm));
-        PublishNotificationAlarmService notification = new PublishNotificationAlarmServiceBuilder().setTopic("test")
-                .setConnectionType(ConnectionType.Service).setMessage("The service is now inService")
-                .setOperationalState(State.OutOfService).setServiceName("service name").build();
+        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 onPublishNotificationAlarmServiceWrongTopicTest() {
+    public void onPublishNotificationAlarmServiceWrongPublisherTest() {
         NbiNotificationsListenerImpl listener = new NbiNotificationsListenerImpl(Map.of("test", publisherService),
                 Map.of("test", publisherAlarm));
         PublishNotificationAlarmService notification = new PublishNotificationAlarmServiceBuilder()
-                .setTopic("wrongtopic").setConnectionType(ConnectionType.Service)
-                .setMessage("The service is now inService").setOperationalState(State.OutOfService)
-                .setServiceName("service name").build();
+                .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());
     }