AuthenticationClient { public static void openLoginInBrowser(Activity contextActivity, AuthenticationRequest request) { Intent launchBrowser = new Intent(Intent.ACTION_VIEW, request.toUri()); contextActivity.startActivity(launchBrowser); } AuthenticationClient(Activity activity); static void openLoginInBrowser(Activity contextActivity, AuthenticationRequest request); static Intent createLoginActivityIntent(Activity contextActivity, AuthenticationRequest request); static void openLoginActivity(Activity contextActivity, int requestCode, AuthenticationRequest request); static void stopLoginActivity(Activity contextActivity, int requestCode); static AuthenticationResponse getResponse(int resultCode, Intent intent); static void openDownloadSpotifyActivity(Activity contextActivity); static void openDownloadSpotifyActivity(Activity contextActivity, String campaign); static boolean isAvailable(Context ctx, Intent intent);  }
@Test public void shouldLaunchIntentForPassedActivity() { AuthenticationRequest authenticationRequest = mock(AuthenticationRequest.class); Activity activity = mock(Activity.class); when(authenticationRequest.toUri()).thenReturn(Uri.parse("to: Mockito.doNothing().when(activity).startActivity(any(Intent.class)); ArgumentCaptor<Intent> captor = ArgumentCaptor.forClass(Intent.class); AuthenticationClient.openLoginInBrowser(activity, authenticationRequest); verify(activity, times(1)).startActivity(captor.capture()); assertEquals(Intent.ACTION_VIEW, captor.getValue().getAction()); assertEquals("to: }