@Test public void testTooManyRepositoriesAreCappedToFive() throws Exception { TestObserver<List<GitHubRepository>> observer = new TestObserver<>(); viewModel.toGitHubRepositoryList() .apply(Arrays.asList(1, 2, 3, 4, 5, 6)) .subscribe(observer); observer.awaitTerminalEvent(); assertEquals("Invalid number of repositories", 5, ((Collection<?>) observer.getEvents().get(0).get(0)).size()); }
@NonNull Function<List<Integer>, Observable<List<GitHubRepository>>> toGitHubRepositoryList() { return repositoryIds -> Observable.fromIterable(repositoryIds) .take(MAX_REPOSITORIES_DISPLAYED) .map(this::getGitHubRepositoryObservable) .toList() .toObservable() .flatMap(RxUtils::toObservableList); }
RepositoriesViewModel extends AbstractViewModel { @NonNull Function<List<Integer>, Observable<List<GitHubRepository>>> toGitHubRepositoryList() { return repositoryIds -> Observable.fromIterable(repositoryIds) .take(MAX_REPOSITORIES_DISPLAYED) .map(this::getGitHubRepositoryObservable) .toList() .toObservable() .flatMap(RxUtils::toObservableList); } }
RepositoriesViewModel extends AbstractViewModel { @NonNull Function<List<Integer>, Observable<List<GitHubRepository>>> toGitHubRepositoryList() { return repositoryIds -> Observable.fromIterable(repositoryIds) .take(MAX_REPOSITORIES_DISPLAYED) .map(this::getGitHubRepositoryObservable) .toList() .toObservable() .flatMap(RxUtils::toObservableList); } RepositoriesViewModel(@NonNull final GetGitHubRepositorySearch getGitHubRepositorySearch,
                                 @NonNull final GetGitHubRepository getGitHubRepository); }
RepositoriesViewModel extends AbstractViewModel { @NonNull Function<List<Integer>, Observable<List<GitHubRepository>>> toGitHubRepositoryList() { return repositoryIds -> Observable.fromIterable(repositoryIds) .take(MAX_REPOSITORIES_DISPLAYED) .map(this::getGitHubRepositoryObservable) .toList() .toObservable() .flatMap(RxUtils::toObservableList); } RepositoriesViewModel(@NonNull final GetGitHubRepositorySearch getGitHubRepositorySearch,
                                 @NonNull final GetGitHubRepository getGitHubRepository); @NonNull Observable<GitHubRepository> getSelectRepository(); @NonNull Observable<List<GitHubRepository>> getRepositories(); @NonNull Observable<ProgressStatus> getNetworkRequestStatusText(); void setSearchString(@NonNull final String searchString); void selectRepository(@NonNull final GitHubRepository repository); @Override void subscribeToDataStoreInternal(@NonNull final CompositeDisposable compositeDisposable); }
RepositoriesViewModel extends AbstractViewModel { @NonNull Function<List<Integer>, Observable<List<GitHubRepository>>> toGitHubRepositoryList() { return repositoryIds -> Observable.fromIterable(repositoryIds) .take(MAX_REPOSITORIES_DISPLAYED) .map(this::getGitHubRepositoryObservable) .toList() .toObservable() .flatMap(RxUtils::toObservableList); } RepositoriesViewModel(@NonNull final GetGitHubRepositorySearch getGitHubRepositorySearch,
                                 @NonNull final GetGitHubRepository getGitHubRepository); @NonNull Observable<GitHubRepository> getSelectRepository(); @NonNull Observable<List<GitHubRepository>> getRepositories(); @NonNull Observable<ProgressStatus> getNetworkRequestStatusText(); void setSearchString(@NonNull final String searchString); void selectRepository(@NonNull final GitHubRepository repository); @Override void subscribeToDataStoreInternal(@NonNull final CompositeDisposable compositeDisposable);  }