2 * Copyright (c) 2016 Cisco Systems, 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.openflowplugin.applications.frsync.impl;
10 import org.junit.After;
11 import org.junit.Before;
12 import org.junit.Test;
13 import org.junit.runner.RunWith;
14 import org.mockito.ArgumentMatchers;
15 import org.mockito.Mock;
16 import org.mockito.Mockito;
17 import org.mockito.runners.MockitoJUnitRunner;
18 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
19 import org.opendaylight.controller.md.sal.binding.api.DataTreeChangeListener;
20 import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier;
21 import org.opendaylight.controller.sal.binding.api.RpcConsumerRegistry;
22 import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.SalFlatBatchService;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.SalTableService;
26 import org.opendaylight.yangtools.yang.binding.RpcService;
29 * Test for {@link ForwardingRulesSyncProvider}.
31 @RunWith(MockitoJUnitRunner.class)
32 public class ForwardingRulesSyncProviderTest {
34 private ForwardingRulesSyncProvider provider;
36 private DataBroker dataBroker;
38 private RpcConsumerRegistry rpcRegistry;
40 private ClusterSingletonServiceProvider clusterSingletonService;
43 public void setUp() throws Exception {
44 Mockito.when(rpcRegistry.getRpcService(ArgumentMatchers.<Class<? extends RpcService>>any()))
45 .thenAnswer(invocation -> {
46 Class<? extends RpcService> serviceType =
47 (Class<? extends RpcService>) invocation.getArguments()[0];
48 return Mockito.mock(serviceType);
51 provider = new ForwardingRulesSyncProvider(dataBroker, rpcRegistry, clusterSingletonService);
52 Mockito.verify(rpcRegistry).getRpcService(SalTableService.class);
53 Mockito.verify(rpcRegistry).getRpcService(SalFlatBatchService.class);
57 public void testInit() throws Exception {
60 Mockito.verify(dataBroker, Mockito.times(2)).registerDataTreeChangeListener(
61 ArgumentMatchers.<DataTreeIdentifier<FlowCapableNode>>any(),
62 ArgumentMatchers.<DataTreeChangeListener<FlowCapableNode>>any());
66 public void tearDown() {