1616import static com .google .common .truth .Truth .assertThat ;
1717import static org .junit .Assert .assertThrows ;
1818import static org .mockito .ArgumentMatchers .eq ;
19+ import static org .mockito .Mockito .lenient ;
1920import static org .mockito .Mockito .when ;
2021import java .util .concurrent .ExecutionException ;
2122
@@ -166,14 +167,16 @@ private void setupGrpcService(ImagesServiceGrpc.ImagesServiceImplBase serviceImp
166167 grpcCleanup .register (InProcessChannelBuilder .forName (serverName ).directExecutor ().build ());
167168 blockingStub = ImagesServiceGrpc .newBlockingStub (channel );
168169 futureStub = ImagesServiceGrpc .newFutureStub (channel );
169- when (mockGrpcImagesClient .getBlockingStub ()).thenReturn (blockingStub );
170- when (mockGrpcImagesClient .getFutureStub ()).thenReturn (futureStub );
170+ lenient (). when (mockGrpcImagesClient .getBlockingStub ()).thenReturn (blockingStub );
171+ lenient (). when (mockGrpcImagesClient .getFutureStub ()).thenReturn (futureStub );
171172 imagesService =
172173 new ImagesServiceImpl (
173174 mockEnvironmentProvider , mockGrpcImagesClient , null , mockBlobstoreReference );
174175
175- when (mockEnvironmentProvider .getenv (
176- ImagesServiceFactoryImpl .USE_CUSTOM_IMAGES_GRPC_SERVICE_ENV ))
176+ lenient ()
177+ .when (
178+ mockEnvironmentProvider .getenv (
179+ ImagesServiceFactoryImpl .USE_CUSTOM_IMAGES_GRPC_SERVICE_ENV ))
177180 .thenReturn ("true" );
178181 }
179182
@@ -356,8 +359,10 @@ public void loadImageData_withLegacyBlobKey_failure() throws Exception {
356359
357360 public void setUpGrpc (boolean useGrpc ) throws Exception {
358361 ImagesServiceImpl .setStorageForTesting (mockStorage );
359- when (mockEnvironmentProvider .getenv (
360- ImagesServiceFactoryImpl .USE_CUSTOM_IMAGES_GRPC_SERVICE_ENV ))
362+ lenient ()
363+ .when (
364+ mockEnvironmentProvider .getenv (
365+ ImagesServiceFactoryImpl .USE_CUSTOM_IMAGES_GRPC_SERVICE_ENV ))
361366 .thenReturn (Boolean .toString (useGrpc ));
362367
363368 if (useGrpc ) {
@@ -373,8 +378,8 @@ public void setUpGrpc(boolean useGrpc) throws Exception {
373378 InProcessChannelBuilder .forName (serverName ).directExecutor ().build ());
374379 blockingStub = ImagesServiceGrpc .newBlockingStub (channel );
375380 futureStub = ImagesServiceGrpc .newFutureStub (channel );
376- when (mockGrpcImagesClient .getBlockingStub ()).thenReturn (blockingStub );
377- when (mockGrpcImagesClient .getFutureStub ()).thenReturn (futureStub );
381+ lenient (). when (mockGrpcImagesClient .getBlockingStub ()).thenReturn (blockingStub );
382+ lenient (). when (mockGrpcImagesClient .getFutureStub ()).thenReturn (futureStub );
378383
379384 imagesService =
380385 new ImagesServiceImpl (
0 commit comments