SentenceDetailPresenter extends AbstractMvpPresenter<SentenceDetail.View, SentenceDetailViewModel> implements SentenceDetail.Presenter<SentenceDetail.View, SentenceDetailViewModel> { @Override public void loadSentences(boolean firstLoad) { if (firstLoad) { mLoadSentenceCallback = new LoadSentencesUC.LoadSentencesCallback() { @Override public void onSentencesGet(List<? extends Sentence> sentences) { if (mView != null) { if ((sentences == null || sentences.isEmpty()) && getViewModel().getCurrentSentenseId() >= 0 && getViewModel().isFavoriteList()) { loadCurrentSentense(new LoadSentenceUC.LoadSentenceCallback() { @Override public void onSentenceGot(Sentence sentence) { List<Sentence> sentences1 = new ArrayList<Sentence>(); if (sentence != null) { sentences1.add(sentence); } showSentenceList(sentences1); } }); } else { showSentenceList(sentences); } } } }; } mLoadSentencesUC.requestParams(new LoadSentencesUC.LoadSentencesRequestParms(firstLoad, getViewModel().isFavoriteList())) .callback(mLoadSentenceCallback) .execute(mLoadSentencesUseCaseHandler); } SentenceDetailPresenter(SentenceDataRepository sentenceDataRepository, AudioPlayer audioPlayer); void setLoadSentencesUCAndHandler(LoadSentencesUC loadSentencesUC, UseCaseHandler useCaseHandler); void setUpdateFavoriteSentenceUCAndHandler(UpdateFavoriteSentenceUC updateFavoriteSentenceUC, UseCaseHandler useCaseHandler); void setSetPlayStyleUCAndHandler(SetPlayStyleUC setPlayStyleUC, UseCaseHandler useCaseHandler); void setGetPlayStyleUCAndHandler(GetPlayStyleUC getPlayStyleUCForPrepareMenu,
                                            GetPlayStyleUC getPlayStyleUCForPlayAudio,
                                            UseCaseHandler useCaseHandler); void setFetchSentenceAudioUCAndHandler(FetchSentenceAudioUC fetchSentenceAudioUC, UseCaseHandler useCaseHandler); @Override void loadSentences(boolean firstLoad); void loadCurrentSentense(LoadSentenceUC.LoadSentenceCallback callback); @Override void fetchSentenceAudio(); @Override void setPlayStyle(int style); @Override void setFavorite(@NonNull Sentence sentence, boolean favorite); @Override void onAudioFabButtonClicked(); @Subscribe(threadMode = ThreadMode.MAIN) @Override void onFetchingAudioEvent(FetchingAudioEvent fetchingAudioEvent); @Override void onDisplaySentence(Sentence sentence); @Override void onCreate(); @Override void onViewCreated(); @Override void onPrepareOptionsMenu(); @Override void onActivityCreated(); @Override void onResume(); @Override void onStop(); @Override void onDestroy(); @VisibleForTesting EventBus getEventBus();  }
@Test public void testLoadSentences_NotFirst() { mSentenceDetailPresenter.loadSentences(false); verify(mLoadSentencesUC).requestParams(mLoadSentencesRequestParmsCaptor.capture()); assertFalse(mLoadSentencesRequestParmsCaptor.getValue().isFavorite()); assertFalse(mLoadSentencesRequestParmsCaptor.getValue().isFirstLoad()); verify(mLoadSentencesUC).callback(mLoadSentencesCallbackCaptor.capture()); LoadSentencesUC.LoadSentencesCallback callback = mLoadSentencesCallbackCaptor.getValue(); assertNull(callback); verify(mLoadSentencesUC).execute(mLoadSentencesUseCaseHandler); }