@Override public void run() { for (int j = 0; j < numPerThread; j++) { pool.newCall(methodDescriptor, callOptions); } } });
private void verifyTargetChannel( ChannelPool pool, List<ManagedChannel> channels, ManagedChannel targetChannel) { MethodDescriptor<Color, Money> methodDescriptor = FakeServiceGrpc.METHOD_RECOGNIZE; CallOptions callOptions = CallOptions.DEFAULT; @SuppressWarnings("unchecked") ClientCall<Color, Money> expectedClientCall = Mockito.mock(ClientCall.class); for (ManagedChannel channel : channels) { Mockito.reset(channel); } Mockito.doReturn(expectedClientCall).when(targetChannel).newCall(methodDescriptor, callOptions); ClientCall<Color, Money> actualCall = pool.newCall(methodDescriptor, callOptions); Truth.assertThat(actualCall).isSameAs(expectedClientCall); Mockito.verify(targetChannel, Mockito.times(1)).newCall(methodDescriptor, callOptions); for (ManagedChannel otherChannel : channels) { if (otherChannel != targetChannel) { Mockito.verify(otherChannel, Mockito.never()).newCall(methodDescriptor, callOptions); } } }