Merge changes from topic "nbinotification"
[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.rev201130.GetNotificationsServiceInputBuilder;
20 import org.opendaylight.yang.gen.v1.nbi.notifications.rev201130.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.rev201130.NotificationService> converter = new JsonStringConverter<>(
30                 getDataStoreContextUtil().getBindingDOMCodecServices());
31         nbiNotificationsImpl = new NbiNotificationsImpl(converter, "localhost:8080");
32     }
33
34     public void getNotificationsServiceEmptyDataTest() throws InterruptedException, ExecutionException {
35         ListenableFuture<RpcResult<GetNotificationsServiceOutput>> result =
36                 nbiNotificationsImpl.getNotificationsService(new GetNotificationsServiceInputBuilder().build());
37         assertNull("Should be null", result.get().getResult().getNotificationService());
38     }
39
40     @Test
41     public void getNotificationsServiceTest() throws InterruptedException, ExecutionException {
42         GetNotificationsServiceInputBuilder builder = new GetNotificationsServiceInputBuilder();
43         builder.setGroupId("groupId");
44         builder.setIdConsumer("consumerId");
45         builder.setConnectionType(ConnectionType.Service);
46         ListenableFuture<RpcResult<GetNotificationsServiceOutput>> result =
47                 nbiNotificationsImpl.getNotificationsService(builder.build());
48         assertNull("Should be null", result.get().getResult().getNotificationService());
49     }
50 }