import io.netty.util.concurrent.Future;
import java.net.InetSocketAddress;
import java.util.Collections;
+import java.util.concurrent.Executor;
import org.junit.Before;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.osgi.framework.ServiceRegistration;
class AbstractConfig {
- protected static final AsNumber AS = new AsNumber(123456L);
+ protected static final AsNumber AS = new AsNumber(72L);
@Mock
protected RIB rib;
@Mock
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
- Mockito.doAnswer(new Answer<ClusterSingletonServiceRegistration>() {
- @Override
- public ClusterSingletonServiceRegistration answer(final InvocationOnMock invocationOnMock) throws Throwable {
- singletonService = (ClusterSingletonService) invocationOnMock.getArguments()[0];
- return singletonServiceRegistration;
- }
+ Mockito.doAnswer(invocationOnMock->{
+ this.singletonService = (ClusterSingletonService) invocationOnMock.getArguments()[0];
+ return this.singletonServiceRegistration;
}).when(this.rib).registerClusterSingletonService(any(ClusterSingletonService.class));
-
Mockito.doReturn(new UnsignedInt32Counter("counter")).when(this.render).getConfiguredPeerCounter();
Mockito.doReturn(this.render).when(this.rib).getRenderStats();
Mockito.doReturn(this.domTx).when(this.rib).createPeerChain(any(TransactionChainListener.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);
+ Mockito.doAnswer(new Answer<Void>() {
+ @Override
+ public Void answer(final InvocationOnMock invocation) throws Throwable {
+ final Runnable callback = (Runnable) invocation.getArguments()[0];
+ callback.run();
+ return null;
+ }
+ }).when(checkedFuture).addListener(Mockito.any(Runnable.class), Mockito.any(Executor.class));
Mockito.doReturn(checkedFuture).when(this.domDW).submit();
Mockito.doReturn(null).when(checkedFuture).checkedGet();
+ Mockito.doReturn(null).when(checkedFuture).get();
+ Mockito.doReturn("checkedFuture").when(checkedFuture).toString();
Mockito.doNothing().when(this.singletonServiceRegistration).close();
Mockito.doReturn(YangInstanceIdentifier.of(Rib.QNAME)).when(this.rib).getYangRibId();
Mockito.doReturn(this.listener).when(this.dataTreeChangeService).registerDataTreeChangeListener(any(), any());
Mockito.doReturn(mock(ServiceGroupIdentifier.class)).when(this.rib).getRibIServiceGroupIdentifier();
Mockito.doReturn(new BgpId("127.0.0.1")).when(this.rib).getBgpIdentifier();
- Mockito.doReturn(true).when(future).cancel(true);
- Mockito.doReturn(future).when(this.dispatcher)
+ Mockito.doReturn(true).when(this.future).cancel(true);
+ Mockito.doReturn(this.future).when(this.dispatcher)
.createReconnectingClient(any(InetSocketAddress.class), any(BGPPeerRegistry.class), anyInt(), any(Optional.class));
Mockito.doReturn(this.dispatcher).when(this.rib).getDispatcher();