@Test public void getSounds_emitsSearchResultsWrappedInDisplayableItems() { List<Sound> sounds = TestData.sounds(10); new Arrangement().enqueueSearchResults(ofObj(sounds)); viewModel.getSoundsOnceAndStream() .test() .assertValue(hasOptionValue(expectedDisplayableItems(sounds))); }
@NonNull Observable<Option<List<DisplayableItem<Sound>>>> getSoundsOnceAndStream() { return searchDataModel.getSearchStateOnceAndStream() .map(SearchState::results) .map(it -> it.map(SearchFragmentViewModel::wrapInDisplayableItem)) .doOnNext(__ -> audioPlayer.stopPlayback()); }
SearchFragmentViewModel extends SimpleViewModel { @NonNull Observable<Option<List<DisplayableItem<Sound>>>> getSoundsOnceAndStream() { return searchDataModel.getSearchStateOnceAndStream() .map(SearchState::results) .map(it -> it.map(SearchFragmentViewModel::wrapInDisplayableItem)) .doOnNext(__ -> audioPlayer.stopPlayback()); } }
SearchFragmentViewModel extends SimpleViewModel { @NonNull Observable<Option<List<DisplayableItem<Sound>>>> getSoundsOnceAndStream() { return searchDataModel.getSearchStateOnceAndStream() .map(SearchState::results) .map(it -> it.map(SearchFragmentViewModel::wrapInDisplayableItem)) .doOnNext(__ -> audioPlayer.stopPlayback()); } SearchFragmentViewModel(@NonNull final SearchDataModel searchDataModel,
                            @NonNull final Navigator navigator,
                            @NonNull final AudioPlayer audioPlayer); }
SearchFragmentViewModel extends SimpleViewModel { @NonNull Observable<Option<List<DisplayableItem<Sound>>>> getSoundsOnceAndStream() { return searchDataModel.getSearchStateOnceAndStream() .map(SearchState::results) .map(it -> it.map(SearchFragmentViewModel::wrapInDisplayableItem)) .doOnNext(__ -> audioPlayer.stopPlayback()); } SearchFragmentViewModel(@NonNull final SearchDataModel searchDataModel,
                            @NonNull final Navigator navigator,
                            @NonNull final AudioPlayer audioPlayer);  }
SearchFragmentViewModel extends SimpleViewModel { @NonNull Observable<Option<List<DisplayableItem<Sound>>>> getSoundsOnceAndStream() { return searchDataModel.getSearchStateOnceAndStream() .map(SearchState::results) .map(it -> it.map(SearchFragmentViewModel::wrapInDisplayableItem)) .doOnNext(__ -> audioPlayer.stopPlayback()); } SearchFragmentViewModel(@NonNull final SearchDataModel searchDataModel,
                            @NonNull final Navigator navigator,
                            @NonNull final AudioPlayer audioPlayer);   }