MovieDetailsPresenterImpl implements MovieDetailsPresenter { @Override public void showTrailers(Movie movie) { trailersSubscription = movieDetailsInteractor.getTrailers(movie.getId()) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(this::onGetTrailersSuccess, t -> onGetTrailersFailure()); } 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 shouldBeAbleToShowTrailers() { when(movie.getId()).thenReturn("12345"); Observable<List<Video>> responseObservable = Observable.just(videos); when(movieDetailsInteractor.getTrailers(movie.getId())).thenReturn(responseObservable); movieDetailsPresenter.showTrailers(movie); verify(view).showTrailers(videos); }
@Test public void shouldFailSilentlyWhenNoTrailers() throws Exception { when(movie.getId()).thenReturn("12345"); when(movieDetailsInteractor.getTrailers(movie.getId())).thenReturn(Observable.error(new SocketTimeoutException())); movieDetailsPresenter.showTrailers(movie); verifyZeroInteractions(view); }