ContentPresenter extends BasePresenter<ContentMvpView> { public void getCats(List<Cat> cats) { checkViewAttached(); mSubscription = mDataManager.getCats(cats) .observeOn(AndroidSchedulers.mainThread()) .subscribeOn(Schedulers.io()) .subscribe(new SingleSubscriber<List<Cat>>() { @Override public void onSuccess(List<Cat> cats) { getMvpView().showCats(cats); } @Override public void onError(Throwable error) { getMvpView().showCatsError(); Timber.e(error, "There was an error loading the cats!"); } }); } @Inject  ContentPresenter(DataManager dataManager); @Override void detachView(); void getCats(List<Cat> cats);  }
@Test public void getCatsSuccessful() { List<Cat> cats = TestDataFactory.makeCats(10); stubDataManagerGetCats(Single.just(cats)); mContentPresenter.getCats(cats); verify(mMockContentMvpView).showCats(cats); verify(mMockContentMvpView, never()).showCatsError(); }
@Test public void getTagsFails() { List<Cat> cats = TestDataFactory.makeCats(10); stubDataManagerGetCats(Single.just(cats)); stubDataManagerGetCats(Single.<List<Cat>>error(new RuntimeException())); mContentPresenter.getCats(cats); verify(mMockContentMvpView).showCatsError(); verify(mMockContentMvpView, never()).showCats(anyListOf(Cat.class)); }