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.common.api.CommitInfo;
25 import org.opendaylight.transportpce.common.device.DeviceTransactionManager;
26 import org.opendaylight.transportpce.common.mapping.PortMapping;
27 import org.opendaylight.transportpce.common.network.NetworkTransactionService;
28 import org.opendaylight.transportpce.networkmodel.service.FrequenciesService;
29 import org.opendaylight.transportpce.networkmodel.service.NetworkModelService;
31 @ExtendWith(MockitoExtension.class)
32 public class NetworkModelProviderTest {
34 NetworkTransactionService networkTransactionService;
36 DataBroker dataBroker;
38 NetworkModelService networkModelService;
40 DeviceTransactionManager deviceTransactionManager;
42 PortMapping portMapping;
44 NetConfTopologyListener topologyListener;
46 NotificationService notificationService;
48 FrequenciesService frequenciesService;
51 void networkmodelProviderInitTest() {
52 Answer<FluentFuture<CommitInfo>> answer = new Answer<FluentFuture<CommitInfo>>() {
55 public FluentFuture<CommitInfo> answer(InvocationOnMock invocation) throws Throwable {
56 return CommitInfo.emptyFluentFuture();
60 when(networkTransactionService.commit()).then(answer);
62 new NetworkModelProvider(networkTransactionService, dataBroker, networkModelService, deviceTransactionManager,
63 portMapping, notificationService, frequenciesService);
65 verify(dataBroker, times(2)).registerDataTreeChangeListener(any(), any());