diff options
author | cyBerta <cyberta@riseup.net> | 2023-04-18 12:39:15 +0200 |
---|---|---|
committer | cyBerta <cyberta@riseup.net> | 2023-04-18 12:39:15 +0200 |
commit | 3ce9d2a5df2a193fd85f82b8201de57f1026302b (patch) | |
tree | b27c49d88dc1e176823ab452177e3af712390809 /app/src/test/java | |
parent | a5b1430c54223a3b8c4e576e0124d7747a26b4ad (diff) |
fix tests using mocked okhttpclient
Diffstat (limited to 'app/src/test/java')
-rw-r--r-- | app/src/test/java/se/leap/bitmaskclient/testutils/MockHelper.java | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/app/src/test/java/se/leap/bitmaskclient/testutils/MockHelper.java b/app/src/test/java/se/leap/bitmaskclient/testutils/MockHelper.java index d30e8b7e..c272970d 100644 --- a/app/src/test/java/se/leap/bitmaskclient/testutils/MockHelper.java +++ b/app/src/test/java/se/leap/bitmaskclient/testutils/MockHelper.java @@ -74,6 +74,7 @@ import se.leap.bitmaskclient.base.utils.ConfigHelper; import se.leap.bitmaskclient.base.utils.FileHelper; import se.leap.bitmaskclient.base.utils.InputStreamHelper; import se.leap.bitmaskclient.base.utils.PreferenceHelper; +import se.leap.bitmaskclient.providersetup.connectivity.DnsResolver; import se.leap.bitmaskclient.providersetup.connectivity.OkHttpClientGenerator; import se.leap.bitmaskclient.testutils.BackendMockResponses.BackendMockProvider; import se.leap.bitmaskclient.testutils.matchers.BundleMatcher; @@ -577,13 +578,14 @@ public class MockHelper { public static OkHttpClientGenerator mockClientGenerator(boolean resolveDNS) throws UnknownHostException { OkHttpClientGenerator mockClientGenerator = mock(OkHttpClientGenerator.class); - OkHttpClient mockedOkHttpClient = mock(OkHttpClient.class, RETURNS_DEEP_STUBS); + OkHttpClient mockedOkHttpClient = mock(OkHttpClient.class); + DnsResolver mockedDnsResolver = mock(DnsResolver.class); when(mockClientGenerator.initCommercialCAHttpClient(any(JSONObject.class), anyInt())).thenReturn(mockedOkHttpClient); when(mockClientGenerator.initSelfSignedCAHttpClient(anyString(), anyInt(), any(JSONObject.class))).thenReturn(mockedOkHttpClient); if (resolveDNS) { - when(mockedOkHttpClient.dns().lookup(anyString())).thenReturn(new ArrayList<>()); + when(mockedDnsResolver.lookup(anyString())).thenReturn(new ArrayList<>()); } else { - when(mockedOkHttpClient.dns().lookup(anyString())).thenThrow(new UnknownHostException()); + when(mockedDnsResolver.lookup(anyString())).thenThrow(new UnknownHostException()); } return mockClientGenerator; } |