MainPresenter { void getFitnessData() { fitnessSessionDataList.clear(); view.showLoading(); DataReadRequest.Builder dataReadRequestBuilder = getDataReadRequestBuilder(); DataReadRequest dataReadRequest = dataReadRequestBuilder.build(); DataReadRequest dataReadRequestServer = dataReadRequestBuilder.enableServerQueries().build(); disposable.add( rxFit.history().readBuckets(dataReadRequestServer) .doOnError(throwable -> { if(throwable instanceof StatusException && ((StatusException)throwable).getStatus().getStatusCode() == CommonStatusCodes.TIMEOUT) Log.e("MainActivity", "Timeout on server query request", throwable); }) .compose(RxFitOnExceptionResumeNext.with(rxFit.history().readBuckets(dataReadRequest))) .subscribeOn(Schedulers.computation()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(this::onBucketLoaded, this::onBucketLoadError, () -> view.onFitnessSessionDataLoaded(fitnessSessionDataList)) ); } MainPresenter(RxFit rxFit); void attachView(MainView view); void detachView();  }
@Test public void testNoResults() { doReturn(Observable.empty()).when(history).readBuckets(Matchers.any(DataReadRequest.class)); mainPresenter.getFitnessData(); ArgumentCaptor<List> fitnessSessionDataCaptor = ArgumentCaptor.forClass(List.class); verify(mainView, times(1)).onFitnessSessionDataLoaded(fitnessSessionDataCaptor.capture()); assertTrue(fitnessSessionDataCaptor.getValue().isEmpty()); }