2 * Copyright © 2020 Orange, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.transportpce.nbinotifications.impl;
10 import static org.junit.Assert.assertNull;
12 import com.google.common.util.concurrent.ListenableFuture;
13 import java.util.concurrent.ExecutionException;
14 import org.junit.Before;
15 import org.junit.Test;
16 import org.mockito.Mock;
17 import org.opendaylight.transportpce.common.converter.JsonStringConverter;
18 import org.opendaylight.transportpce.common.network.NetworkTransactionImpl;
19 import org.opendaylight.transportpce.common.network.NetworkTransactionService;
20 import org.opendaylight.transportpce.common.network.RequestProcessor;
21 import org.opendaylight.transportpce.nbinotifications.utils.TopicManager;
22 import org.opendaylight.transportpce.test.AbstractTest;
23 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev211210.ConnectionType;
24 import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.GetNotificationsAlarmServiceInputBuilder;
25 import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.GetNotificationsAlarmServiceOutput;
26 import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.GetNotificationsProcessServiceInputBuilder;
27 import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.GetNotificationsProcessServiceOutput;
28 import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.NotificationAlarmService;
29 import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.NotificationProcessService;
30 import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.NotificationTapiService;
31 import org.opendaylight.yangtools.yang.common.RpcResult;
33 public class NbiNotificationsImplTest extends AbstractTest {
34 private NbiNotificationsImpl nbiNotificationsImpl;
35 public static NetworkTransactionService networkTransactionService;
38 private TopicManager topicManager;
42 networkTransactionService = new NetworkTransactionImpl(
43 new RequestProcessor(getDataStoreContextUtil().getDataBroker()));
44 JsonStringConverter<NotificationProcessService> converter = new JsonStringConverter<>(
45 getDataStoreContextUtil().getBindingDOMCodecServices());
46 JsonStringConverter<NotificationAlarmService> converterAlarm = new JsonStringConverter<>(
47 getDataStoreContextUtil().getBindingDOMCodecServices());
48 JsonStringConverter<NotificationTapiService> converterTapi = new JsonStringConverter<>(
49 getDataStoreContextUtil().getBindingDOMCodecServices());
51 nbiNotificationsImpl = new NbiNotificationsImpl(converter, converterAlarm, converterTapi,
52 "localhost:8080", networkTransactionService, topicManager);
56 public void getNotificationsServiceEmptyDataTest() throws InterruptedException, ExecutionException {
57 ListenableFuture<RpcResult<GetNotificationsProcessServiceOutput>> result =
58 nbiNotificationsImpl.getNotificationsProcessService(
59 new GetNotificationsProcessServiceInputBuilder().build());
60 assertNull("Should be null", result.get().getResult().getNotificationsProcessService());
64 public void getNotificationsServiceTest() throws InterruptedException, ExecutionException {
65 GetNotificationsProcessServiceInputBuilder builder = new GetNotificationsProcessServiceInputBuilder()
66 .setGroupId("groupId")
67 .setIdConsumer("consumerId")
68 .setConnectionType(ConnectionType.Service);
69 ListenableFuture<RpcResult<GetNotificationsProcessServiceOutput>> result =
70 nbiNotificationsImpl.getNotificationsProcessService(builder.build());
71 assertNull("Should be null", result.get().getResult().getNotificationsProcessService());
75 public void getNotificationsAlarmServiceTest() throws InterruptedException, ExecutionException {
76 GetNotificationsAlarmServiceInputBuilder builder = new GetNotificationsAlarmServiceInputBuilder()
77 .setGroupId("groupId")
78 .setIdConsumer("consumerId")
79 .setConnectionType(ConnectionType.Service);
80 ListenableFuture<RpcResult<GetNotificationsAlarmServiceOutput>> result =
81 nbiNotificationsImpl.getNotificationsAlarmService(builder.build());
82 assertNull("Should be null", result.get().getResult().getNotificationsAlarmService());