*/
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.rev210628.GetNotificationsAlarmServiceInputBuilder;
-import org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.GetNotificationsAlarmServiceOutput;
-import org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.GetNotificationsServiceInputBuilder;
-import org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.GetNotificationsServiceOutput;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.ConnectionType;
+import org.opendaylight.yang.gen.v1.nbi.notifications.rev230726.GetNotificationsAlarmServiceInputBuilder;
+import org.opendaylight.yang.gen.v1.nbi.notifications.rev230726.GetNotificationsAlarmServiceOutput;
+import org.opendaylight.yang.gen.v1.nbi.notifications.rev230726.GetNotificationsProcessServiceInputBuilder;
+import org.opendaylight.yang.gen.v1.nbi.notifications.rev230726.GetNotificationsProcessServiceOutput;
+import org.opendaylight.yang.gen.v1.nbi.notifications.rev230726.NotificationAlarmService;
+import org.opendaylight.yang.gen.v1.nbi.notifications.rev230726.NotificationProcessService;
+import org.opendaylight.yang.gen.v1.nbi.notifications.rev230726.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;
+ private TopicManager topicManager;
- @Before
- public void setUp() {
- JsonStringConverter<org.opendaylight.yang.gen.v1
- .nbi.notifications.rev210628.NotificationService> converter = new JsonStringConverter<>(
+ @BeforeEach
+ void setUp() throws ExecutionException, InterruptedException {
+ topicManager = TopicManager.getInstance();
+ networkTransactionService = new NetworkTransactionImpl(getDataBroker());
+ JsonStringConverter<NotificationProcessService> converter = new JsonStringConverter<>(
getDataStoreContextUtil().getBindingDOMCodecServices());
- JsonStringConverter<org.opendaylight.yang.gen.v1
- .nbi.notifications.rev210628.NotificationAlarmService> converterAlarm = new JsonStringConverter<>(
+ JsonStringConverter<NotificationAlarmService> converterAlarm = new JsonStringConverter<>(
getDataStoreContextUtil().getBindingDOMCodecServices());
- nbiNotificationsImpl = new NbiNotificationsImpl(converter, converterAlarm,"localhost:8080");
+ JsonStringConverter<NotificationTapiService> 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 {
- ListenableFuture<RpcResult<GetNotificationsServiceOutput>> result =
- nbiNotificationsImpl.getNotificationsService(new GetNotificationsServiceInputBuilder().build());
- assertNull("Should be null", result.get().getResult().getNotificationService());
+ void getNotificationsServiceEmptyDataTest() throws InterruptedException, ExecutionException {
+ ListenableFuture<RpcResult<GetNotificationsProcessServiceOutput>> result =
+ nbiNotificationsImpl.getNotificationsProcessService(
+ new GetNotificationsProcessServiceInputBuilder().build());
+ assertNull(result.get().getResult().getNotificationsProcessService(), "Should be null");
}
@Test
- public void getNotificationsServiceTest() throws InterruptedException, ExecutionException {
- GetNotificationsServiceInputBuilder builder = new GetNotificationsServiceInputBuilder()
+ void getNotificationsServiceTest() throws InterruptedException, ExecutionException {
+ GetNotificationsProcessServiceInputBuilder builder = new GetNotificationsProcessServiceInputBuilder()
.setGroupId("groupId")
.setIdConsumer("consumerId")
.setConnectionType(ConnectionType.Service);
- ListenableFuture<RpcResult<GetNotificationsServiceOutput>> result =
- nbiNotificationsImpl.getNotificationsService(builder.build());
- assertNull("Should be null", result.get().getResult().getNotificationService());
+ ListenableFuture<RpcResult<GetNotificationsProcessServiceOutput>> result =
+ nbiNotificationsImpl.getNotificationsProcessService(builder.build());
+ 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<RpcResult<GetNotificationsAlarmServiceOutput>> result =
nbiNotificationsImpl.getNotificationsAlarmService(builder.build());
- assertNull("Should be null", result.get().getResult().getNotificationAlarmService());
+ assertNull(result.get().getResult().getNotificationsAlarmService(), "Should be null");
+ }
+
+ @Test
+ void createTapiNotificationSubscriptionServiceTest() throws InterruptedException, ExecutionException {
+ CreateNotificationSubscriptionServiceInputBuilder builder
+ = NotificationServiceDataUtils.buildNotificationSubscriptionServiceInputBuilder();
+ ListenableFuture<RpcResult<CreateNotificationSubscriptionServiceOutput>> 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<RpcResult<CreateNotificationSubscriptionServiceOutput>> result =
+ nbiNotificationsImpl.createNotificationSubscriptionService(builder.build());
+ GetNotificationListInputBuilder builder1 = new GetNotificationListInputBuilder()
+ .setTimePeriod("Time Period")
+ .setSubscriptionIdOrName(result.get().getResult().getSubscriptionService().getUuid().getValue());
+ ListenableFuture<RpcResult<GetNotificationListOutput>> result1 =
+ nbiNotificationsImpl.getNotificationList(builder1.build());
+ assertNull(result1.get().getResult().getNotification(), "Should be null");
}
}