@Test public void verify_getSearchPagedList_called_only_once_time() { when(usecase.getSearchPagedList(query)).thenReturn(Observable.just(pagedList)); verify(usecase, times(0)).getSearchPagedList(query); viewModel.searchFor(query); verify(usecase, times(1)).getSearchPagedList(query); viewModel.searchFor(query); verify(usecase, times(1)).getSearchPagedList(query); }
public void searchFor(String query) { if (searchQueryState == null){ createPagedList(query); }else { searchNewsUseCase.updateSearchQuery(query); } searchQueryState = query; }
SearchViewModel extends BaseViewModel { public void searchFor(String query) { if (searchQueryState == null){ createPagedList(query); }else { searchNewsUseCase.updateSearchQuery(query); } searchQueryState = query; } }
SearchViewModel extends BaseViewModel { public void searchFor(String query) { if (searchQueryState == null){ createPagedList(query); }else { searchNewsUseCase.updateSearchQuery(query); } searchQueryState = query; } @Inject  SearchViewModel(@Named(value = IO_SCHEDULER) Scheduler subscribeOn, @Named(value = MAIN_THREAD_SCHEDULER) Scheduler observeOn, SearchNewsUseCase<NewsUI> searchNewsUseCase); }
SearchViewModel extends BaseViewModel { public void searchFor(String query) { if (searchQueryState == null){ createPagedList(query); }else { searchNewsUseCase.updateSearchQuery(query); } searchQueryState = query; } @Inject  SearchViewModel(@Named(value = IO_SCHEDULER) Scheduler subscribeOn, @Named(value = MAIN_THREAD_SCHEDULER) Scheduler observeOn, SearchNewsUseCase<NewsUI> searchNewsUseCase); void searchFor(String query); LiveData<PagedList<NewsUI>> getNewsLiveData(); MutableLiveData<DataStatus> getPagingDataStatus(); String getSearchQueryState(); }
SearchViewModel extends BaseViewModel { public void searchFor(String query) { if (searchQueryState == null){ createPagedList(query); }else { searchNewsUseCase.updateSearchQuery(query); } searchQueryState = query; } @Inject  SearchViewModel(@Named(value = IO_SCHEDULER) Scheduler subscribeOn, @Named(value = MAIN_THREAD_SCHEDULER) Scheduler observeOn, SearchNewsUseCase<NewsUI> searchNewsUseCase); void searchFor(String query); LiveData<PagedList<NewsUI>> getNewsLiveData(); MutableLiveData<DataStatus> getPagingDataStatus(); String getSearchQueryState();  }