Skip to content
This repository has been archived by the owner on Sep 26, 2023. It is now read-only.

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
igorbernstein2 committed Nov 22, 2021
1 parent 41e9e9d commit 6a8d3eb
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,8 @@ public void channelPrimerIsCalledPeriodically() throws IOException {

Mockito.doAnswer(extractChannelRefresher)
.when(scheduledExecutorService)
.schedule(
Mockito.any(Runnable.class), Mockito.anyLong(), Mockito.eq(TimeUnit.MILLISECONDS));
.scheduleAtFixedRate(
Mockito.any(Runnable.class), Mockito.anyLong(), Mockito.anyLong(), Mockito.any());

FakeChannelFactory channelFactory =
new FakeChannelFactory(Arrays.asList(channel1, channel2, channel3), mockChannelPrimer);
Expand All @@ -211,26 +211,16 @@ public void channelPrimerIsCalledPeriodically() throws IOException {
// 1 call during the creation
Mockito.verify(mockChannelPrimer, Mockito.times(1))
.primeChannel(Mockito.any(ManagedChannel.class));
Mockito.verify(scheduledExecutorService, Mockito.times(1))
.schedule(
Mockito.any(Runnable.class), Mockito.anyLong(), Mockito.eq(TimeUnit.MILLISECONDS));

channelRefreshers.get(0).run();
// 1 more call during channel refresh
Mockito.verify(mockChannelPrimer, Mockito.times(2))
.primeChannel(Mockito.any(ManagedChannel.class));
Mockito.verify(scheduledExecutorService, Mockito.times(2))
.schedule(
Mockito.any(Runnable.class), Mockito.anyLong(), Mockito.eq(TimeUnit.MILLISECONDS));

channelRefreshers.get(0).run();
// 1 more call during channel refresh
Mockito.verify(mockChannelPrimer, Mockito.times(3))
.primeChannel(Mockito.any(ManagedChannel.class));
Mockito.verify(scheduledExecutorService, Mockito.times(3))
.schedule(
Mockito.any(Runnable.class), Mockito.anyLong(), Mockito.eq(TimeUnit.MILLISECONDS));
scheduledExecutorService.shutdown();
}

// ----
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;

import com.google.api.core.ApiFunction;
import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider.Builder;
Expand Down

0 comments on commit 6a8d3eb

Please sign in to comment.