X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=nbinotifications%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Ftransportpce%2Fnbinotifications%2Fimpl%2FNbiNotificationsImplTest.java;h=bc025c5d0f6959976a5280a5749d52eecb828742;hb=72726c942bab51f2d1081e83e2b9ac8aa6481122;hp=018c2d62257796d9afdf3bc7d09ec4c8717b1730;hpb=5b61d96f9251589244940215ee9f62e7ff204d11;p=transportpce.git diff --git a/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/impl/NbiNotificationsImplTest.java b/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/impl/NbiNotificationsImplTest.java index 018c2d622..bc025c5d0 100644 --- a/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/impl/NbiNotificationsImplTest.java +++ b/nbinotifications/src/test/java/org/opendaylight/transportpce/nbinotifications/impl/NbiNotificationsImplTest.java @@ -7,17 +7,18 @@ */ package org.opendaylight.transportpce.nbinotifications.impl; +import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import com.google.common.util.concurrent.ListenableFuture; import java.util.concurrent.ExecutionException; import org.junit.Before; import org.junit.Test; -import org.mockito.Mock; import org.opendaylight.transportpce.common.converter.JsonStringConverter; import org.opendaylight.transportpce.common.network.NetworkTransactionImpl; import org.opendaylight.transportpce.common.network.NetworkTransactionService; import org.opendaylight.transportpce.common.network.RequestProcessor; +import org.opendaylight.transportpce.nbinotifications.utils.NotificationServiceDataUtils; import org.opendaylight.transportpce.nbinotifications.utils.TopicManager; import org.opendaylight.transportpce.test.AbstractTest; import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev211210.ConnectionType; @@ -28,17 +29,20 @@ import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.GetNotifications import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.NotificationAlarmService; import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.NotificationProcessService; import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.NotificationTapiService; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.CreateNotificationSubscriptionServiceInputBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.CreateNotificationSubscriptionServiceOutput; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.GetNotificationListInputBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.GetNotificationListOutput; import org.opendaylight.yangtools.yang.common.RpcResult; public class NbiNotificationsImplTest extends AbstractTest { private NbiNotificationsImpl nbiNotificationsImpl; public static NetworkTransactionService networkTransactionService; - - @Mock private TopicManager topicManager; @Before - public void setUp() { + public void setUp() throws ExecutionException, InterruptedException { + topicManager = TopicManager.getInstance(); networkTransactionService = new NetworkTransactionImpl( new RequestProcessor(getDataStoreContextUtil().getDataBroker())); JsonStringConverter converter = new JsonStringConverter<>( @@ -47,6 +51,8 @@ public class NbiNotificationsImplTest extends AbstractTest { getDataStoreContextUtil().getBindingDOMCodecServices()); JsonStringConverter converterTapi = new JsonStringConverter<>( getDataStoreContextUtil().getBindingDOMCodecServices()); + topicManager.setTapiConverter(converterTapi); + NotificationServiceDataUtils.createTapiContext(networkTransactionService); nbiNotificationsImpl = new NbiNotificationsImpl(converter, converterAlarm, converterTapi, "localhost:8080", networkTransactionService, topicManager); @@ -81,4 +87,28 @@ public class NbiNotificationsImplTest extends AbstractTest { nbiNotificationsImpl.getNotificationsAlarmService(builder.build()); assertNull("Should be null", result.get().getResult().getNotificationsAlarmService()); } + + @Test + public void createTapiNotificationSubscriptionServiceTest() throws InterruptedException, ExecutionException { + CreateNotificationSubscriptionServiceInputBuilder builder + = NotificationServiceDataUtils.buildNotificationSubscriptionServiceInputBuilder(); + ListenableFuture> result = + nbiNotificationsImpl.createNotificationSubscriptionService(builder.build()); + assertNotNull("Should receive UUID for subscription service", + result.get().getResult().getSubscriptionService().getUuid().toString()); + } + + @Test + public void getTapiNotificationsServiceTest() throws InterruptedException, ExecutionException { + CreateNotificationSubscriptionServiceInputBuilder builder + = NotificationServiceDataUtils.buildNotificationSubscriptionServiceInputBuilder(); + ListenableFuture> result = + nbiNotificationsImpl.createNotificationSubscriptionService(builder.build()); + GetNotificationListInputBuilder builder1 = new GetNotificationListInputBuilder() + .setTimePeriod("Time Period") + .setSubscriptionIdOrName(result.get().getResult().getSubscriptionService().getUuid().getValue()); + ListenableFuture> result1 = + nbiNotificationsImpl.getNotificationList(builder1.build()); + assertNull("Should be null", result1.get().getResult().getNotification()); + } }