@Test public void getPopularMoviesMakesApiCall() { when(apiService.discover(SORT_BY_POPULARITY, PAGE, API_KEY)) .thenReturn(Observable.just(mDiscoverMoviesResponse)); mRemoteRepository.getPopularMovies(1).subscribeWith(mMovieListTestSubscriber); verify(apiService).discover(SORT_BY_POPULARITY, PAGE, API_KEY); mMovieListTestSubscriber.assertValue(mMovieList); }
@Override public Observable<List<Movie>> getPopularMovies(int page) { Observable<DiscoverMoviesResponse> discoverMoviesResponseObservable = apiService.discover("popularity.desc", page, ApiUtils.getApiKey()); return discoverMoviesResponseObservable .flatMap(new Function<DiscoverMoviesResponse, ObservableSource<? extends List<Movie>>>() { @Override public ObservableSource<? extends List<Movie>> apply(DiscoverMoviesResponse discoverMoviesResponse) throws Exception { return Observable.just(discoverMoviesResponse.getResults()); } }); }
MoviesRemoteRepository implements MoviesRepository { @Override public Observable<List<Movie>> getPopularMovies(int page) { Observable<DiscoverMoviesResponse> discoverMoviesResponseObservable = apiService.discover("popularity.desc", page, ApiUtils.getApiKey()); return discoverMoviesResponseObservable .flatMap(new Function<DiscoverMoviesResponse, ObservableSource<? extends List<Movie>>>() { @Override public ObservableSource<? extends List<Movie>> apply(DiscoverMoviesResponse discoverMoviesResponse) throws Exception { return Observable.just(discoverMoviesResponse.getResults()); } }); } }
MoviesRemoteRepository implements MoviesRepository { @Override public Observable<List<Movie>> getPopularMovies(int page) { Observable<DiscoverMoviesResponse> discoverMoviesResponseObservable = apiService.discover("popularity.desc", page, ApiUtils.getApiKey()); return discoverMoviesResponseObservable .flatMap(new Function<DiscoverMoviesResponse, ObservableSource<? extends List<Movie>>>() { @Override public ObservableSource<? extends List<Movie>> apply(DiscoverMoviesResponse discoverMoviesResponse) throws Exception { return Observable.just(discoverMoviesResponse.getResults()); } }); } MoviesRemoteRepository(MovieApiService apiService); }
MoviesRemoteRepository implements MoviesRepository { @Override public Observable<List<Movie>> getPopularMovies(int page) { Observable<DiscoverMoviesResponse> discoverMoviesResponseObservable = apiService.discover("popularity.desc", page, ApiUtils.getApiKey()); return discoverMoviesResponseObservable .flatMap(new Function<DiscoverMoviesResponse, ObservableSource<? extends List<Movie>>>() { @Override public ObservableSource<? extends List<Movie>> apply(DiscoverMoviesResponse discoverMoviesResponse) throws Exception { return Observable.just(discoverMoviesResponse.getResults()); } }); } MoviesRemoteRepository(MovieApiService apiService); @Override Observable<List<Movie>> getPopularMovies(int page); @Override Observable<Movie> getMovieDetails(long movieId); }
MoviesRemoteRepository implements MoviesRepository { @Override public Observable<List<Movie>> getPopularMovies(int page) { Observable<DiscoverMoviesResponse> discoverMoviesResponseObservable = apiService.discover("popularity.desc", page, ApiUtils.getApiKey()); return discoverMoviesResponseObservable .flatMap(new Function<DiscoverMoviesResponse, ObservableSource<? extends List<Movie>>>() { @Override public ObservableSource<? extends List<Movie>> apply(DiscoverMoviesResponse discoverMoviesResponse) throws Exception { return Observable.just(discoverMoviesResponse.getResults()); } }); } MoviesRemoteRepository(MovieApiService apiService); @Override Observable<List<Movie>> getPopularMovies(int page); @Override Observable<Movie> getMovieDetails(long movieId);  }