Refactor NBINotification & add ServiceListener tests
[transportpce.git] / nbinotifications / src / main / java / org / opendaylight / transportpce / nbinotifications / impl / NbiNotificationsImpl.java
index d7201d87ad63fc627f19d1dc88f0a678af5aca1b..60fd5517f71edbe1ce4fd958a665cc868b30f52e 100644 (file)
@@ -11,7 +11,8 @@ import com.google.common.util.concurrent.ListenableFuture;
 import java.util.List;
 import org.opendaylight.transportpce.common.converter.JsonStringConverter;
 import org.opendaylight.transportpce.nbinotifications.consumer.Subscriber;
-import org.opendaylight.transportpce.nbinotifications.consumer.SubscriberAlarm;
+import org.opendaylight.transportpce.nbinotifications.serialization.NotificationAlarmServiceDeserializer;
+import org.opendaylight.transportpce.nbinotifications.serialization.NotificationServiceDeserializer;
 import org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.GetNotificationsAlarmServiceInput;
 import org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.GetNotificationsAlarmServiceOutput;
 import org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.GetNotificationsAlarmServiceOutputBuilder;
@@ -51,9 +52,11 @@ public class NbiNotificationsImpl implements NbiNotificationsService {
             LOG.warn("Missing mandatory params for input {}", input);
             return RpcResultBuilder.success(new GetNotificationsServiceOutputBuilder().build()).buildFuture();
         }
-        Subscriber subscriber = new Subscriber(input.getIdConsumer(), input.getGroupId(), server, converterService);
+        Subscriber<org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.NotificationService,
+                NotificationService> subscriber = new Subscriber<>(input.getIdConsumer(), input.getGroupId(), server,
+                converterService, NotificationServiceDeserializer.class);
         List<NotificationService> notificationServiceList = subscriber
-                .subscribeService(input.getConnectionType().getName());
+                .subscribe(input.getConnectionType().getName(), NotificationService.QNAME);
         GetNotificationsServiceOutputBuilder output = new GetNotificationsServiceOutputBuilder()
                 .setNotificationService(notificationServiceList);
         return RpcResultBuilder.success(output.build()).buildFuture();
@@ -67,10 +70,11 @@ public class NbiNotificationsImpl implements NbiNotificationsService {
             LOG.warn("Missing mandatory params for input {}", input);
             return RpcResultBuilder.success(new GetNotificationsAlarmServiceOutputBuilder().build()).buildFuture();
         }
-        SubscriberAlarm subscriberAlarm = new SubscriberAlarm(input.getIdConsumer(), input.getGroupId(), server,
-                converterAlarmService);
-        List<NotificationAlarmService> notificationAlarmServiceList = subscriberAlarm
-                .subscribeAlarm("alarm" + input.getConnectionType().getName());
+        Subscriber<org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.NotificationAlarmService,
+                NotificationAlarmService> subscriber = new Subscriber<>(input.getIdConsumer(), input.getGroupId(),
+                server, converterAlarmService, NotificationAlarmServiceDeserializer.class);
+        List<NotificationAlarmService> notificationAlarmServiceList = subscriber
+                .subscribe("alarm" + input.getConnectionType().getName(), NotificationAlarmService.QNAME);
         GetNotificationsAlarmServiceOutputBuilder output = new GetNotificationsAlarmServiceOutputBuilder()
                 .setNotificationAlarmService(notificationAlarmServiceList);
         return RpcResultBuilder.success(output.build()).buildFuture();