CreatePostPresenter { @Nonnull Observable<Object> finishActivityObservable() { return Observable.merge( addPostResult.compose(ResponseOrError.<PostWithBody>onlySuccess()), navigationClickSubject); } CreatePostPresenter(@Nonnull final PostsDao postsDao,
                               @Nonnull final Scheduler uiScheduler);   }
@Test public void testAfterStart_activityIsNotClosed() throws Exception { final TestSubscriber<Object> finishActivity = new TestSubscriber<>(); postPresenter.finishActivityObservable().subscribe(finishActivity); assert_().that(finishActivity.getOnNextEvents()).isEmpty(); }
@Test public void testAfterSaveSuccess_closeActivity() throws Exception { final TestSubscriber<Object> finishActivity = new TestSubscriber<>(); postPresenter.finishActivityObservable().subscribe(finishActivity); fillDataAndSubmit(); returnCorrectResponse(); assert_().that(finishActivity.getOnNextEvents()).hasSize(1); }
@Test public void testAfterSaveFail_doNotCloseActivity() throws Exception { final TestSubscriber<Object> finishActivity = new TestSubscriber<>(); postPresenter.finishActivityObservable().subscribe(finishActivity); fillDataAndSubmit(); returnException(); assert_().that(finishActivity.getOnNextEvents()).isEmpty(); }