Refactor nbinotifications
[transportpce.git] / nbinotifications / src / test / java / org / opendaylight / transportpce / nbinotifications / impl / NbiNotificationsImplTest.java
index deb7c0b2f57a737064bc8e27971c7968b6c28c6f..4bb418e842280fa8f8d035feec6167d5941ce69f 100644 (file)
@@ -15,6 +15,11 @@ import com.google.common.util.concurrent.ListenableFuture;
 import java.util.concurrent.ExecutionException;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.opendaylight.mdsal.binding.api.NotificationService;
+import org.opendaylight.mdsal.binding.api.RpcProviderService;
 import org.opendaylight.transportpce.common.converter.JsonStringConverter;
 import org.opendaylight.transportpce.common.network.NetworkTransactionImpl;
 import org.opendaylight.transportpce.common.network.NetworkTransactionService;
@@ -38,8 +43,15 @@ import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev22112
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev221121.GetNotificationListOutput;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 
+@ExtendWith(MockitoExtension.class)
 public class NbiNotificationsImplTest extends AbstractTest {
-    private NbiNotificationsImpl nbiNotificationsImpl;
+
+    @Mock
+    RpcProviderService rpcProviderRegistry;
+    @Mock
+    private NotificationService notificationService;
+
+    private NbiNotificationsProvider nbiNotifications;
     public static NetworkTransactionService networkTransactionService;
     private TopicManager topicManager;
     private JsonStringConverter<NotificationProcessService> converterProcess;
@@ -56,23 +68,24 @@ public class NbiNotificationsImplTest extends AbstractTest {
         topicManager.setTapiConverter(converterTapi);
         NotificationServiceDataUtils.createTapiContext(networkTransactionService);
 
-        nbiNotificationsImpl = new NbiNotificationsImpl(converterProcess, converterAlarm, converterTapi,
-            "localhost:8080", networkTransactionService, topicManager);
+        nbiNotifications = new NbiNotificationsProvider("localhost:8080", "localhost:8080",
+                rpcProviderRegistry, notificationService, getDataStoreContextUtil().getBindingDOMCodecServices(),
+                networkTransactionService);
     }
 
     @Test
     void getNotificationsServiceEmptyDataTest() throws InterruptedException, ExecutionException {
         ListenableFuture<RpcResult<GetNotificationsProcessServiceOutput>> result =
-                new GetNotificationsProcessServiceImpl(converterProcess, "localhost:8080").invoke(
-                        new GetNotificationsProcessServiceInputBuilder().build());
+            new GetNotificationsProcessServiceImpl(converterProcess, "localhost:8080")
+                .invoke(new GetNotificationsProcessServiceInputBuilder().build());
         assertNull(result.get().getResult().getNotificationsProcessService(), "Should be null");
     }
 
     @Test
     void getNotificationsServiceTest() throws InterruptedException, ExecutionException {
         ListenableFuture<RpcResult<GetNotificationsProcessServiceOutput>> result =
-                new GetNotificationsProcessServiceImpl(converterProcess, "localhost:8080")
-            .invoke(new GetNotificationsProcessServiceInputBuilder()
+            new GetNotificationsProcessServiceImpl(converterProcess, "localhost:8080")
+                .invoke(new GetNotificationsProcessServiceInputBuilder()
                     .setGroupId("groupId")
                     .setIdConsumer("consumerId")
                     .setConnectionType(ConnectionType.Service)
@@ -83,8 +96,8 @@ public class NbiNotificationsImplTest extends AbstractTest {
     @Test
     void getNotificationsAlarmServiceTest() throws InterruptedException, ExecutionException {
         ListenableFuture<RpcResult<GetNotificationsAlarmServiceOutput>> result =
-                new GetNotificationsAlarmServiceImpl(converterAlarm, "localhost:8080")
-            .invoke(new GetNotificationsAlarmServiceInputBuilder()
+            new GetNotificationsAlarmServiceImpl(converterAlarm, "localhost:8080")
+                .invoke(new GetNotificationsAlarmServiceInputBuilder()
                     .setGroupId("groupId")
                     .setIdConsumer("consumerId")
                     .setConnectionType(ConnectionType.Service)
@@ -95,8 +108,8 @@ public class NbiNotificationsImplTest extends AbstractTest {
     @Test
     void createTapiNotificationSubscriptionServiceTest() throws InterruptedException, ExecutionException {
         ListenableFuture<RpcResult<CreateNotificationSubscriptionServiceOutput>> result =
-                new CreateNotificationSubscriptionServiceImpl(nbiNotificationsImpl, topicManager)
-            .invoke(NotificationServiceDataUtils.buildNotificationSubscriptionServiceInputBuilder().build());
+            new CreateNotificationSubscriptionServiceImpl(nbiNotifications, topicManager)
+                .invoke(NotificationServiceDataUtils.buildNotificationSubscriptionServiceInputBuilder().build());
         assertNotNull(result.get().getResult().getSubscriptionService().getUuid().toString(),
             "Should receive UUID for subscription service");
     }
@@ -104,11 +117,11 @@ public class NbiNotificationsImplTest extends AbstractTest {
     @Test
     void getTapiNotificationsServiceTest() throws InterruptedException, ExecutionException {
         ListenableFuture<RpcResult<CreateNotificationSubscriptionServiceOutput>> result =
-                new CreateNotificationSubscriptionServiceImpl(nbiNotificationsImpl, topicManager)
+                new CreateNotificationSubscriptionServiceImpl(nbiNotifications, topicManager)
             .invoke(NotificationServiceDataUtils.buildNotificationSubscriptionServiceInputBuilder().build());
         ListenableFuture<RpcResult<GetNotificationListOutput>> result2 =
-                new GetNotificationListImpl(converterTapi, "localhost:8080", networkTransactionService, topicManager)
-            .invoke(new GetNotificationListInputBuilder()
+            new GetNotificationListImpl(converterTapi, "localhost:8080", networkTransactionService, topicManager)
+                .invoke(new GetNotificationListInputBuilder()
                     .setTimeRange(null)
                     .setSubscriptionId(result.get().getResult().getSubscriptionService().getUuid())
                     .build());