SentenceListPresenter extends AbstractMvpPresenter<SentenceList.View, SentenceListViewModel> implements SentenceList.Presenter<SentenceList.View, SentenceListViewModel> { @Override public void setFavorite(@NonNull Sentence sentence, boolean favorite) { sentence.setIsStar(favorite); mUpdateFavoriteSentenceUC.requestParams(sentence).execute(mUpdateFavoriteSentenceUseCaseHandler); } SentenceListPresenter(); void setLoadSentencesUCAndHandler(LoadSentencesUC loadSentencesUC, UseCaseHandler useCaseHandler); void setUpdateFavoriteSentenceUCAndHandler(UpdateFavoriteSentenceUC updateFavoriteSentenceUC, UseCaseHandler useCaseHandler); @Override void loadSentences(final boolean firstLoad); @Override void openSentence(long sentenceId); @Override void setFavorite(@NonNull Sentence sentence, boolean favorite); @Override void onCreate(); @Override void onActivityCreated(); @Subscribe @Override void onSentenceChanged(SentenceChangedEvent event); @Override void setNeedAutoFocused(boolean needAutoFocused); @Override void onDestroy(); @VisibleForTesting EventBus getEventBus();  }
@Test public void testSetFavorite_True() { SentenceEntity sentence = new SentenceEntity(); mSentenceListPresenter.setFavorite(sentence, true); assertTrue(sentence.getIsStar()); verify(mUpdateFavoriteSentenceUC).requestParams(sentence); verify(mUpdateFavoriteSentenceUC).execute(mUpdateFavoriteSentenceUseCaseHandler); }
@Test public void testSetFavorite_False() { SentenceEntity sentence = new SentenceEntity(); mSentenceListPresenter.setFavorite(sentence, false); assertFalse(sentence.getIsStar()); verify(mUpdateFavoriteSentenceUC).requestParams(sentence); verify(mUpdateFavoriteSentenceUC).execute(mUpdateFavoriteSentenceUseCaseHandler); }