BookInfoPresenter extends BasePresenter<BookInfoContract.View> implements BookInfoContract.Presenter { @Override public void shareBookClicked(FireBookDetails bookInfo) { if (bookInfo == null) { getView().showSnackBarMessage(R.string.book_info_still_loading); return; } analytics.trackShareBook(bookInfo); getView().sendShareEvent(bookInfo.getBookTitle()); } BookInfoPresenter(@NonNull BookService bookService, @NonNull DownloadService downloadService,
                      @NonNull Analytics analytics, Scheduler ioScheduler, Scheduler mainScheduler); @Override void loadContributorInformation(FireBookDetails bookDetailId); @Override void downloadBook(final FireBookDetails bookInfo); @Override void shareBookClicked(FireBookDetails bookInfo);  }
@Test public void shareBook_SendsShareEvent() { BOOK_DETAIL.setBookTitle("Book Title"); bookInfoPresenter.shareBookClicked(BOOK_DETAIL); verify(bookInfoView).sendShareEvent("Book Title"); verify(analytics).trackShareBook(BOOK_DETAIL); }
@Test public void shareBook_BookNull_ShowsErrorMessage() { bookInfoPresenter.shareBookClicked(null); verify(bookInfoView).showSnackBarMessage(R.string.book_info_still_loading); verify(bookInfoView, never()).sendShareEvent(anyString()); }