Source:
public void testSignInSucceeded() { Activity mockActivty = mock(Activity.class); ActivityHelper mockActivityHelper = mock(ActivityHelper.class); FirebaseUser mockFirebaseUser = TestHelper.makeMockFirebaseUser(); IDPResponse mockIdpResponse = mock(IDPResponse.class); CredentialSignInHandler credentialSignInHandler = new CredentialSignInHandler( mockActivty, mockActivityHelper, RC_ACCOUNT_LINK, RC_SAVE_CREDENTIALS, mockIdpResponse); Context mockContext = mock(Context.class); FlowParameters mockFlowParams = mock(FlowParameters.class); Task mockTask = mock(Task.class); when(mockTask.isSuccessful()).thenReturn(true); when(mockTask.getResult()).thenReturn(new FakeAuthResult(mockFirebaseUser)); when(mockActivityHelper.getApplicationContext()).thenReturn(mockContext); when(mockActivityHelper.getFlowParams()).thenReturn(mockFlowParams); credentialSignInHandler.onComplete(mockTask); ArgumentCaptor<Intent> intentCaptor = ArgumentCaptor.forClass(Intent.class); ArgumentCaptor<Integer> intCaptor = ArgumentCaptor.forClass(Integer.class); verify(mockActivty).startActivityForResult(intentCaptor.capture(), intCaptor.capture()); Intent capturedIntent = intentCaptor.getValue(); assertEquals(RC_SAVE_CREDENTIALS, (int) intCaptor.getValue()); assertEquals( SaveCredentialsActivity.class.getName(), capturedIntent.getComponent().getClassName()); assertEquals( TestConstants.EMAIL, capturedIntent.getExtras().getString(ExtraConstants.EXTRA_EMAIL)); assertEquals( TestConstants.NAME, capturedIntent.getExtras().getString(ExtraConstants.EXTRA_NAME)); assertEquals( TestConstants.PHOTO_URL, capturedIntent.getExtras().getString(ExtraConstants.EXTRA_PROFILE_PICTURE_URI)); }

Target:
public void testSignInSucceeded() { Activity mockActivity = mock(Activity.class); ActivityHelper mockActivityHelper = mock(ActivityHelper.class); FirebaseUser mockFirebaseUser = TestHelper.makeMockFirebaseUser(); IDPResponse idpResponse = new IDPResponse( GoogleAuthProvider.PROVIDER_ID, TestConstants.EMAIL, new Bundle()); CredentialSignInHandler credentialSignInHandler = new CredentialSignInHandler( mockActivity, mockActivityHelper, RC_ACCOUNT_LINK, RC_SAVE_CREDENTIALS, idpResponse); Context mockContext = mock(Context.class); FlowParameters mockFlowParams = mock(FlowParameters.class); Task signInTask = Tasks.forResult(new FakeAuthResult(mockFirebaseUser)); when(mockActivityHelper.getApplicationContext()).thenReturn(mockContext); when(mockActivityHelper.getFlowParams()).thenReturn(mockFlowParams); credentialSignInHandler.onComplete(signInTask); ArgumentCaptor<Intent> intentCaptor = ArgumentCaptor.forClass(Intent.class); ArgumentCaptor<Integer> intCaptor = ArgumentCaptor.forClass(Integer.class); verify(mockActivity).startActivityForResult(intentCaptor.capture(), intCaptor.capture()); Intent capturedIntent = intentCaptor.getValue(); assertEquals(RC_SAVE_CREDENTIALS, (int) intCaptor.getValue()); assertEquals( SaveCredentialsActivity.class.getName(), capturedIntent.getComponent().getClassName()); assertEquals( TestConstants.EMAIL, capturedIntent.getExtras().getString(ExtraConstants.EXTRA_EMAIL)); assertEquals( TestConstants.NAME, capturedIntent.getExtras().getString(ExtraConstants.EXTRA_NAME)); assertEquals( TestConstants.PHOTO_URL, capturedIntent.getExtras().getString(ExtraConstants.EXTRA_PROFILE_PICTURE_URI)); }