2 * Copyright © 2020 Orange, Inc. and others. All rights reserved.
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
8 package org.opendaylight.transportpce.networkmodel;
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;
15 import com.google.common.util.concurrent.FluentFuture;
16 import org.junit.jupiter.api.Test;
17 import org.junit.jupiter.api.extension.ExtendWith;
18 import org.mockito.Mock;
19 import org.mockito.invocation.InvocationOnMock;
20 import org.mockito.junit.jupiter.MockitoExtension;
21 import org.mockito.stubbing.Answer;
22 import org.opendaylight.mdsal.binding.api.DataBroker;
23 import org.opendaylight.mdsal.binding.api.NotificationService;
24 import org.opendaylight.mdsal.binding.api.RpcProviderService;
25 import org.opendaylight.mdsal.common.api.CommitInfo;
26 import org.opendaylight.transportpce.common.device.DeviceTransactionManager;
27 import org.opendaylight.transportpce.common.mapping.PortMapping;
28 import org.opendaylight.transportpce.common.network.NetworkTransactionService;
29 import org.opendaylight.transportpce.networkmodel.service.FrequenciesService;
30 import org.opendaylight.transportpce.networkmodel.service.NetworkModelService;
31 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.networkutils.rev220630.TransportpceNetworkutilsService;
33 @ExtendWith(MockitoExtension.class)
34 public class NetworkModelProviderTest {
36 NetworkTransactionService networkTransactionService;
38 DataBroker dataBroker;
40 RpcProviderService rpcProviderService;
42 NetworkModelService networkModelService;
44 DeviceTransactionManager deviceTransactionManager;
46 PortMapping portMapping;
48 NetConfTopologyListener topologyListener;
50 NotificationService notificationService;
52 FrequenciesService frequenciesService;
54 TransportpceNetworkutilsService networkUtils;
57 void networkmodelProviderInitTest() {
58 Answer<FluentFuture<CommitInfo>> answer = new Answer<FluentFuture<CommitInfo>>() {
61 public FluentFuture<CommitInfo> answer(InvocationOnMock invocation) throws Throwable {
62 return CommitInfo.emptyFluentFuture();
66 when(networkTransactionService.commit()).then(answer);
68 new NetworkModelProvider(networkTransactionService, dataBroker, rpcProviderService, networkModelService,
69 deviceTransactionManager, portMapping, notificationService, frequenciesService, networkUtils);
71 verify(rpcProviderService, times(1))
72 .registerRpcImplementation(any(), any(TransportpceNetworkutilsService.class));
73 verify(dataBroker, times(2)).registerDataTreeChangeListener(any(), any());