c2ea4b72dfc3cc3c0a3121e45148bbe317703279
[transportpce.git] / networkmodel / src / test / java / org / opendaylight / transportpce / networkmodel / NetworkModelProviderTest.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.networkmodel;
9
10 import static org.mockito.ArgumentMatchers.any;
11 import static org.mockito.Mockito.times;
12 import static org.mockito.Mockito.verify;
13 import static org.mockito.Mockito.when;
14
15 import com.google.common.util.concurrent.FluentFuture;
16 import org.junit.Test;
17 import org.junit.runner.RunWith;
18 import org.mockito.Mock;
19 import org.mockito.invocation.InvocationOnMock;
20 import org.mockito.junit.MockitoJUnitRunner;
21 import org.mockito.stubbing.Answer;
22 import org.opendaylight.mdsal.binding.api.RpcProviderService;
23 import org.opendaylight.mdsal.common.api.CommitInfo;
24 import org.opendaylight.transportpce.common.network.NetworkTransactionService;
25 import org.opendaylight.transportpce.test.AbstractTest;
26 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.networkutils.rev170818.TransportpceNetworkutilsService;
27
28
29 @RunWith(MockitoJUnitRunner.StrictStubs.class)
30 public class NetworkModelProviderTest extends AbstractTest {
31     @Mock
32     NetworkTransactionService networkTransactionService;
33     @Mock
34     RpcProviderService rpcProviderService;
35     @Mock
36     TransportpceNetworkutilsService networkutilsService;
37     @Mock
38     NetConfTopologyListener topologyListener;
39
40
41     @Test
42     public void networkmodelProviderInitTest() {
43         NetworkModelProvider provider = new NetworkModelProvider(networkTransactionService, getDataBroker(),
44             rpcProviderService, networkutilsService, topologyListener);
45         Answer<FluentFuture<CommitInfo>> answer = new Answer<FluentFuture<CommitInfo>>() {
46
47             @Override
48             public FluentFuture<CommitInfo> answer(InvocationOnMock invocation) throws Throwable {
49                 return CommitInfo.emptyFluentFuture();
50             }
51
52         };
53         when(networkTransactionService.commit()).then(answer);
54
55         provider.init();
56
57         verify(rpcProviderService, times(1))
58             .registerRpcImplementation(any(), any(TransportpceNetworkutilsService.class));
59     }
60
61 }