### Question:
RepositoriesViewModel extends AbstractViewModel { @NonNull static Function<DataStreamNotification<GitHubRepositorySearch>, ProgressStatus> toProgressStatus() { return notification -> { if (notification.isOngoing()) { return ProgressStatus.LOADING; } else if (notification.isCompletedWithError()) { return ProgressStatus.ERROR; } else { return ProgressStatus.IDLE; } }; } 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);  }### Answer:
@Test public void testStartFetchingReportedAsLoading() throws Exception { assertEquals(LOADING, toProgressStatus().apply(ongoing())); }
@Test public void testFetchingErrorReportedAsError() throws Exception { assertEquals(ERROR, toProgressStatus().apply(completedWithError(null))); }
@Test public void testAnyValueReportedAsIdle() throws Exception { GitHubRepositorySearch value = new GitHubRepositorySearch("", Collections.emptyList()); assertEquals(IDLE, toProgressStatus().apply(onNext(value))); }