3333import static com .google .api .gax .grpc .testing .FakeServiceGrpc .METHOD_SERVER_STREAMING_RECOGNIZE ;
3434import static com .google .common .truth .Truth .assertThat ;
3535import static org .junit .jupiter .api .Assertions .assertThrows ;
36+ import static org .mockito .Mockito .mock ;
3637
3738import com .google .api .core .ApiFuture ;
3839import com .google .api .gax .core .FixedExecutorProvider ;
@@ -91,8 +92,8 @@ void cleanup() throws InterruptedException {
9192
9293 @ Test
9394 void testAuthority () throws IOException {
94- ManagedChannel sub1 = Mockito . mock (ManagedChannel .class );
95- ManagedChannel sub2 = Mockito . mock (ManagedChannel .class );
95+ ManagedChannel sub1 = mock (ManagedChannel .class );
96+ ManagedChannel sub2 = mock (ManagedChannel .class );
9697
9798 Mockito .when (sub1 .authority ()).thenReturn ("myAuth" );
9899
@@ -106,8 +107,8 @@ void testAuthority() throws IOException {
106107
107108 @ Test
108109 void testRoundRobin () throws IOException {
109- ManagedChannel sub1 = Mockito . mock (ManagedChannel .class );
110- ManagedChannel sub2 = Mockito . mock (ManagedChannel .class );
110+ ManagedChannel sub1 = mock (ManagedChannel .class );
111+ ManagedChannel sub2 = mock (ManagedChannel .class );
111112
112113 Mockito .when (sub1 .authority ()).thenReturn ("myAuth" );
113114
@@ -128,7 +129,7 @@ private void verifyTargetChannel(
128129 MethodDescriptor <Color , Money > methodDescriptor = METHOD_RECOGNIZE ;
129130 CallOptions callOptions = CallOptions .DEFAULT ;
130131 @ SuppressWarnings ("unchecked" )
131- ClientCall <Color , Money > expectedClientCall = Mockito . mock (ClientCall .class );
132+ ClientCall <Color , Money > expectedClientCall = mock (ClientCall .class );
132133
133134 channels .forEach (Mockito ::reset );
134135 Mockito .doReturn (expectedClientCall ).when (targetChannel ).newCall (methodDescriptor , callOptions );
@@ -148,12 +149,12 @@ private void verifyTargetChannel(
148149 private static ChannelFactory createMockChannelFactory (
149150 List <ManagedChannel > channels , List <ClientCall <Object , Object >> startedCalls ) {
150151 return () -> {
151- ManagedChannel channel = Mockito . mock (ManagedChannel .class );
152+ ManagedChannel channel = mock (ManagedChannel .class );
152153 Mockito .when (channel .newCall (Mockito .any (), Mockito .any ()))
153154 .thenAnswer (
154155 invocation -> {
155156 @ SuppressWarnings ("unchecked" )
156- ClientCall <Object , Object > clientCall = Mockito . mock (ClientCall .class );
157+ ClientCall <Object , Object > clientCall = mock (ClientCall .class );
157158 if (startedCalls != null ) {
158159 startedCalls .add (clientCall );
159160 }
@@ -174,14 +175,14 @@ void ensureEvenDistribution() throws InterruptedException, IOException {
174175 final MethodDescriptor <Color , Money > methodDescriptor = METHOD_RECOGNIZE ;
175176 final CallOptions callOptions = CallOptions .DEFAULT ;
176177 @ SuppressWarnings ("unchecked" )
177- final ClientCall <Color , Money > clientCall = Mockito . mock (ClientCall .class );
178+ final ClientCall <Color , Money > clientCall = mock (ClientCall .class );
178179
179180 for (int i = 0 ; i < numChannels ; i ++) {
180181 final int index = i ;
181182
182183 counts [i ] = new AtomicInteger ();
183184
184- channels [i ] = Mockito . mock (ManagedChannel .class );
185+ channels [i ] = mock (ManagedChannel .class );
185186 Mockito .when (channels [i ].newCall (methodDescriptor , callOptions ))
186187 .thenAnswer (
187188 (ignored ) -> {
@@ -221,9 +222,9 @@ void ensureEvenDistribution() throws InterruptedException, IOException {
221222 // Test channelPrimer is called same number of times as poolSize if executorService is set to null
222223 @ Test
223224 void channelPrimerShouldCallPoolConstruction () throws IOException {
224- ChannelPrimer mockChannelPrimer = Mockito . mock (ChannelPrimer .class );
225- ManagedChannel channel1 = Mockito . mock (ManagedChannel .class );
226- ManagedChannel channel2 = Mockito . mock (ManagedChannel .class );
225+ ChannelPrimer mockChannelPrimer = mock (ChannelPrimer .class );
226+ ManagedChannel channel1 = mock (ManagedChannel .class );
227+ ManagedChannel channel2 = mock (ManagedChannel .class );
227228
228229 pool =
229230 ChannelPool .create (
@@ -239,21 +240,20 @@ void channelPrimerShouldCallPoolConstruction() throws IOException {
239240 // Test channelPrimer is called periodically, if there's an executorService
240241 @ Test
241242 void channelPrimerIsCalledPeriodically () throws IOException {
242- ChannelPrimer mockChannelPrimer = Mockito . mock (ChannelPrimer .class );
243- ManagedChannel channel1 = Mockito . mock (ManagedChannel .class );
244- ManagedChannel channel2 = Mockito . mock (ManagedChannel .class );
245- ManagedChannel channel3 = Mockito . mock (ManagedChannel .class );
243+ ChannelPrimer mockChannelPrimer = mock (ChannelPrimer .class );
244+ ManagedChannel channel1 = mock (ManagedChannel .class );
245+ ManagedChannel channel2 = mock (ManagedChannel .class );
246+ ManagedChannel channel3 = mock (ManagedChannel .class );
246247
247248 List <Runnable > channelRefreshers = new ArrayList <>();
248249
249- ScheduledExecutorService scheduledExecutorService =
250- Mockito .mock (ScheduledExecutorService .class );
250+ ScheduledExecutorService scheduledExecutorService = mock (ScheduledExecutorService .class );
251251 FixedExecutorProvider provider = FixedExecutorProvider .create (scheduledExecutorService );
252252
253253 Answer <?> extractChannelRefresher =
254254 invocation -> {
255255 channelRefreshers .add (invocation .getArgument (0 ));
256- return Mockito . mock (ScheduledFuture .class );
256+ return mock (ScheduledFuture .class );
257257 };
258258
259259 Mockito .doAnswer (extractChannelRefresher )
@@ -290,8 +290,8 @@ void channelPrimerIsCalledPeriodically() throws IOException {
290290 // call should be allowed to complete and the channel should not be shutdown
291291 @ Test
292292 void callShouldCompleteAfterCreation () throws IOException {
293- ManagedChannel underlyingChannel = Mockito . mock (ManagedChannel .class );
294- ManagedChannel replacementChannel = Mockito . mock (ManagedChannel .class );
293+ ManagedChannel underlyingChannel = mock (ManagedChannel .class );
294+ ManagedChannel replacementChannel = mock (ManagedChannel .class );
295295 FakeChannelFactory channelFactory =
296296 new FakeChannelFactory (ImmutableList .of (underlyingChannel , replacementChannel ));
297297 pool = ChannelPool .create (ChannelPoolSettings .staticallySized (1 ), channelFactory , null );
@@ -315,7 +315,7 @@ void callShouldCompleteAfterCreation() throws IOException {
315315
316316 // create a new call on entry
317317 @ SuppressWarnings ("unchecked" )
318- ClientCall .Listener <Integer > listener = Mockito . mock (ClientCall .Listener .class );
318+ ClientCall .Listener <Integer > listener = mock (ClientCall .Listener .class );
319319 ClientCall <String , Integer > call =
320320 pool .newCall (FakeMethodDescriptor .create (), CallOptions .DEFAULT );
321321
@@ -338,8 +338,8 @@ void callShouldCompleteAfterCreation() throws IOException {
338338 // call should be allowed to complete and the channel should not be shutdown
339339 @ Test
340340 void callShouldCompleteAfterStarted () throws IOException {
341- final ManagedChannel underlyingChannel = Mockito . mock (ManagedChannel .class );
342- ManagedChannel replacementChannel = Mockito . mock (ManagedChannel .class );
341+ final ManagedChannel underlyingChannel = mock (ManagedChannel .class );
342+ ManagedChannel replacementChannel = mock (ManagedChannel .class );
343343
344344 FakeChannelFactory channelFactory =
345345 new FakeChannelFactory (ImmutableList .of (underlyingChannel , replacementChannel ));
@@ -364,7 +364,7 @@ void callShouldCompleteAfterStarted() throws IOException {
364364
365365 // create a new call on safeShutdownManagedChannel
366366 @ SuppressWarnings ("unchecked" )
367- ClientCall .Listener <Integer > listener = Mockito . mock (ClientCall .Listener .class );
367+ ClientCall .Listener <Integer > listener = mock (ClientCall .Listener .class );
368368 ClientCall <String , Integer > call =
369369 pool .newCall (FakeMethodDescriptor .create (), CallOptions .DEFAULT );
370370
@@ -383,8 +383,8 @@ void callShouldCompleteAfterStarted() throws IOException {
383383 // Channel should be shutdown after a refresh all the calls have completed
384384 @ Test
385385 void channelShouldShutdown () throws IOException {
386- ManagedChannel underlyingChannel = Mockito . mock (ManagedChannel .class );
387- ManagedChannel replacementChannel = Mockito . mock (ManagedChannel .class );
386+ ManagedChannel underlyingChannel = mock (ManagedChannel .class );
387+ ManagedChannel replacementChannel = mock (ManagedChannel .class );
388388
389389 FakeChannelFactory channelFactory =
390390 new FakeChannelFactory (ImmutableList .of (underlyingChannel , replacementChannel ));
@@ -409,7 +409,7 @@ void channelShouldShutdown() throws IOException {
409409
410410 // create a new call on safeShutdownManagedChannel
411411 @ SuppressWarnings ("unchecked" )
412- ClientCall .Listener <Integer > listener = Mockito . mock (ClientCall .Listener .class );
412+ ClientCall .Listener <Integer > listener = mock (ClientCall .Listener .class );
413413 ClientCall <String , Integer > call =
414414 pool .newCall (FakeMethodDescriptor .create (), CallOptions .DEFAULT );
415415
@@ -426,12 +426,11 @@ void channelShouldShutdown() throws IOException {
426426
427427 @ Test
428428 void channelRefreshShouldSwapChannels () throws IOException {
429- ManagedChannel underlyingChannel1 = Mockito . mock (ManagedChannel .class );
430- ManagedChannel underlyingChannel2 = Mockito . mock (ManagedChannel .class );
429+ ManagedChannel underlyingChannel1 = mock (ManagedChannel .class );
430+ ManagedChannel underlyingChannel2 = mock (ManagedChannel .class );
431431
432432 // mock executor service to capture the runnable scheduled, so we can invoke it when we want to
433- ScheduledExecutorService scheduledExecutorService =
434- Mockito .mock (ScheduledExecutorService .class );
433+ ScheduledExecutorService scheduledExecutorService = mock (ScheduledExecutorService .class );
435434 FixedExecutorProvider provider = FixedExecutorProvider .create (scheduledExecutorService );
436435
437436 Mockito .doReturn (null )
@@ -466,7 +465,7 @@ void channelRefreshShouldSwapChannels() throws IOException {
466465
467466 @ Test
468467 void channelCountShouldNotChangeWhenOutstandingRpcsAreWithinLimits () throws Exception {
469- ScheduledExecutorService executor = Mockito . mock (ScheduledExecutorService .class );
468+ ScheduledExecutorService executor = mock (ScheduledExecutorService .class );
470469 FixedExecutorProvider provider = FixedExecutorProvider .create (executor );
471470
472471 List <ManagedChannel > channels = new ArrayList <>();
@@ -532,7 +531,7 @@ void channelCountShouldNotChangeWhenOutstandingRpcsAreWithinLimits() throws Exce
532531
533532 @ Test
534533 void customResizeDeltaIsRespected () throws Exception {
535- ScheduledExecutorService executor = Mockito . mock (ScheduledExecutorService .class );
534+ ScheduledExecutorService executor = mock (ScheduledExecutorService .class );
536535 FixedExecutorProvider provider = FixedExecutorProvider .create (executor );
537536
538537 List <ManagedChannel > channels = new ArrayList <>();
@@ -564,7 +563,7 @@ void customResizeDeltaIsRespected() throws Exception {
564563
565564 @ Test
566565 void removedIdleChannelsAreShutdown () throws Exception {
567- ScheduledExecutorService executor = Mockito . mock (ScheduledExecutorService .class );
566+ ScheduledExecutorService executor = mock (ScheduledExecutorService .class );
568567 FixedExecutorProvider provider = FixedExecutorProvider .create (executor );
569568
570569 List <ManagedChannel > channels = new ArrayList <>();
@@ -591,7 +590,7 @@ void removedIdleChannelsAreShutdown() throws Exception {
591590
592591 @ Test
593592 void removedActiveChannelsAreShutdown () throws Exception {
594- ScheduledExecutorService executor = Mockito . mock (ScheduledExecutorService .class );
593+ ScheduledExecutorService executor = mock (ScheduledExecutorService .class );
595594 FixedExecutorProvider provider = FixedExecutorProvider .create (executor );
596595
597596 List <ManagedChannel > channels = new ArrayList <>();
@@ -639,16 +638,16 @@ void removedActiveChannelsAreShutdown() throws Exception {
639638
640639 @ Test
641640 void testReleasingClientCallCancelEarly () throws IOException {
642- ClientCall mockClientCall = Mockito . mock (ClientCall .class );
641+ ClientCall mockClientCall = mock (ClientCall .class );
643642 Mockito .doAnswer (invocation -> null ).when (mockClientCall ).cancel (Mockito .any (), Mockito .any ());
644- ManagedChannel fakeChannel = Mockito . mock (ManagedChannel .class );
643+ ManagedChannel fakeChannel = mock (ManagedChannel .class );
645644 Mockito .when (fakeChannel .newCall (Mockito .any (), Mockito .any ())).thenReturn (mockClientCall );
646645 ChannelPoolSettings channelPoolSettings = ChannelPoolSettings .staticallySized (1 );
647646 ChannelFactory factory = new FakeChannelFactory (ImmutableList .of (fakeChannel ));
648647 pool = ChannelPool .create (channelPoolSettings , factory , null );
649648
650649 EndpointContext endpointContext =
651- Mockito . Mockito . mock (EndpointContext .class , Mockito .withSettings ().withoutAnnotations ());
650+ mock (EndpointContext .class , org . mockito . Mockito .withSettings ().withoutAnnotations ());
652651 Mockito .doNothing ()
653652 .when (endpointContext )
654653 .validateUniverseDomain (Mockito .any (Credentials .class ), Mockito .any (GrpcStatusCode .class ));
@@ -693,7 +692,7 @@ public void onComplete() {}
693692
694693 @ Test
695694 void repeatedResizingLogsWarningOnExpand () throws Exception {
696- ScheduledExecutorService executor = Mockito . mock (ScheduledExecutorService .class );
695+ ScheduledExecutorService executor = mock (ScheduledExecutorService .class );
697696 FixedExecutorProvider provider = FixedExecutorProvider .create (executor );
698697
699698 ChannelFactory channelFactory = createMockChannelFactory (new ArrayList <>(), null );
@@ -744,10 +743,10 @@ void repeatedResizingLogsWarningOnExpand() throws Exception {
744743
745744 @ Test
746745 void repeatedResizingLogsWarningOnShrink () throws Exception {
747- ScheduledExecutorService executor = Mockito . mock (ScheduledExecutorService .class );
746+ ScheduledExecutorService executor = mock (ScheduledExecutorService .class );
748747 FixedExecutorProvider provider = FixedExecutorProvider .create (executor );
749748
750- ChannelFactory channelFactory = () -> Mockito . mock (ManagedChannel .class );
749+ ChannelFactory channelFactory = () -> mock (ManagedChannel .class );
751750
752751 pool =
753752 new ChannelPool (
@@ -790,16 +789,16 @@ void testDoubleRelease() throws Exception {
790789
791790 try {
792791 // Create a fake channel pool thats backed by mock channels that simply record invocations
793- ClientCall mockClientCall = Mockito . mock (ClientCall .class );
794- ManagedChannel fakeChannel = Mockito . mock (ManagedChannel .class );
792+ ClientCall mockClientCall = mock (ClientCall .class );
793+ ManagedChannel fakeChannel = mock (ManagedChannel .class );
795794 Mockito .when (fakeChannel .newCall (Mockito .any (), Mockito .any ())).thenReturn (mockClientCall );
796795 ChannelPoolSettings channelPoolSettings = ChannelPoolSettings .staticallySized (1 );
797796 ChannelFactory factory = new FakeChannelFactory (ImmutableList .of (fakeChannel ));
798797
799798 pool = ChannelPool .create (channelPoolSettings , factory , null );
800799
801800 EndpointContext endpointContext =
802- Mockito . Mockito . mock (EndpointContext .class , Mockito .withSettings ().withoutAnnotations ());
801+ mock (EndpointContext .class , org . mockito . Mockito .withSettings ().withoutAnnotations ());
803802 Mockito .doNothing ()
804803 .when (endpointContext )
805804 .validateUniverseDomain (
@@ -852,7 +851,7 @@ void settingsValidationFailsWhenMaxResizeDeltaExceedsLimit() {
852851
853852 @ Test
854853 void minChannelsClampedToMaxChannelCountUnderHighLoad () throws Exception {
855- ScheduledExecutorService executor = Mockito . mock (ScheduledExecutorService .class );
854+ ScheduledExecutorService executor = mock (ScheduledExecutorService .class );
856855 FixedExecutorProvider provider = FixedExecutorProvider .create (executor );
857856
858857 List <ManagedChannel > channels = new ArrayList <>();
@@ -887,7 +886,7 @@ void minChannelsClampedToMaxChannelCountUnderHighLoad() throws Exception {
887886
888887 @ Test
889888 void maxChannelsClampedToMinChannelCountUnderLowLoad () throws Exception {
890- ScheduledExecutorService executor = Mockito . mock (ScheduledExecutorService .class );
889+ ScheduledExecutorService executor = mock (ScheduledExecutorService .class );
891890 FixedExecutorProvider provider = FixedExecutorProvider .create (executor );
892891
893892 List <ManagedChannel > channels = new ArrayList <>();
0 commit comments