@Test public void search_ValidSearchTerm_ReturnsResults() { List<MakeUp> makeUpDummyList = getDummyMakeUpList(); when(makeUpRepository.searchMakeUp(anyString(), anyString())).thenReturn(Observable.just (makeUpDummyList)); makeUpSearchPresenter.search("maybelline", "bronzer"); verify(view).showLoading(); verify(view).hideLoading(); verify(view).showSearchResults(makeUpDummyList); verify(view, never()).showError(anyString()); }
@Override public void search(String brand, String product) { checkViewAttached(); getView().showLoading(); addSubscription(makeUpRepository.searchMakeUp(brand, product).subscribeOn(ioScheduler) .observeOn(mainScheduler).subscribe(new Subscriber<List<MakeUp>>() { @Override public void onCompleted() { } @Override public void onError(Throwable e) { getView().hideLoading(); getView().showError(e.getMessage()); } @Override public void onNext(List<MakeUp> makeUps) { getView().hideLoading(); if (makeUps.isEmpty()) { getView().showEmptyState(); } else { getView().showSearchResults(makeUps); } } })); }
MakeUpSearchPresenter extends BasePresenter<MakeUpSearchContract.View> implements
        MakeUpSearchContract.Presenter { @Override public void search(String brand, String product) { checkViewAttached(); getView().showLoading(); addSubscription(makeUpRepository.searchMakeUp(brand, product).subscribeOn(ioScheduler) .observeOn(mainScheduler).subscribe(new Subscriber<List<MakeUp>>() { @Override public void onCompleted() { } @Override public void onError(Throwable e) { getView().hideLoading(); getView().showError(e.getMessage()); } @Override public void onNext(List<MakeUp> makeUps) { getView().hideLoading(); if (makeUps.isEmpty()) { getView().showEmptyState(); } else { getView().showSearchResults(makeUps); } } })); } }
MakeUpSearchPresenter extends BasePresenter<MakeUpSearchContract.View> implements
        MakeUpSearchContract.Presenter { @Override public void search(String brand, String product) { checkViewAttached(); getView().showLoading(); addSubscription(makeUpRepository.searchMakeUp(brand, product).subscribeOn(ioScheduler) .observeOn(mainScheduler).subscribe(new Subscriber<List<MakeUp>>() { @Override public void onCompleted() { } @Override public void onError(Throwable e) { getView().hideLoading(); getView().showError(e.getMessage()); } @Override public void onNext(List<MakeUp> makeUps) { getView().hideLoading(); if (makeUps.isEmpty()) { getView().showEmptyState(); } else { getView().showSearchResults(makeUps); } } })); } MakeUpSearchPresenter(MakeUpRepository makeUpRepository, Scheduler ioScheduler, Scheduler
            mainScheduler); }
MakeUpSearchPresenter extends BasePresenter<MakeUpSearchContract.View> implements
        MakeUpSearchContract.Presenter { @Override public void search(String brand, String product) { checkViewAttached(); getView().showLoading(); addSubscription(makeUpRepository.searchMakeUp(brand, product).subscribeOn(ioScheduler) .observeOn(mainScheduler).subscribe(new Subscriber<List<MakeUp>>() { @Override public void onCompleted() { } @Override public void onError(Throwable e) { getView().hideLoading(); getView().showError(e.getMessage()); } @Override public void onNext(List<MakeUp> makeUps) { getView().hideLoading(); if (makeUps.isEmpty()) { getView().showEmptyState(); } else { getView().showSearchResults(makeUps); } } })); } MakeUpSearchPresenter(MakeUpRepository makeUpRepository, Scheduler ioScheduler, Scheduler
            mainScheduler); @Override void search(String brand, String product); }
MakeUpSearchPresenter extends BasePresenter<MakeUpSearchContract.View> implements
        MakeUpSearchContract.Presenter { @Override public void search(String brand, String product) { checkViewAttached(); getView().showLoading(); addSubscription(makeUpRepository.searchMakeUp(brand, product).subscribeOn(ioScheduler) .observeOn(mainScheduler).subscribe(new Subscriber<List<MakeUp>>() { @Override public void onCompleted() { } @Override public void onError(Throwable e) { getView().hideLoading(); getView().showError(e.getMessage()); } @Override public void onNext(List<MakeUp> makeUps) { getView().hideLoading(); if (makeUps.isEmpty()) { getView().showEmptyState(); } else { getView().showSearchResults(makeUps); } } })); } MakeUpSearchPresenter(MakeUpRepository makeUpRepository, Scheduler ioScheduler, Scheduler
            mainScheduler); @Override void search(String brand, String product);  }