@Test public void searchMakeUp_200OkResponse_InvokesCorrectApiCalls() { when(makeUpProductRestService.searchMakeUpProducts(anyString(), anyString())).thenReturn (Observable.just(makeUpList()).toList()); TestSubscriber<List<MakeUp>> subscriber = new TestSubscriber<>(); makeUpRepository.searchMakeUp(BRAND_COVERGIRL, PRODUCT_TYPE_LIPSTICK).subscribe(subscriber); subscriber.awaitTerminalEvent(); subscriber.assertNoErrors(); List<List<MakeUp>> onNextEvents = subscriber.getOnNextEvents(); List<MakeUp> makeup = onNextEvents.get(0); Assert.assertEquals(BRAND_COVERGIRL, makeup.get(0).getBrand()); Assert.assertEquals(PRODUCT_TYPE_LIPSTICK, makeup.get(0).getProductType()); verify(makeUpProductRestService).searchMakeUpProducts(BRAND_COVERGIRL, PRODUCT_TYPE_LIPSTICK); }
@Override public Observable<List<MakeUp>> searchMakeUp(final String brandName, final String productName) { return Observable.defer(() -> makeUpProductRestService.searchMakeUpProducts(brandName, productName)) .retryWhen(observable -> observable.flatMap(o -> { if (o instanceof IOException) { return Observable.just(null); } return Observable.error(o); })); }
MakeUpRepositoryImpl implements MakeUpRepository { @Override public Observable<List<MakeUp>> searchMakeUp(final String brandName, final String productName) { return Observable.defer(() -> makeUpProductRestService.searchMakeUpProducts(brandName, productName)) .retryWhen(observable -> observable.flatMap(o -> { if (o instanceof IOException) { return Observable.just(null); } return Observable.error(o); })); } }
MakeUpRepositoryImpl implements MakeUpRepository { @Override public Observable<List<MakeUp>> searchMakeUp(final String brandName, final String productName) { return Observable.defer(() -> makeUpProductRestService.searchMakeUpProducts(brandName, productName)) .retryWhen(observable -> observable.flatMap(o -> { if (o instanceof IOException) { return Observable.just(null); } return Observable.error(o); })); } MakeUpRepositoryImpl(MakeUpProductRestService makeUpProductRestService); }
MakeUpRepositoryImpl implements MakeUpRepository { @Override public Observable<List<MakeUp>> searchMakeUp(final String brandName, final String productName) { return Observable.defer(() -> makeUpProductRestService.searchMakeUpProducts(brandName, productName)) .retryWhen(observable -> observable.flatMap(o -> { if (o instanceof IOException) { return Observable.just(null); } return Observable.error(o); })); } MakeUpRepositoryImpl(MakeUpProductRestService makeUpProductRestService); @Override Observable<List<MakeUp>> searchMakeUp(final String brandName, final String productName); }
MakeUpRepositoryImpl implements MakeUpRepository { @Override public Observable<List<MakeUp>> searchMakeUp(final String brandName, final String productName) { return Observable.defer(() -> makeUpProductRestService.searchMakeUpProducts(brandName, productName)) .retryWhen(observable -> observable.flatMap(o -> { if (o instanceof IOException) { return Observable.just(null); } return Observable.error(o); })); } MakeUpRepositoryImpl(MakeUpProductRestService makeUpProductRestService); @Override Observable<List<MakeUp>> searchMakeUp(final String brandName, final String productName);  }