MainPresenter { @Nonnull Observable<Throwable> errorObservable() { return errorObservable; } MainPresenter(@Nonnull final PostsDao postsDao,
                         @Nonnull final MyCurrentLoggedInUserDao currentLoggedInUserDao,
                         @Nonnull Scheduler uiScheduler);   }
@Test public void testBeforeDownload_errorIsNull() throws Exception { final TestSubscriber<Throwable> error = new TestSubscriber<>(); mainPresenter.errorObservable().subscribe(error); assert_().that(error.getOnNextEvents()) .contains(null); error.assertNoErrors(); }
@Test public void testAfterSuccessDownload_errorIsStillNull() throws Exception { final TestSubscriber<Throwable> error = new TestSubscriber<>(); mainPresenter.errorObservable().subscribe(error); postsSubject.onNext(sampleData()); scheduler.triggerActions(); assert_().that(error.getOnNextEvents()) .contains(null); error.assertNoErrors(); }
@Test public void testAfterFailedDownload_errorIsSet() throws Exception { final Exception e = new Exception(); final TestSubscriber<Throwable> error = new TestSubscriber<>(); mainPresenter.errorObservable().subscribe(error); postsSubject.onNext(ResponseOrError.<PostsResponse>fromError(e)); scheduler.triggerActions(); assert_().that(error.getOnNextEvents()) .containsExactly(null, e) .inOrder(); error.assertNoErrors(); }