packages/modules/Connectivity: remove usages of deprecated Mockito matchers
Test: m checkbuild Flag: TEST_ONLY Bug: 310268946 Change-Id: Icef421511b6fed6dc7912a9b703773ba5700c62a
This commit is contained in:
parent
5acb3ae676
commit
6cc971daab
16 changed files with 57 additions and 61 deletions
|
|
@ -47,9 +47,9 @@ import static org.junit.Assert.assertTrue;
|
|||
import static org.junit.Assert.fail;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.ArgumentMatchers.argThat;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Matchers.anyString;
|
||||
import static org.mockito.Matchers.eq;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.clearInvocations;
|
||||
import static org.mockito.Mockito.doAnswer;
|
||||
import static org.mockito.Mockito.doNothing;
|
||||
|
|
|
|||
|
|
@ -71,12 +71,12 @@ import static org.junit.Assert.assertNotNull;
|
|||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Matchers.anyBoolean;
|
||||
import static org.mockito.Matchers.anyInt;
|
||||
import static org.mockito.Matchers.anyLong;
|
||||
import static org.mockito.Matchers.anyString;
|
||||
import static org.mockito.Matchers.eq;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyBoolean;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.ArgumentMatchers.anyLong;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.argThat;
|
||||
import static org.mockito.Mockito.clearInvocations;
|
||||
import static org.mockito.Mockito.inOrder;
|
||||
|
|
|
|||
|
|
@ -45,11 +45,11 @@ import static com.android.testutils.DevSdkIgnoreRuleKt.SC_V2;
|
|||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Matchers.anyBoolean;
|
||||
import static org.mockito.Matchers.anyInt;
|
||||
import static org.mockito.Matchers.anyLong;
|
||||
import static org.mockito.Matchers.anyString;
|
||||
import static org.mockito.Matchers.eq;
|
||||
import static org.mockito.ArgumentMatchers.anyBoolean;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.ArgumentMatchers.anyLong;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.clearInvocations;
|
||||
import static org.mockito.Mockito.inOrder;
|
||||
import static org.mockito.Mockito.never;
|
||||
|
|
|
|||
|
|
@ -42,11 +42,10 @@ import static junit.framework.Assert.assertNotNull;
|
|||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Matchers.anyLong;
|
||||
import static org.mockito.Matchers.anyObject;
|
||||
import static org.mockito.Matchers.anyString;
|
||||
import static org.mockito.Matchers.eq;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyLong;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.clearInvocations;
|
||||
import static org.mockito.Mockito.inOrder;
|
||||
import static org.mockito.Mockito.never;
|
||||
|
|
@ -282,7 +281,7 @@ public class OffloadControllerTest {
|
|||
// This LinkProperties value does not differ from the default upstream.
|
||||
// There should be no extraneous call to setUpstreamParameters().
|
||||
inOrder.verify(mHardware, never()).setUpstreamParameters(
|
||||
anyObject(), anyObject(), anyObject(), anyObject());
|
||||
any(), any(), any(), any());
|
||||
inOrder.verifyNoMoreInteractions();
|
||||
|
||||
final LinkProperties lp = new LinkProperties();
|
||||
|
|
@ -410,7 +409,7 @@ public class OffloadControllerTest {
|
|||
// This LinkProperties value does not differ from the default upstream.
|
||||
// There should be no extraneous call to setUpstreamParameters().
|
||||
inOrder.verify(mHardware, never()).setUpstreamParameters(
|
||||
anyObject(), anyObject(), anyObject(), anyObject());
|
||||
any(), any(), any(), any());
|
||||
inOrder.verifyNoMoreInteractions();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ import static org.junit.Assert.assertEquals;
|
|||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.Matchers.eq;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
|
|
|
|||
|
|
@ -96,9 +96,9 @@ import static org.junit.Assert.fail;
|
|||
import static org.junit.Assume.assumeTrue;
|
||||
import static org.mockito.ArgumentMatchers.argThat;
|
||||
import static org.mockito.ArgumentMatchers.notNull;
|
||||
import static org.mockito.Matchers.anyInt;
|
||||
import static org.mockito.Matchers.anyString;
|
||||
import static org.mockito.Matchers.eq;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.any;
|
||||
import static org.mockito.Mockito.atLeast;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ package com.android.server.remoteauth;
|
|||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertThrows;
|
||||
import static org.mockito.ArgumentMatchers.anyObject;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.doThrow;
|
||||
|
|
@ -98,7 +98,7 @@ public class RemoteAuthConnectionCacheTest {
|
|||
@Test
|
||||
public void testGetConnection_failedToConnect() {
|
||||
mConnectionCache.setConnectionInfo(mConnectionInfo);
|
||||
doReturn(null).when(mConnectivityManager).connect(eq(mConnectionInfo), anyObject());
|
||||
doReturn(null).when(mConnectivityManager).connect(eq(mConnectionInfo), any());
|
||||
|
||||
assertNull(mConnectionCache.getConnection(CONNECTION_ID));
|
||||
}
|
||||
|
|
@ -108,7 +108,7 @@ public class RemoteAuthConnectionCacheTest {
|
|||
mConnectionCache.setConnectionInfo(mConnectionInfo);
|
||||
doThrow(ConnectionException.class)
|
||||
.when(mConnectivityManager)
|
||||
.connect(eq(mConnectionInfo), anyObject());
|
||||
.connect(eq(mConnectionInfo), any());
|
||||
|
||||
assertNull(mConnectionCache.getConnection(CONNECTION_ID));
|
||||
}
|
||||
|
|
@ -116,7 +116,7 @@ public class RemoteAuthConnectionCacheTest {
|
|||
@Test
|
||||
public void testGetConnection_connectionSucceed() {
|
||||
mConnectionCache.setConnectionInfo(mConnectionInfo);
|
||||
doReturn(mConnection).when(mConnectivityManager).connect(eq(mConnectionInfo), anyObject());
|
||||
doReturn(mConnection).when(mConnectivityManager).connect(eq(mConnectionInfo), any());
|
||||
|
||||
assertEquals(mConnection, mConnectionCache.getConnection(CONNECTION_ID));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ package com.android.server.remoteauth;
|
|||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.ArgumentMatchers.anyObject;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.times;
|
||||
|
|
@ -82,6 +82,6 @@ public class RemoteAuthPlatformTest {
|
|||
@Override
|
||||
public void onFailure(int errorCode) {}
|
||||
}));
|
||||
verify(mConnection, times(1)).sendRequest(eq(REQUEST), anyObject());
|
||||
verify(mConnection, times(1)).sendRequest(eq(REQUEST), any());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ import static com.android.net.module.util.netlink.NetlinkConstants.IPCTNL_MSG_CT
|
|||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotEquals;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.mockito.Matchers.eq;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.timeout;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
|
|
|
|||
|
|
@ -23,10 +23,10 @@ import static android.system.OsConstants.SOCK_DGRAM;
|
|||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.mockito.Matchers.anyInt;
|
||||
import static org.mockito.Matchers.anyObject;
|
||||
import static org.mockito.Matchers.anyString;
|
||||
import static org.mockito.Matchers.eq;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
|
@ -100,7 +100,7 @@ public class IpSecManagerTest {
|
|||
when(mMockIpSecService.allocateSecurityParameterIndex(
|
||||
eq(GOOGLE_DNS_4.getHostAddress()),
|
||||
eq(DROID_SPI),
|
||||
anyObject()))
|
||||
any()))
|
||||
.thenReturn(spiResp);
|
||||
|
||||
IpSecManager.SecurityParameterIndex droidSpi =
|
||||
|
|
@ -119,7 +119,7 @@ public class IpSecManagerTest {
|
|||
when(mMockIpSecService.allocateSecurityParameterIndex(
|
||||
eq(GOOGLE_DNS_4.getHostAddress()),
|
||||
eq(IpSecManager.INVALID_SECURITY_PARAMETER_INDEX),
|
||||
anyObject()))
|
||||
any()))
|
||||
.thenReturn(spiResp);
|
||||
|
||||
IpSecManager.SecurityParameterIndex randomSpi =
|
||||
|
|
@ -140,7 +140,7 @@ public class IpSecManagerTest {
|
|||
IpSecSpiResponse spiResp =
|
||||
new IpSecSpiResponse(IpSecManager.Status.RESOURCE_UNAVAILABLE, 0, 0);
|
||||
when(mMockIpSecService.allocateSecurityParameterIndex(
|
||||
anyString(), anyInt(), anyObject()))
|
||||
anyString(), anyInt(), any()))
|
||||
.thenReturn(spiResp);
|
||||
|
||||
try {
|
||||
|
|
@ -157,7 +157,7 @@ public class IpSecManagerTest {
|
|||
public void testAllocSpiSpiUnavailableException() throws Exception {
|
||||
IpSecSpiResponse spiResp = new IpSecSpiResponse(IpSecManager.Status.SPI_UNAVAILABLE, 0, 0);
|
||||
when(mMockIpSecService.allocateSecurityParameterIndex(
|
||||
anyString(), anyInt(), anyObject()))
|
||||
anyString(), anyInt(), any()))
|
||||
.thenReturn(spiResp);
|
||||
|
||||
try {
|
||||
|
|
@ -187,7 +187,7 @@ public class IpSecManagerTest {
|
|||
DUMMY_RESOURCE_ID,
|
||||
TEST_UDP_ENCAP_PORT,
|
||||
Os.socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP));
|
||||
when(mMockIpSecService.openUdpEncapsulationSocket(eq(TEST_UDP_ENCAP_PORT), anyObject()))
|
||||
when(mMockIpSecService.openUdpEncapsulationSocket(eq(TEST_UDP_ENCAP_PORT), any()))
|
||||
.thenReturn(udpEncapResp);
|
||||
|
||||
IpSecManager.UdpEncapsulationSocket encapSocket =
|
||||
|
|
@ -236,7 +236,7 @@ public class IpSecManagerTest {
|
|||
TEST_UDP_ENCAP_PORT,
|
||||
Os.socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP));
|
||||
|
||||
when(mMockIpSecService.openUdpEncapsulationSocket(eq(0), anyObject()))
|
||||
when(mMockIpSecService.openUdpEncapsulationSocket(eq(0), any()))
|
||||
.thenReturn(udpEncapResp);
|
||||
|
||||
IpSecManager.UdpEncapsulationSocket encapSocket =
|
||||
|
|
@ -267,7 +267,7 @@ public class IpSecManagerTest {
|
|||
new IpSecTunnelInterfaceResponse(IpSecManager.Status.OK, resourceId, intfName);
|
||||
when(mMockIpSecService.createTunnelInterface(
|
||||
eq(VTI_LOCAL_ADDRESS.getHostAddress()), eq(GOOGLE_DNS_4.getHostAddress()),
|
||||
anyObject(), anyObject(), anyString()))
|
||||
any(), any(), anyString()))
|
||||
.thenReturn(dummyResponse);
|
||||
|
||||
IpSecManager.IpSecTunnelInterface tunnelIntf = mIpSecManager.createIpSecTunnelInterface(
|
||||
|
|
|
|||
|
|
@ -220,7 +220,7 @@ import static org.mockito.ArgumentMatchers.anyString;
|
|||
import static org.mockito.ArgumentMatchers.argThat;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.ArgumentMatchers.isNull;
|
||||
import static org.mockito.Matchers.anyInt;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.Mockito.any;
|
||||
import static org.mockito.Mockito.atLeastOnce;
|
||||
import static org.mockito.Mockito.clearInvocations;
|
||||
|
|
|
|||
|
|
@ -37,9 +37,6 @@ import static org.mockito.ArgumentMatchers.anyLong;
|
|||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.ArgumentMatchers.argThat;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Matchers.anyInt;
|
||||
import static org.mockito.Matchers.anyString;
|
||||
import static org.mockito.Matchers.eq;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.times;
|
||||
|
|
|
|||
|
|
@ -19,9 +19,9 @@ package com.android.server;
|
|||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.mockito.Matchers.anyInt;
|
||||
import static org.mockito.Matchers.anyObject;
|
||||
import static org.mockito.Matchers.eq;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.doThrow;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.spy;
|
||||
|
|
@ -111,7 +111,7 @@ public class IpSecServiceRefcountedResourceTest {
|
|||
assertResourceState(resource, 1, 0, 0, 0, 0);
|
||||
|
||||
// Verify linking to binder death
|
||||
verify(binderMock).linkToDeath(anyObject(), anyInt());
|
||||
verify(binderMock).linkToDeath(any(), anyInt());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -129,14 +129,14 @@ public class IpSecServiceRefcountedResourceTest {
|
|||
assertResourceState(childResource, 2, 0, 0, 0, 0);
|
||||
|
||||
// Verify linking to binder death
|
||||
verify(binderMockChild).linkToDeath(anyObject(), anyInt());
|
||||
verify(binderMockParent).linkToDeath(anyObject(), anyInt());
|
||||
verify(binderMockChild).linkToDeath(any(), anyInt());
|
||||
verify(binderMockParent).linkToDeath(any(), anyInt());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailLinkToDeath() throws RemoteException {
|
||||
IBinder binderMock = mock(IBinder.class);
|
||||
doThrow(new RemoteException()).when(binderMock).linkToDeath(anyObject(), anyInt());
|
||||
doThrow(new RemoteException()).when(binderMock).linkToDeath(any(), anyInt());
|
||||
|
||||
try {
|
||||
getTestRefcountedResource(binderMock);
|
||||
|
|
|
|||
|
|
@ -26,10 +26,10 @@ import static org.junit.Assert.assertNotEquals;
|
|||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.mockito.Matchers.anyInt;
|
||||
import static org.mockito.Matchers.anyString;
|
||||
import static org.mockito.Matchers.argThat;
|
||||
import static org.mockito.Matchers.eq;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.ArgumentMatchers.argThat;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
|
|
|||
|
|
@ -35,8 +35,8 @@ import static com.android.testutils.DevSdkIgnoreRuleKt.SC_V2;
|
|||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertThrows;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
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 android.content.Context;
|
||||
import android.net.DataUsageRequest;
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ import static org.mockito.ArgumentMatchers.any;
|
|||
import static org.mockito.ArgumentMatchers.anyBoolean;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.Matchers.eq;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.doAnswer;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
|
|
|||
Loading…
Reference in a new issue