Initial tapi notification implementation
[transportpce.git] / nbinotifications / src / test / java / org / opendaylight / transportpce / nbinotifications / impl / NbiNotificationsProviderTest.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.mockito.ArgumentMatchers.any;
11 import static org.mockito.Mockito.times;
12 import static org.mockito.Mockito.verify;
13
14 import java.util.Arrays;
15 import org.junit.Before;
16 import org.junit.Test;
17 import org.mockito.Mock;
18 import org.mockito.MockitoAnnotations;
19 import org.opendaylight.mdsal.binding.api.NotificationService;
20 import org.opendaylight.mdsal.binding.api.RpcProviderService;
21 import org.opendaylight.transportpce.common.network.NetworkTransactionImpl;
22 import org.opendaylight.transportpce.common.network.NetworkTransactionService;
23 import org.opendaylight.transportpce.common.network.RequestProcessor;
24 import org.opendaylight.transportpce.nbinotifications.listener.NbiNotificationsListenerImpl;
25 import org.opendaylight.transportpce.test.AbstractTest;
26
27 public class NbiNotificationsProviderTest  extends AbstractTest {
28     public static NetworkTransactionService networkTransactionService;
29
30     @Mock
31     RpcProviderService rpcProviderRegistry;
32
33     @Mock
34     private NotificationService notificationService;
35
36     @Before
37     public void init() {
38         MockitoAnnotations.openMocks(this);
39
40     }
41
42     @Test
43     public void initTest() {
44         networkTransactionService = new NetworkTransactionImpl(
45             new RequestProcessor(getDataStoreContextUtil().getDataBroker()));
46         NbiNotificationsProvider provider = new NbiNotificationsProvider(
47                 Arrays.asList("topic1", "topic2"), Arrays.asList("topic1", "topic2"), "localhost:8080",
48                 "localhost:8080", rpcProviderRegistry, notificationService,
49                 getDataStoreContextUtil().getBindingDOMCodecServices(), networkTransactionService);
50         provider.init();
51         verify(rpcProviderRegistry, times(2))
52                 .registerRpcImplementation(any(), any(NbiNotificationsImpl.class));
53         verify(notificationService, times(1))
54                 .registerNotificationListener(any(NbiNotificationsListenerImpl.class));
55     }
56 }