@Test public void oauthCallback_onSuccessCallsView() { when(oAuthInteractor.retrieveAccessToken(any(Uri.class))).thenReturn(Completable.complete()); Uri uri = mock(Uri.class); presenter.oauthCallback(uri); verify(loginView, times(1)).onAuthSuccess(); verify(loginView, times(1)).showLoading(); verifyNoMoreInteractions(loginView); }
@Test public void oauthCallback_onErrorCallsView() { when(oAuthInteractor.retrieveAccessToken(any(Uri.class))) .thenReturn(Completable.error(new Throwable("Error~"))); Uri uri = mock(Uri.class); presenter.oauthCallback(uri); verify(loginView, times(1)).onErrorAccessToken(); verify(loginView, times(1)).showLoading(); verifyNoMoreInteractions(loginView); }
@Test public void startOAuth_errorReturnedToView() { when(networkInteractor.hasInternetConnectionCompletable()).thenReturn(Completable.complete()); when(oAuthInteractor.retrieveRequestToken()).thenReturn(Single.error(new Throwable("Error!"))); presenter.startOAuth(); verify(networkInteractor, times(1)).hasInternetConnectionCompletable(); verify(loginView, times(1)).onErrorRequestToken(); verify(loginView, times(1)).showLoading(); verifyNoMoreInteractions(loginView); }
@Test public void startOAuth_opensBrowserOnSuccess() { when(networkInteractor.hasInternetConnectionCompletable()).thenReturn(Completable.complete()); String OAUTH_CALLBACK = "Redirect URL"; when(oAuthInteractor.retrieveRequestToken()).thenReturn(Single.just(OAUTH_CALLBACK)); presenter.startOAuth(); verify(networkInteractor, times(1)).hasInternetConnectionCompletable(); verify(loginView, times(1)).showLoading(); verify(loginView, times(1)).openBrowser(OAUTH_CALLBACK); verifyNoMoreInteractions(loginView); }