### Question:
CollectPresenter extends BasePresenter<CollectContract.View> implements CollectContract.Presenter { @Override public void cancelCollectPageArticle(int position, FeedArticleData feedArticleData) { addSubscribe(mDataManager.cancelCollectPageArticle(feedArticleData.getId()) .compose(RxUtils.rxSchedulerHelper()) .compose(RxUtils.handleCollectResult()) .subscribeWith(new BaseObserver<FeedArticleListData>(mView, WanAndroidApp.getInstance().getString(R.string.cancel_collect_fail)) { @Override public void onNext(FeedArticleListData feedArticleListData) { feedArticleData.setCollect(false); mView.showCancelCollectPageArticleData(position, feedArticleData, feedArticleListData); } })); } @Inject  CollectPresenter(DataManager dataManager); @Override void attachView(CollectContract.View view); @Override void getCollectList(int page, boolean isShowError); @Override void cancelCollectPageArticle(int position, FeedArticleData feedArticleData);  }### Answer:
@Test public void cancelCollectFail() { CookiesManager.clearAllCookies(); FeedArticleData feedArticleData = new FeedArticleData(); feedArticleData.setCollect(true); mCollectPresenter.cancelCollectPageArticle(0, feedArticleData); Mockito.verify(mView).showErrorMsg(mApplication.getString(R.string.cancel_collect_fail)); Mockito.verify(mView).showError(); }
@Test public void cancelCollectSuccess() { login(); FeedArticleData feedArticleData = new FeedArticleData(); feedArticleData.setCollect(true); mCollectPresenter.cancelCollectPageArticle(0, feedArticleData); feedArticleData.setCollect(false); Mockito.verify(mView).showCancelCollectPageArticleData(ArgumentMatchers.eq(0), ArgumentMatchers.eq(feedArticleData), ArgumentMatchers.any(FeedArticleListData.class)); }