mirror of
https://github.com/google/nomulus.git
synced 2025-05-23 20:59:35 +02:00
Migrate org.mockito.Matchers#any* to org.mockito.ArgumentMatchers
The former is deprecated and replaced by the latter in Mockito 2. However, there is a functional difference: ArgumentMatchers will reject `null` and check the type if the matcher specified a type (e.g. `any(Class)` or `anyInt()`). `any()` will remain to accept anything. For more information see [] Tested: TAP --sample ran all affected tests and none failed [] ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=250690285
This commit is contained in:
parent
28393e569c
commit
ef9478b68c
5 changed files with 16 additions and 13 deletions
|
@ -59,8 +59,8 @@ import org.junit.Test;
|
|||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.ArgumentMatchers;
|
||||
import org.mockito.Captor;
|
||||
import org.mockito.Matchers;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnit;
|
||||
import org.mockito.junit.MockitoRule;
|
||||
|
@ -428,10 +428,13 @@ public class CloudDnsWriterTest {
|
|||
public void retryMutateZoneOnError() {
|
||||
CloudDnsWriter spyWriter = spy(writer);
|
||||
// First call - throw. Second call - do nothing.
|
||||
doThrow(ZoneStateException.class).doNothing().when(spyWriter).mutateZone(Matchers.any());
|
||||
doThrow(ZoneStateException.class)
|
||||
.doNothing()
|
||||
.when(spyWriter)
|
||||
.mutateZone(ArgumentMatchers.any());
|
||||
spyWriter.commit();
|
||||
|
||||
verify(spyWriter, times(2)).mutateZone(Matchers.any());
|
||||
verify(spyWriter, times(2)).mutateZone(ArgumentMatchers.any());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -57,7 +57,7 @@ import org.junit.Rule;
|
|||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
import org.mockito.Matchers;
|
||||
import org.mockito.ArgumentMatchers;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnit;
|
||||
import org.mockito.junit.MockitoRule;
|
||||
|
@ -99,7 +99,7 @@ public class EppControllerTest extends ShardableTestCase {
|
|||
loggerToIntercept.addHandler(logHandler);
|
||||
|
||||
when(sessionMetadata.getClientId()).thenReturn("some-client");
|
||||
when(flowComponentBuilder.flowModule(Matchers.any())).thenReturn(flowComponentBuilder);
|
||||
when(flowComponentBuilder.flowModule(ArgumentMatchers.any())).thenReturn(flowComponentBuilder);
|
||||
when(flowComponentBuilder.build()).thenReturn(flowComponent);
|
||||
when(flowComponent.flowRunner()).thenReturn(flowRunner);
|
||||
when(eppOutput.isResponse()).thenReturn(true);
|
||||
|
|
|
@ -16,8 +16,8 @@ package google.registry.flows;
|
|||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static org.mockito.ArgumentMatchers.isA;
|
||||
import static org.mockito.Mockito.eq;
|
||||
import static org.mockito.Mockito.isA;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
|
|
|
@ -40,8 +40,8 @@ import org.joda.money.CurrencyUnit;
|
|||
import org.joda.time.DateTime;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mockito.ArgumentMatchers;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
/** Unit tests for {@link CreateRegistrarCommand}. */
|
||||
public class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarCommand> {
|
||||
|
@ -238,10 +238,10 @@ public class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarC
|
|||
@Test
|
||||
public void testFailure_groupCreationFails() throws Exception {
|
||||
when(connection.sendPostRequest(
|
||||
Mockito.anyString(),
|
||||
Mockito.anyMap(),
|
||||
Mockito.any(MediaType.class),
|
||||
Mockito.any(byte[].class)))
|
||||
ArgumentMatchers.anyString(),
|
||||
ArgumentMatchers.anyMap(),
|
||||
ArgumentMatchers.any(MediaType.class),
|
||||
ArgumentMatchers.any(byte[].class)))
|
||||
.thenThrow(new IOException("BAD ROBOT NO COOKIE"));
|
||||
runCommandForced(
|
||||
"--name=blobio",
|
||||
|
|
|
@ -48,7 +48,7 @@ import javax.annotation.Nullable;
|
|||
import org.joda.time.DateTime;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.ArgumentMatchers;
|
||||
|
||||
/** Unit tests for {@link GenerateAllocationTokensCommand}. */
|
||||
public class GenerateAllocationTokensCommandTest
|
||||
|
@ -93,7 +93,7 @@ public class GenerateAllocationTokensCommandTest
|
|||
.doThrow(fakeException)
|
||||
.doCallRealMethod()
|
||||
.when(spyCommand)
|
||||
.saveTokens(Mockito.any());
|
||||
.saveTokens(ArgumentMatchers.any());
|
||||
runCommand("--number", "1");
|
||||
assertAllocationTokens(createToken("123456789ABCDEFG", null, null));
|
||||
assertInStdout("123456789ABCDEFG");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue