From 9b319f4f5b0a5db7eb33b0ddae32f7086dad7ade Mon Sep 17 00:00:00 2001 From: Googler Date: Wed, 29 May 2019 07:47:32 -0700 Subject: [PATCH] Automatic code cleanup. PiperOrigin-RevId: 250489470 --- ...tpConnectorMultiplexerIntegrationTest.java | 4 +- .../HttpConnectorMultiplexerTest.java | 6 +- .../downloader/HttpConnectorTest.java | 2 +- .../repository/downloader/HttpStreamTest.java | 2 +- .../downloader/ProgressInputStreamTest.java | 4 +- .../downloader/RetryingInputStreamTest.java | 2 +- .../AbstractRemoteActionCacheTests.java | 2 +- .../build/lib/remote/GrpcRemoteCacheTest.java | 11 ++-- .../remote/GrpcRemoteExecutionClientTest.java | 59 +++++++++++-------- .../lib/remote/RemoteSpawnCacheTest.java | 2 +- .../lib/remote/RemoteSpawnRunnerTest.java | 2 +- 11 files changed, 55 insertions(+), 41 deletions(-) diff --git a/src/test/java/com/google/devtools/build/lib/bazel/repository/downloader/HttpConnectorMultiplexerIntegrationTest.java b/src/test/java/com/google/devtools/build/lib/bazel/repository/downloader/HttpConnectorMultiplexerIntegrationTest.java index df81dbe77a8dfa..4490bb0ad01e9c 100644 --- a/src/test/java/com/google/devtools/build/lib/bazel/repository/downloader/HttpConnectorMultiplexerIntegrationTest.java +++ b/src/test/java/com/google/devtools/build/lib/bazel/repository/downloader/HttpConnectorMultiplexerIntegrationTest.java @@ -20,8 +20,8 @@ import static com.google.devtools.build.lib.bazel.repository.downloader.HttpParser.readHttpRequest; import static java.nio.charset.StandardCharsets.US_ASCII; import static java.util.Arrays.asList; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyLong; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyLong; import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; diff --git a/src/test/java/com/google/devtools/build/lib/bazel/repository/downloader/HttpConnectorMultiplexerTest.java b/src/test/java/com/google/devtools/build/lib/bazel/repository/downloader/HttpConnectorMultiplexerTest.java index cb5a82b10e5d4a..a93e50f32214ad 100644 --- a/src/test/java/com/google/devtools/build/lib/bazel/repository/downloader/HttpConnectorMultiplexerTest.java +++ b/src/test/java/com/google/devtools/build/lib/bazel/repository/downloader/HttpConnectorMultiplexerTest.java @@ -20,9 +20,9 @@ import static com.google.devtools.build.lib.testutil.MoreAsserts.assertThrows; import static java.nio.charset.StandardCharsets.UTF_8; import static java.util.Arrays.asList; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyLong; -import static org.mockito.Matchers.anyString; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyLong; +import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Matchers.eq; import static org.mockito.Matchers.same; import static org.mockito.Mockito.doAnswer; diff --git a/src/test/java/com/google/devtools/build/lib/bazel/repository/downloader/HttpConnectorTest.java b/src/test/java/com/google/devtools/build/lib/bazel/repository/downloader/HttpConnectorTest.java index e151340a133d7a..0e4c6c19d6e031 100644 --- a/src/test/java/com/google/devtools/build/lib/bazel/repository/downloader/HttpConnectorTest.java +++ b/src/test/java/com/google/devtools/build/lib/bazel/repository/downloader/HttpConnectorTest.java @@ -21,7 +21,7 @@ import static java.nio.charset.StandardCharsets.US_ASCII; import static java.nio.charset.StandardCharsets.UTF_8; import static org.junit.Assert.fail; -import static org.mockito.Matchers.any; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; diff --git a/src/test/java/com/google/devtools/build/lib/bazel/repository/downloader/HttpStreamTest.java b/src/test/java/com/google/devtools/build/lib/bazel/repository/downloader/HttpStreamTest.java index 8e64f380a79a23..6af4caf3b8adfe 100644 --- a/src/test/java/com/google/devtools/build/lib/bazel/repository/downloader/HttpStreamTest.java +++ b/src/test/java/com/google/devtools/build/lib/bazel/repository/downloader/HttpStreamTest.java @@ -19,7 +19,7 @@ import static com.google.devtools.build.lib.bazel.repository.downloader.DownloaderTestUtils.makeUrl; import static java.nio.charset.StandardCharsets.UTF_8; import static org.junit.Assert.fail; -import static org.mockito.Matchers.any; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; diff --git a/src/test/java/com/google/devtools/build/lib/bazel/repository/downloader/ProgressInputStreamTest.java b/src/test/java/com/google/devtools/build/lib/bazel/repository/downloader/ProgressInputStreamTest.java index db46f5bfa46d06..7748aa2f0419d2 100644 --- a/src/test/java/com/google/devtools/build/lib/bazel/repository/downloader/ProgressInputStreamTest.java +++ b/src/test/java/com/google/devtools/build/lib/bazel/repository/downloader/ProgressInputStreamTest.java @@ -17,8 +17,8 @@ import static com.google.common.truth.Truth.assertThat; import static com.google.devtools.build.lib.bazel.repository.downloader.DownloaderTestUtils.makeUrl; import static com.google.devtools.build.lib.testutil.MoreAsserts.assertThrows; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyInt; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.Matchers.eq; import static org.mockito.Matchers.same; import static org.mockito.Mockito.mock; diff --git a/src/test/java/com/google/devtools/build/lib/bazel/repository/downloader/RetryingInputStreamTest.java b/src/test/java/com/google/devtools/build/lib/bazel/repository/downloader/RetryingInputStreamTest.java index 5a813120cba2a0..d30cd54da49ca3 100644 --- a/src/test/java/com/google/devtools/build/lib/bazel/repository/downloader/RetryingInputStreamTest.java +++ b/src/test/java/com/google/devtools/build/lib/bazel/repository/downloader/RetryingInputStreamTest.java @@ -16,7 +16,7 @@ import static com.google.common.truth.Truth.assertThat; import static com.google.devtools.build.lib.testutil.MoreAsserts.assertThrows; -import static org.mockito.Matchers.any; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Matchers.eq; import static org.mockito.Matchers.same; import static org.mockito.Mockito.mock; diff --git a/src/test/java/com/google/devtools/build/lib/remote/AbstractRemoteActionCacheTests.java b/src/test/java/com/google/devtools/build/lib/remote/AbstractRemoteActionCacheTests.java index 5716372c9e9687..49fe5f3bb850fb 100644 --- a/src/test/java/com/google/devtools/build/lib/remote/AbstractRemoteActionCacheTests.java +++ b/src/test/java/com/google/devtools/build/lib/remote/AbstractRemoteActionCacheTests.java @@ -17,7 +17,7 @@ import static com.google.devtools.build.lib.remote.util.DigestUtil.toBinaryDigest; import static com.google.devtools.build.lib.testutil.MoreAsserts.assertThrows; import static java.nio.charset.StandardCharsets.UTF_8; -import static org.mockito.Matchers.anyInt; +import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.Matchers.eq; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; diff --git a/src/test/java/com/google/devtools/build/lib/remote/GrpcRemoteCacheTest.java b/src/test/java/com/google/devtools/build/lib/remote/GrpcRemoteCacheTest.java index 08b2767f649202..68a2d457e83846 100644 --- a/src/test/java/com/google/devtools/build/lib/remote/GrpcRemoteCacheTest.java +++ b/src/test/java/com/google/devtools/build/lib/remote/GrpcRemoteCacheTest.java @@ -19,7 +19,7 @@ import static java.nio.charset.StandardCharsets.UTF_8; import static org.junit.Assert.fail; import static org.mockito.AdditionalAnswers.answerVoid; -import static org.mockito.Mockito.any; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.when; @@ -102,6 +102,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; +import org.mockito.ArgumentMatchers; import org.mockito.Mockito; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; @@ -590,12 +591,12 @@ public void findMissingBlobs( for (int chunkSize = 1; chunkSize <= 6; ++chunkSize) { GrpcRemoteCache client = newClient(); Chunker.setDefaultChunkSizeForTesting(chunkSize); - when(mockByteStreamImpl.write(Mockito.>anyObject())) + when(mockByteStreamImpl.write(ArgumentMatchers.>any())) .thenAnswer(blobChunkedWriteAnswer("abcdef", chunkSize)); assertThat(client.uploadBlob("abcdef".getBytes(UTF_8))).isEqualTo(digest); } Mockito.verify(mockByteStreamImpl, Mockito.times(6)) - .write(Mockito.>anyObject()); + .write(ArgumentMatchers.>any()); } @Test @@ -893,7 +894,7 @@ public void updateActionResult( }); ByteStreamImplBase mockByteStreamImpl = Mockito.mock(ByteStreamImplBase.class); serviceRegistry.addService(mockByteStreamImpl); - when(mockByteStreamImpl.write(Mockito.>anyObject())) + when(mockByteStreamImpl.write(ArgumentMatchers.>any())) .thenAnswer( new Answer>() { private int numErrors = 4; @@ -965,7 +966,7 @@ public void onError(Throwable t) { outErr); // 4 times for the errors, 3 times for the successful uploads. Mockito.verify(mockByteStreamImpl, Mockito.times(7)) - .write(Mockito.>anyObject()); + .write(ArgumentMatchers.>any()); } @Test diff --git a/src/test/java/com/google/devtools/build/lib/remote/GrpcRemoteExecutionClientTest.java b/src/test/java/com/google/devtools/build/lib/remote/GrpcRemoteExecutionClientTest.java index c1937e91680f9c..b89d6f06b325dc 100644 --- a/src/test/java/com/google/devtools/build/lib/remote/GrpcRemoteExecutionClientTest.java +++ b/src/test/java/com/google/devtools/build/lib/remote/GrpcRemoteExecutionClientTest.java @@ -18,7 +18,7 @@ import static java.nio.charset.StandardCharsets.UTF_8; import static org.junit.Assert.fail; import static org.mockito.AdditionalAnswers.answerVoid; -import static org.mockito.Mockito.any; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.when; @@ -116,6 +116,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; +import org.mockito.ArgumentMatchers; import org.mockito.Mockito; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; @@ -616,7 +617,7 @@ public void findMissingBlobs( serviceRegistry.addService(ServerInterceptors.intercept(cas, new RequestHeadersValidator())); ByteStreamImplBase mockByteStreamImpl = Mockito.mock(ByteStreamImplBase.class); - when(mockByteStreamImpl.write(Mockito.>anyObject())) + when(mockByteStreamImpl.write(ArgumentMatchers.>any())) .thenAnswer(blobWriteAnswer("xyz".getBytes(UTF_8))); serviceRegistry.addService( ServerInterceptors.intercept(mockByteStreamImpl, new RequestHeadersValidator())); @@ -627,7 +628,7 @@ public void findMissingBlobs( assertThat(result.isCacheHit()).isFalse(); assertThat(outErr.outAsLatin1()).isEqualTo("stdout"); assertThat(outErr.errAsLatin1()).isEqualTo("stderr"); - Mockito.verify(mockByteStreamImpl).write(Mockito.>anyObject()); + Mockito.verify(mockByteStreamImpl).write(ArgumentMatchers.>any()); } private Answer answerWith(@Nullable Operation op, Status status) { @@ -702,13 +703,14 @@ public void getActionResult( .doAnswer(answerWith(opSuccess, Status.UNAVAILABLE)) // last status should be ignored. .when(mockExecutionImpl) .execute( - Mockito.anyObject(), Mockito.>anyObject()); + ArgumentMatchers.any(), + ArgumentMatchers.>any()); Mockito.doAnswer(answerWith(null, Status.UNAVAILABLE)) .doAnswer(answerWith(operationWithExecuteError, Status.OK)) .when(mockExecutionImpl) .waitExecution( - Mockito.anyObject(), - Mockito.>anyObject()); + ArgumentMatchers.any(), + ArgumentMatchers.>any()); serviceRegistry.addService(mockExecutionImpl); serviceRegistry.addService( @@ -734,7 +736,7 @@ public void findMissingBlobs( }); ByteStreamImplBase mockByteStreamImpl = Mockito.mock(ByteStreamImplBase.class); - when(mockByteStreamImpl.write(Mockito.>anyObject())) + when(mockByteStreamImpl.write(ArgumentMatchers.>any())) .thenAnswer(blobWriteAnswerError()) // Error on the input file. .thenAnswer(blobWriteAnswerError()) // Error on the input file again. .thenAnswer(blobWriteAnswer("xyz".getBytes(UTF_8))); // Upload input file successfully. @@ -770,7 +772,9 @@ public void findMissingBlobs( return null; }) .when(mockByteStreamImpl) - .read(Mockito.anyObject(), Mockito.>anyObject()); + .read( + ArgumentMatchers.any(), + ArgumentMatchers.>any()); serviceRegistry.addService(mockByteStreamImpl); SpawnResult result = client.exec(simpleSpawn, simplePolicy); @@ -781,15 +785,18 @@ public void findMissingBlobs( assertThat(outErr.errAsLatin1()).isEqualTo("stderr"); Mockito.verify(mockExecutionImpl, Mockito.times(4)) .execute( - Mockito.anyObject(), Mockito.>anyObject()); + ArgumentMatchers.any(), + ArgumentMatchers.>any()); Mockito.verify(mockExecutionImpl, Mockito.times(2)) .waitExecution( - Mockito.anyObject(), - Mockito.>anyObject()); + ArgumentMatchers.any(), + ArgumentMatchers.>any()); Mockito.verify(mockByteStreamImpl, Mockito.times(2)) - .read(Mockito.anyObject(), Mockito.>anyObject()); + .read( + ArgumentMatchers.any(), + ArgumentMatchers.>any()); Mockito.verify(mockByteStreamImpl, Mockito.times(3)) - .write(Mockito.>anyObject()); + .write(ArgumentMatchers.>any()); } @Test @@ -833,13 +840,14 @@ public void getActionResult( .doAnswer(answerWith(unfinishedOperation, Status.UNAVAILABLE)) .when(mockExecutionImpl) .execute( - Mockito.anyObject(), Mockito.>anyObject()); + ArgumentMatchers.any(), + ArgumentMatchers.>any()); Mockito.doAnswer(answerWith(unfinishedOperation, Status.NOT_FOUND)) .doAnswer(answerWith(opSuccess, Status.UNAVAILABLE)) // This error is ignored. .when(mockExecutionImpl) .waitExecution( - Mockito.anyObject(), - Mockito.>anyObject()); + ArgumentMatchers.any(), + ArgumentMatchers.>any()); serviceRegistry.addService(mockExecutionImpl); serviceRegistry.addService( @@ -859,7 +867,7 @@ public void findMissingBlobs( }); ByteStreamImplBase mockByteStreamImpl = Mockito.mock(ByteStreamImplBase.class); - when(mockByteStreamImpl.write(Mockito.>anyObject())) + when(mockByteStreamImpl.write(ArgumentMatchers.>any())) .thenAnswer(blobWriteAnswer("xyz".getBytes(UTF_8))); // Upload input file successfully. Mockito.doAnswer( invocationOnMock -> { @@ -872,7 +880,9 @@ public void findMissingBlobs( return null; }) .when(mockByteStreamImpl) - .read(Mockito.anyObject(), Mockito.>anyObject()); + .read( + ArgumentMatchers.any(), + ArgumentMatchers.>any()); serviceRegistry.addService(mockByteStreamImpl); SpawnResult result = client.exec(simpleSpawn, simplePolicy); @@ -883,15 +893,18 @@ public void findMissingBlobs( assertThat(outErr.errAsLatin1()).isEqualTo("stderr"); Mockito.verify(mockExecutionImpl, Mockito.times(3)) .execute( - Mockito.anyObject(), Mockito.>anyObject()); + ArgumentMatchers.any(), + ArgumentMatchers.>any()); Mockito.verify(mockExecutionImpl, Mockito.times(2)) .waitExecution( - Mockito.anyObject(), - Mockito.>anyObject()); + ArgumentMatchers.any(), + ArgumentMatchers.>any()); Mockito.verify(mockByteStreamImpl) - .read(Mockito.anyObject(), Mockito.>anyObject()); + .read( + ArgumentMatchers.any(), + ArgumentMatchers.>any()); Mockito.verify(mockByteStreamImpl, Mockito.times(1)) - .write(Mockito.>anyObject()); + .write(ArgumentMatchers.>any()); } @Test diff --git a/src/test/java/com/google/devtools/build/lib/remote/RemoteSpawnCacheTest.java b/src/test/java/com/google/devtools/build/lib/remote/RemoteSpawnCacheTest.java index 3b59f98e2f610d..49c4f3122348a1 100644 --- a/src/test/java/com/google/devtools/build/lib/remote/RemoteSpawnCacheTest.java +++ b/src/test/java/com/google/devtools/build/lib/remote/RemoteSpawnCacheTest.java @@ -14,8 +14,8 @@ package com.google.devtools.build.lib.remote; import static com.google.common.truth.Truth.assertThat; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyCollection; -import static org.mockito.Matchers.any; import static org.mockito.Matchers.eq; import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.never; diff --git a/src/test/java/com/google/devtools/build/lib/remote/RemoteSpawnRunnerTest.java b/src/test/java/com/google/devtools/build/lib/remote/RemoteSpawnRunnerTest.java index e3699d19c2d580..66021a363c126f 100644 --- a/src/test/java/com/google/devtools/build/lib/remote/RemoteSpawnRunnerTest.java +++ b/src/test/java/com/google/devtools/build/lib/remote/RemoteSpawnRunnerTest.java @@ -16,8 +16,8 @@ import static com.google.common.truth.Truth.assertThat; import static com.google.devtools.build.lib.testutil.MoreAsserts.assertThrows; import static java.nio.charset.StandardCharsets.ISO_8859_1; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyCollection; -import static org.mockito.Matchers.any; import static org.mockito.Matchers.eq; import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.doThrow;