MovieDetailsPresenterImpl implements MovieDetailsPresenter { @Override public void onFavoriteClick(Movie movie) { if (isViewAttached()) { boolean isFavorite = favoritesInteractor.isFavorite(movie.getId()); if (isFavorite) { favoritesInteractor.unFavorite(movie.getId()); view.showUnFavorited(); } else { favoritesInteractor.setFavorite(movie); view.showFavorited(); } } } MovieDetailsPresenterImpl(MovieDetailsInteractor movieDetailsInteractor, FavoritesInteractor favoritesInteractor); @Override void setView(MovieDetailsView view); @Override void destroy(); @Override void showDetails(Movie movie); @Override void showTrailers(Movie movie); @Override void showReviews(Movie movie); @Override void showFavoriteButton(Movie movie); @Override void onFavoriteClick(Movie movie);  }
@Test public void shouldUnfavoriteIfFavoriteTapped() { when(movie.getId()).thenReturn("12345"); when(favoritesInteractor.isFavorite(movie.getId())).thenReturn(true); movieDetailsPresenter.onFavoriteClick(movie); verify(view).showUnFavorited(); }
@Test public void shouldFavoriteIfUnfavoriteTapped() { when(movie.getId()).thenReturn("12345"); when(favoritesInteractor.isFavorite(movie.getId())).thenReturn(false); movieDetailsPresenter.onFavoriteClick(movie); verify(view).showFavorited(); }