Initial tapi notification implementation
[transportpce.git] / nbinotifications / src / test / java / org / opendaylight / transportpce / nbinotifications / impl / NbiNotificationsImplTest.java
1 /*
2  * Copyright © 2020 Orange, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.transportpce.nbinotifications.impl;
9
10 import static org.junit.Assert.assertNull;
11
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.yangtools.yang.common.RpcResult;
31
32 public class NbiNotificationsImplTest extends AbstractTest {
33     private NbiNotificationsImpl nbiNotificationsImpl;
34     public static NetworkTransactionService networkTransactionService;
35
36     @Mock
37     private TopicManager topicManager;
38
39     @Before
40     public void setUp() {
41         networkTransactionService = new NetworkTransactionImpl(
42             new RequestProcessor(getDataStoreContextUtil().getDataBroker()));
43         JsonStringConverter<NotificationProcessService> converter = new JsonStringConverter<>(
44                 getDataStoreContextUtil().getBindingDOMCodecServices());
45         JsonStringConverter<NotificationAlarmService> converterAlarm = new JsonStringConverter<>(
46                 getDataStoreContextUtil().getBindingDOMCodecServices());
47         nbiNotificationsImpl = new NbiNotificationsImpl(converter, converterAlarm,"localhost:8080",
48             networkTransactionService, topicManager);
49     }
50
51     @Test
52     public void getNotificationsServiceEmptyDataTest() throws InterruptedException, ExecutionException {
53         ListenableFuture<RpcResult<GetNotificationsProcessServiceOutput>> result =
54                 nbiNotificationsImpl.getNotificationsProcessService(
55                         new GetNotificationsProcessServiceInputBuilder().build());
56         assertNull("Should be null", result.get().getResult().getNotificationsProcessService());
57     }
58
59     @Test
60     public void getNotificationsServiceTest() throws InterruptedException, ExecutionException {
61         GetNotificationsProcessServiceInputBuilder builder = new GetNotificationsProcessServiceInputBuilder()
62                 .setGroupId("groupId")
63                 .setIdConsumer("consumerId")
64                 .setConnectionType(ConnectionType.Service);
65         ListenableFuture<RpcResult<GetNotificationsProcessServiceOutput>> result =
66                 nbiNotificationsImpl.getNotificationsProcessService(builder.build());
67         assertNull("Should be null", result.get().getResult().getNotificationsProcessService());
68     }
69
70     @Test
71     public void getNotificationsAlarmServiceTest() throws InterruptedException, ExecutionException {
72         GetNotificationsAlarmServiceInputBuilder builder = new GetNotificationsAlarmServiceInputBuilder()
73                 .setGroupId("groupId")
74                 .setIdConsumer("consumerId")
75                 .setConnectionType(ConnectionType.Service);
76         ListenableFuture<RpcResult<GetNotificationsAlarmServiceOutput>> result =
77                 nbiNotificationsImpl.getNotificationsAlarmService(builder.build());
78         assertNull("Should be null", result.get().getResult().getNotificationsAlarmService());
79     }
80 }