Ejemplo n.º 1
0
  @Test
  public void startOAuth_callsViewIfNoInternet() {
    when(networkInteractor.hasInternetConnectionCompletable())
        .thenReturn(Completable.error(new NetworkInteractor.NetworkUnavailableException()));

    presenter.startOAuth();

    verify(networkInteractor, times(1)).hasInternetConnectionCompletable();
    verify(loginView, times(1)).onErrorNoInternet();
    verifyNoMoreInteractions(loginView);
  }
Ejemplo n.º 2
0
  @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);
  }
Ejemplo n.º 3
0
  @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);
  }