Source:
<code>public void testAutoFlowRefreshTokenRequestFailedWithOauthError() throws IOException, InterruptedException { final FileMockContext mockContext = new FileMockContext(getContext()); final ITokenCacheStore mockCache = getCacheForRefreshToken(TEST_IDTOKEN_USERID, TEST_IDTOKEN_UPN); final AuthenticationContext context = getAuthenticationContext(mockContext, VALID_AUTHORITY, false, mockCache); final AggregatedTelemetryTestClass telemetry = new AggregatedTelemetryTestClass(); Telemetry.getInstance().registerDispatcher(telemetry, true); final CountDownLatch signal = new CountDownLatch(1); final MockActivity testActivity = new MockActivity(signal); final CountDownLatch signalCallback = new CountDownLatch(1); MockAuthenticationCallback callback = new MockAuthenticationCallback(signalCallback); final String responseBody = getErrorResponseBody("interaction_required"); final HttpURLConnection mockedConnection = Mockito.mock(HttpURLConnection.class); HttpUrlConnectionFactory.setMockedHttpUrlConnection(mockedConnection); Util.prepareMockedUrlConnection(mockedConnection); Mockito.when(mockedConnection.getOutputStream()).thenReturn(Mockito.mock(OutputStream.class)); Mockito.when(mockedConnection.getInputStream()).thenThrow(new IOException()); Mockito.when(mockedConnection.getErrorStream()).thenReturn(Util.createInputStream(responseBody)); Mockito.when(mockedConnection.getResponseCode()).thenReturn(HttpURLConnection.HTTP_BAD_REQUEST); context.acquireToken(testActivity.getTestActivity(), "resource", "clientId", "redirect", TEST_IDTOKEN_UPN, callback); final int requestWaitMs = 200000; signal.await(requestWaitMs, TimeUnit.MILLISECONDS); assertEquals("Activity was attempted to start.", AuthenticationConstants.UIRequest.BROWSER_FLOW, testActivity.mStartActivityRequestCode); context.onActivityResult(testActivity.mStartActivityRequestCode, AuthenticationConstants.UIResponse.BROWSER_CODE_COMPLETE, getResponseIntent(callback, "resource", "clientid", "redirect", TEST_IDTOKEN_UPN)); signalCallback.await(CONTEXT_REQUEST_TIME_OUT, TimeUnit.MILLISECONDS); <START> assertTrue(telemetry.checkOauthError()); <END> assertTrue(telemetry.checkNoPIIPresent(EventStrings.LOGIN_HINT, TEST_IDTOKEN_UPN)); }</code><technical_language>check entire set of values acquireToken call.Also this done for rest of acquireToken test cases.It get a high test coverage. #Pending</technical_language>

Target:
public void testAutoFlowRefreshTokenRequestFailedWithOauthError() throws IOException, InterruptedException { final FileMockContext mockContext = new FileMockContext(getContext()); final ITokenCacheStore mockCache = getCacheForRefreshToken(TEST_IDTOKEN_USERID, TEST_IDTOKEN_UPN); final AuthenticationContext context = getAuthenticationContext(mockContext, VALID_AUTHORITY, false, mockCache); final AggregatedTelemetryTestClass telemetry = new AggregatedTelemetryTestClass(); Telemetry.getInstance().registerDispatcher(telemetry, true); final CountDownLatch signal = new CountDownLatch(1); final MockActivity testActivity = new MockActivity(signal); final CountDownLatch signalCallback = new CountDownLatch(1); MockAuthenticationCallback callback = new MockAuthenticationCallback(signalCallback); final String responseBody = getErrorResponseBody("interaction_required"); final HttpURLConnection mockedConnection = Mockito.mock(HttpURLConnection.class); HttpUrlConnectionFactory.setMockedHttpUrlConnection(mockedConnection); Util.prepareMockedUrlConnection(mockedConnection); Mockito.when(mockedConnection.getOutputStream()).thenReturn(Mockito.mock(OutputStream.class)); Mockito.when(mockedConnection.getInputStream()).thenThrow(new IOException()); Mockito.when(mockedConnection.getErrorStream()).thenReturn(Util.createInputStream(responseBody)); Mockito.when(mockedConnection.getResponseCode()).thenReturn(HttpURLConnection.HTTP_BAD_REQUEST); context.acquireToken(testActivity.getTestActivity(), "resource", "clientId", "redirect", TEST_IDTOKEN_UPN, callback); final int requestWaitMs = 200000; signal.await(requestWaitMs, TimeUnit.MILLISECONDS); assertEquals("Activity was attempted to start.", AuthenticationConstants.UIRequest.BROWSER_FLOW, testActivity.mStartActivityRequestCode); context.onActivityResult(testActivity.mStartActivityRequestCode, AuthenticationConstants.UIResponse.BROWSER_CODE_COMPLETE, getResponseIntent(callback, "resource", "clientid", "redirect", TEST_IDTOKEN_UPN)); signalCallback.await(CONTEXT_REQUEST_TIME_OUT, TimeUnit.MILLISECONDS); assertTrue(telemetry.checkOauthError()); assertTrue(telemetry.checkNoPIIPresent(EventStrings.LOGIN_HINT, TEST_IDTOKEN_UPN)); assertTrue(telemetry.checkAPIId("100")); assertTrue(telemetry.checkCacheEventCount("3")); assertFalse(telemetry.checkAPISucceeded()); }