SentenceDetailPresenter extends AbstractMvpPresenter<SentenceDetail.View, SentenceDetailViewModel> implements SentenceDetail.Presenter<SentenceDetail.View, SentenceDetailViewModel> { @Override public void onDisplaySentence(Sentence sentence) { if (sentence == null) { return; } long oldId = getViewModel().getCurrentSentenseId(); if (oldId != sentence.getId()) { getViewModel().setPlayToken(System.currentTimeMillis()); getViewModel().setCurrentSentenseId(sentence.getId()); getViewModel().setCurrentAudioUrl(sentence.getAudioUrl()); getViewModel().setAudioStatus(SentenceDetailViewModel.AUDIO_STATUS.NORMAL); updateAudioFabStatusAndPlayIfNeed(); } } 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 testOnDisplaySentence_SameSentence() { when(mCurrentSentence.getId()).thenReturn(1L); mModel.setCurrentSentenseId(1L); mSentenceDetailPresenter.onDisplaySentence(mCurrentSentence); verify(mView, times(0)).updateAudioFabAnimator(any(SentenceDetailViewModel.AUDIO_STATUS.class)); }