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=21a23225caedf7139e8991a686db88096c23cdc0;hb=942384f299eecdf5163014ff7930b12ce26a2ca3;hp=dc8fdeac0d6804ec11933c029b36186a722dd707;hpb=274148a8d813140f86e1f9770ba992b072c1a5cd;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 dc8fdeac0..21a23225c 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,62 +7,107 @@ */ package org.opendaylight.transportpce.nbinotifications.impl; -import static org.junit.Assert.assertNull; + +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; import com.google.common.util.concurrent.ListenableFuture; import java.util.concurrent.ExecutionException; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; 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.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.rev190531.ConnectionType; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.GetNotificationsAlarmServiceInputBuilder; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.GetNotificationsAlarmServiceOutput; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.GetNotificationsProcessServiceInputBuilder; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.GetNotificationsProcessServiceOutput; -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.http.org.openroadm.common.service.types.rev230526.ConnectionType; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev230728.GetNotificationsAlarmServiceInputBuilder; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev230728.GetNotificationsAlarmServiceOutput; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev230728.GetNotificationsProcessServiceInputBuilder; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev230728.GetNotificationsProcessServiceOutput; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev230728.NotificationAlarmService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev230728.NotificationProcessService; +import org.opendaylight.yang.gen.v1.nbi.notifications.rev230728.NotificationTapiService; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev221121.CreateNotificationSubscriptionServiceInputBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev221121.CreateNotificationSubscriptionServiceOutput; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev221121.GetNotificationListInputBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev221121.GetNotificationListOutput; import org.opendaylight.yangtools.yang.common.RpcResult; public class NbiNotificationsImplTest extends AbstractTest { private NbiNotificationsImpl nbiNotificationsImpl; + public static NetworkTransactionService networkTransactionService; + private TopicManager topicManager; - @Before - public void setUp() { + @BeforeEach + void setUp() throws ExecutionException, InterruptedException { + topicManager = TopicManager.getInstance(); + networkTransactionService = new NetworkTransactionImpl(getDataBroker()); JsonStringConverter converter = new JsonStringConverter<>( getDataStoreContextUtil().getBindingDOMCodecServices()); JsonStringConverter converterAlarm = new JsonStringConverter<>( getDataStoreContextUtil().getBindingDOMCodecServices()); - nbiNotificationsImpl = new NbiNotificationsImpl(converter, converterAlarm,"localhost:8080"); + JsonStringConverter converterTapi = new JsonStringConverter<>( + getDataStoreContextUtil().getBindingDOMCodecServices()); + topicManager.setTapiConverter(converterTapi); + NotificationServiceDataUtils.createTapiContext(networkTransactionService); + + nbiNotificationsImpl = new NbiNotificationsImpl(converter, converterAlarm, converterTapi, + "localhost:8080", networkTransactionService, topicManager); } @Test - public void getNotificationsServiceEmptyDataTest() throws InterruptedException, ExecutionException { + void getNotificationsServiceEmptyDataTest() throws InterruptedException, ExecutionException { ListenableFuture> result = nbiNotificationsImpl.getNotificationsProcessService( new GetNotificationsProcessServiceInputBuilder().build()); - assertNull("Should be null", result.get().getResult().getNotificationsProcessService()); + assertNull(result.get().getResult().getNotificationsProcessService(), "Should be null"); } @Test - public void getNotificationsServiceTest() throws InterruptedException, ExecutionException { + void getNotificationsServiceTest() throws InterruptedException, ExecutionException { GetNotificationsProcessServiceInputBuilder builder = new GetNotificationsProcessServiceInputBuilder() .setGroupId("groupId") .setIdConsumer("consumerId") .setConnectionType(ConnectionType.Service); ListenableFuture> result = nbiNotificationsImpl.getNotificationsProcessService(builder.build()); - assertNull("Should be null", result.get().getResult().getNotificationsProcessService()); + assertNull(result.get().getResult().getNotificationsProcessService(), "Should be null"); } @Test - public void getNotificationsAlarmServiceTest() throws InterruptedException, ExecutionException { + void getNotificationsAlarmServiceTest() throws InterruptedException, ExecutionException { GetNotificationsAlarmServiceInputBuilder builder = new GetNotificationsAlarmServiceInputBuilder() .setGroupId("groupId") .setIdConsumer("consumerId") .setConnectionType(ConnectionType.Service); ListenableFuture> result = nbiNotificationsImpl.getNotificationsAlarmService(builder.build()); - assertNull("Should be null", result.get().getResult().getNotificationsAlarmService()); + assertNull(result.get().getResult().getNotificationsAlarmService(), "Should be null"); + } + + @Test + void createTapiNotificationSubscriptionServiceTest() throws InterruptedException, ExecutionException { + CreateNotificationSubscriptionServiceInputBuilder builder + = NotificationServiceDataUtils.buildNotificationSubscriptionServiceInputBuilder(); + ListenableFuture> result = + nbiNotificationsImpl.createNotificationSubscriptionService(builder.build()); + assertNotNull(result.get().getResult().getSubscriptionService().getUuid().toString(), + "Should receive UUID for subscription service"); + } + + @Test + void getTapiNotificationsServiceTest() throws InterruptedException, ExecutionException { + CreateNotificationSubscriptionServiceInputBuilder builder + = NotificationServiceDataUtils.buildNotificationSubscriptionServiceInputBuilder(); + ListenableFuture> result = + nbiNotificationsImpl.createNotificationSubscriptionService(builder.build()); + GetNotificationListInputBuilder builder1 = new GetNotificationListInputBuilder() + .setTimeRange(null) + .setSubscriptionId(result.get().getResult().getSubscriptionService().getUuid()); + ListenableFuture> result1 = + nbiNotificationsImpl.getNotificationList(builder1.build()); + assertNull(result1.get().getResult().getNotification(), "Should be null"); } }