GraphsPresenter extends BaseViperPresenter<GraphsView, GraphsInteractor> { public void subscribe(Trip trip) { this.trip = Preconditions.checkNotNull(trip); subscribe(); } @Inject  GraphsPresenter(GraphsView view, GraphsInteractor interactor, UserPreferenceManager preferences,
                           DatabaseAssistant databaseAssistant); void subscribe(Trip trip); @Override void subscribe();  }
@Test public void showEmptyText() { when(databaseAssistant.isReceiptsTableEmpty(trip)).thenReturn(Single.just(true)); when(interactor.getSummationByCategories(trip)).thenReturn(Maybe.empty()); when(interactor.getSummationByPaymentMethod(trip)).thenReturn(Maybe.empty()); when(interactor.getSummationByDate(trip)).thenReturn(Maybe.empty()); when(interactor.getSummationByReimbursement(trip)).thenReturn(Maybe.empty()); presenter.subscribe(trip); verify(graphsView).showEmptyText(true); verify(graphsView, never()).present(any()); }
@Test(expected=IllegalStateException.class) public void throwExceptionWithoutTrip() { presenter.subscribe(); }
@Test public void showAllGraphs() { when(databaseAssistant.isReceiptsTableEmpty(trip)).thenReturn(Single.just(false)); when(preferenceManager.get(UserPreference.Receipts.UsePaymentMethods)).thenReturn(true); presenter.subscribe(trip); verify(graphsView).showEmptyText(false); verify(graphsView).present(sumByCategoryIndicator); verify(graphsView).present(sumByPaymentMethodIndicator); verify(graphsView).present(sumByDateIndicator); verify(graphsView).present(sumByReimbursementIndicator); }
@Test public void showAllGraphsWithoutPaymentMethods() { when(databaseAssistant.isReceiptsTableEmpty(trip)).thenReturn(Single.just(false)); when(preferenceManager.get(UserPreference.Receipts.UsePaymentMethods)).thenReturn(false); presenter.subscribe(trip); verify(graphsView).showEmptyText(false); verify(graphsView).present(sumByCategoryIndicator); verify(graphsView, never()).present(sumByPaymentMethodIndicator); verify(graphsView).present(sumByDateIndicator); verify(graphsView).present(sumByReimbursementIndicator); }