### Question:
KnowledgeHierarchyListPresenter extends BasePresenter<KnowledgeHierarchyListContract.View> implements KnowledgeHierarchyListContract.Presenter { @Override public void addCollectArticle(int position, FeedArticleData feedArticleData) { addSubscribe(mDataManager.addCollectArticle(feedArticleData.getId()) .compose(RxUtils.rxSchedulerHelper()) .compose(RxUtils.handleCollectResult()) .subscribeWith(new BaseObserver<FeedArticleListData>(mView, WanAndroidApp.getInstance().getString(R.string.collect_fail)) { @Override public void onNext(FeedArticleListData feedArticleListData) { feedArticleData.setCollect(true); mView.showCollectArticleData(position, feedArticleData, feedArticleListData); } })); } @Inject  KnowledgeHierarchyListPresenter(DataManager dataManager); @Override void attachView(KnowledgeHierarchyListContract.View view); @Override void getKnowledgeHierarchyDetailData(int page, int cid, boolean isShowError); @Override void addCollectArticle(int position, FeedArticleData feedArticleData); @Override void cancelCollectArticle(int position, FeedArticleData feedArticleData);  }### Answer:
@Test public void addCollectArticleFail() { CookiesManager.clearAllCookies(); FeedArticleData feedArticleData = new FeedArticleData(); feedArticleData.setId(1100); feedArticleData.setCollect(false); mKnowledgeHierarchyListPresenter.addCollectArticle(0, feedArticleData); Mockito.verify(mView).showErrorMsg(mApplication.getString(R.string.collect_fail)); Mockito.verify(mView).showError(); }
@Test public void addCollectArticleSuccess() { login(); FeedArticleData feedArticleData = new FeedArticleData(); feedArticleData.setId(1100); feedArticleData.setCollect(false); mKnowledgeHierarchyListPresenter.addCollectArticle(0, feedArticleData); Mockito.verify(mView).showCollectArticleData(ArgumentMatchers.eq(0), ArgumentMatchers.eq(feedArticleData), ArgumentMatchers.any(FeedArticleListData.class)); }