Add service listener to notify Kafka
[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.opendaylight.transportpce.common.converter.JsonStringConverter;
17 import org.opendaylight.transportpce.test.AbstractTest;
18 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.ConnectionType;
19 import org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.GetNotificationsServiceInputBuilder;
20 import org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.GetNotificationsServiceOutput;
21 import org.opendaylight.yangtools.yang.common.RpcResult;
22
23 public class NbiNotificationsImplTest extends AbstractTest {
24     private NbiNotificationsImpl nbiNotificationsImpl;
25
26     @Before
27     public void setUp() {
28         JsonStringConverter<org.opendaylight.yang.gen.v1
29             .nbi.notifications.rev210628.NotificationService> converter = new JsonStringConverter<>(
30                 getDataStoreContextUtil().getBindingDOMCodecServices());
31         JsonStringConverter<org.opendaylight.yang.gen.v1
32                 .nbi.notifications.rev210628.NotificationAlarmService> converterAlarm = new JsonStringConverter<>(
33                 getDataStoreContextUtil().getBindingDOMCodecServices());
34         nbiNotificationsImpl = new NbiNotificationsImpl(converter, converterAlarm,"localhost:8080");
35     }
36
37     public void getNotificationsServiceEmptyDataTest() throws InterruptedException, ExecutionException {
38         ListenableFuture<RpcResult<GetNotificationsServiceOutput>> result =
39                 nbiNotificationsImpl.getNotificationsService(new GetNotificationsServiceInputBuilder().build());
40         assertNull("Should be null", result.get().getResult().getNotificationService());
41     }
42
43     @Test
44     public void getNotificationsServiceTest() throws InterruptedException, ExecutionException {
45         GetNotificationsServiceInputBuilder builder = new GetNotificationsServiceInputBuilder();
46         builder.setGroupId("groupId");
47         builder.setIdConsumer("consumerId");
48         builder.setConnectionType(ConnectionType.Service);
49         ListenableFuture<RpcResult<GetNotificationsServiceOutput>> result =
50                 nbiNotificationsImpl.getNotificationsService(builder.build());
51         assertNull("Should be null", result.get().getResult().getNotificationService());
52     }
53 }