ExplorePresenter extends BasePresenter<ExploreContract.View> implements ExploreContract.Presenter { public void listTrending(LangTrending language, Since since) { Map<String, String> params = new LinkedHashMap<>(); if (language != LangTrending.ALL) params.put(LangTrending.key(), language.toString()); params.put(Since.key(), since.toString()); addSubscription( mExploreDataSource.listTrending(params) .subscribe(new DefaultSubscriber<List<Trending>>() { @Override public void onNext(List<Trending> trendings) { getView().onGetTrending(trendings); getView().showOnSuccess(); } @Override protected void onError(String errorStr) { getView().showOnError(Utils.getString(R.string.error_get_trending) + errorStr, ExploreContract.TRENDING); } }) ); } ExplorePresenter(ExploreDataSource exploreDataSource, RepositoryDataSource repositoryDataSource,
                            GankDataSource gankDataSource, ArsenalDataSource arsenalDataSource); void setView(ExploreContract.View view); @Override void attachView(ExploreContract.View mvpView); void listTrending(LangTrending language, Since since); @Override void listTrending(); @Override void listShowCase(); @Override void getShowcaseDetail(final ShowCase showcase); @Override void listGankData(final int page); @Override void listArsenalData(final int page); @Override void checkState(int position, RecyclerViewAdapter adapter); @Override void starRepo(int position, RecyclerViewAdapter adapter, boolean toggle); @Override void watchRepo(int position, RecyclerViewAdapter adapter, boolean toggle); @Override void forkRepo(int position, RecyclerViewAdapter adapter); @Override void getRepoInfo(String owner, String name, OnGetRepoCallback callback); @Override MaterialDialog getDialogLang(); @Override MaterialDialog getDialogSince();  }
@Test public void listTrending() throws Exception { List<Trending> trendings = new ArrayList<>(); trendings.add(new Trending()); trendings.add(new Trending()); trendings.add(new Trending()); ArgumentCaptor<Map<String, String>> captor = new ArgumentCaptor<>(); when(mExploreDataSource.listTrending(captor.capture())).thenReturn(Observable.just(trendings)); presenter.listTrending(); assertFalse(captor.getValue().keySet().contains("language")); assertTrue(captor.getValue().keySet().contains("since")); verify(view).onGetTrending(trendings); verify(view).showOnSuccess(); }