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:
jianglai 2019-05-30 08:14:32 -07:00
parent 538c659609
commit 3d26359e2d
5 changed files with 16 additions and 13 deletions

View file

@ -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