import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
-import com.google.common.base.Optional;
import com.google.common.util.concurrent.CheckedFuture;
import io.netty.util.concurrent.Future;
import java.net.InetSocketAddress;
import java.util.Collections;
import java.util.concurrent.Executor;
-import java.util.concurrent.atomic.LongAdder;
import org.junit.Before;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.opendaylight.protocol.bgp.rib.impl.spi.BGPDispatcher;
import org.opendaylight.protocol.bgp.rib.impl.spi.BGPPeerRegistry;
import org.opendaylight.protocol.bgp.rib.impl.spi.BGPSessionPreferences;
-import org.opendaylight.protocol.bgp.rib.impl.spi.BgpDeployer;
import org.opendaylight.protocol.bgp.rib.impl.spi.ImportPolicyPeerTracker;
import org.opendaylight.protocol.bgp.rib.impl.spi.RIB;
import org.opendaylight.protocol.bgp.rib.impl.spi.RIBSupportContextRegistry;
-import org.opendaylight.protocol.bgp.rib.impl.stats.rib.impl.BGPRenderStats;
import org.opendaylight.protocol.bgp.rib.spi.BGPSessionListener;
+import org.opendaylight.protocol.concepts.KeyMapping;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.BgpRib;
import org.osgi.framework.ServiceRegistration;
class AbstractConfig {
- static final TablesKey TABLES_KEY = new TablesKey(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class);
protected static final AsNumber AS = new AsNumber(72L);
+ protected static final RibId RIB_ID = new RibId("test");
+ static final TablesKey TABLES_KEY = new TablesKey(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class);
protected ClusterSingletonService singletonService;
@Mock
protected RIB rib;
@Mock
protected BGPTableTypeRegistryConsumer tableTypeRegistry;
@Mock
- protected BgpDeployer.WriteConfiguration configurationWriter;
- @Mock
protected DOMTransactionChain domTx;
@Mock
- protected BGPRenderStats render;
- @Mock
protected BGPDispatcher dispatcher;
@Mock
- protected ServiceRegistration serviceRegistration;
+ protected ServiceRegistration<?> serviceRegistration;
@Mock
protected BGPPeerRegistry bgpPeerRegistry;
@Mock
- protected ListenerRegistration listener;
+ protected ListenerRegistration<?> listener;
@Mock
- protected Future future;
+ protected Future<?> future;
@Mock
protected DOMDataWriteTransaction domDW;
@Mock
private ImportPolicyPeerTracker importPolicyPeerTracker;
@Mock
private DOMDataTreeChangeService dataTreeChangeService;
- protected static final RibId RIB_ID = new RibId("test");
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
- Mockito.doAnswer(invocationOnMock->{
+ Mockito.doAnswer(invocationOnMock -> {
this.singletonService = (ClusterSingletonService) invocationOnMock.getArguments()[0];
return this.singletonServiceRegistration;
}).when(this.rib).registerClusterSingletonService(any(ClusterSingletonService.class));
- Mockito.doReturn(new LongAdder()).when(this.render).getConfiguredPeerCounter();
- Mockito.doReturn(this.render).when(this.rib).getRenderStats();
Mockito.doReturn(InstanceIdentifier.create(BgpRib.class).child(org.opendaylight.yang.gen.v1.urn.opendaylight
- .params.xml.ns.yang.bgp.rib.rev130925.bgp.rib.Rib.class, new RibKey(RIB_ID))).when(this.rib)
- .getInstanceIdentifier();
+ .params.xml.ns.yang.bgp.rib.rev130925.bgp.rib.Rib.class, new RibKey(RIB_ID))).when(this.rib)
+ .getInstanceIdentifier();
Mockito.doReturn(this.domTx).when(this.rib).createPeerChain(any(TransactionChainListener.class));
Mockito.doReturn(AS).when(this.rib).getLocalAs();
Mockito.doReturn(this.importPolicyPeerTracker).when(this.rib).getImportPolicyPeerTracker();
Mockito.doNothing().when(this.domDW).put(eq(LogicalDatastoreType.OPERATIONAL), any(YangInstanceIdentifier.class), any(MapEntryNode.class));
Mockito.doNothing().when(this.domDW).delete(eq(LogicalDatastoreType.OPERATIONAL), any(YangInstanceIdentifier.class));
Mockito.doNothing().when(this.domDW).merge(eq(LogicalDatastoreType.OPERATIONAL), any(YangInstanceIdentifier.class), any(NormalizedNode.class));
- final CheckedFuture checkedFuture = mock(CheckedFuture.class);
+ final CheckedFuture<?, ?> checkedFuture = mock(CheckedFuture.class);
Mockito.doAnswer(invocation -> {
final Runnable callback = (Runnable) invocation.getArguments()[0];
callback.run();
Mockito.doReturn(checkedFuture).when(this.domDW).submit();
Mockito.doReturn(null).when(checkedFuture).checkedGet();
Mockito.doReturn(null).when(checkedFuture).get();
+ Mockito.doReturn(true).when(checkedFuture).isDone();
Mockito.doReturn("checkedFuture").when(checkedFuture).toString();
- Mockito.doAnswer(invocationOnMock->{
+ Mockito.doAnswer(invocationOnMock -> {
this.singletonService.closeServiceInstance();
return null;
}).when(this.singletonServiceRegistration).close();
Mockito.doReturn(new BgpId("127.0.0.1")).when(this.rib).getBgpIdentifier();
Mockito.doReturn(true).when(this.future).cancel(true);
Mockito.doReturn(this.future).when(this.dispatcher)
- .createReconnectingClient(any(InetSocketAddress.class), anyInt(), any(Optional.class));
+ .createReconnectingClient(any(InetSocketAddress.class), anyInt(), any(KeyMapping.class));
Mockito.doReturn(this.dispatcher).when(this.rib).getDispatcher();
Mockito.doReturn(java.util.Optional.of(new BgpTableTypeImpl(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class)))
- .when(this.tableTypeRegistry).getTableType(any());
+ .when(this.tableTypeRegistry).getTableType(any());
Mockito.doReturn(java.util.Optional.of(TABLES_KEY)).when(this.tableTypeRegistry).getTableKey(any());
Mockito.doReturn(Collections.singleton(new BgpTableTypeImpl(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class)))
- .when(this.rib).getLocalTables();
- Mockito.doNothing().when(this.configurationWriter).apply();
+ .when(this.rib).getLocalTables();
Mockito.doNothing().when(this.bgpPeerRegistry).addPeer(any(IpAddress.class), any(BGPSessionListener.class), any(BGPSessionPreferences.class));
Mockito.doNothing().when(this.bgpPeerRegistry).removePeer(any(IpAddress.class));