@Test public void creditDraftRawItemsFromServiceAreMapped() throws Exception { List<CreditDraftRaw> rawList = createRawList(); new ArrangeBuilder().withCreditDraftsFromService(rawList) .withMappedCredit(Mockito.mock(CreditDraft.class)); repository.fetchCreditDrafts().subscribe(); Mockito.verify(mapper).apply(rawList.get(0)); Mockito.verify(mapper).apply(rawList.get(1)); Mockito.verify(mapper).apply(rawList.get(2)); }
@NonNull public Completable fetchCreditDrafts() { return creditService.getCreditDrafts() .subscribeOn(Schedulers.io()) .observeOn(Schedulers.computation()) .flatMapObservable(Observable::fromIterable) .map(creditDraftMapper) .toList() .doOnSuccess(store::replaceAll) .toCompletable(); }
CreditRepository { @NonNull public Completable fetchCreditDrafts() { return creditService.getCreditDrafts() .subscribeOn(Schedulers.io()) .observeOn(Schedulers.computation()) .flatMapObservable(Observable::fromIterable) .map(creditDraftMapper) .toList() .doOnSuccess(store::replaceAll) .toCompletable(); } }
CreditRepository { @NonNull public Completable fetchCreditDrafts() { return creditService.getCreditDrafts() .subscribeOn(Schedulers.io()) .observeOn(Schedulers.computation()) .flatMapObservable(Observable::fromIterable) .map(creditDraftMapper) .toList() .doOnSuccess(store::replaceAll) .toCompletable(); } @Inject  CreditRepository(@NonNull final ReactiveStore<String, CreditDraft> store,
                     @NonNull final CreditService creditService,
                     @NonNull final CreditDraftMapper creditDraftMapper); }
CreditRepository { @NonNull public Completable fetchCreditDrafts() { return creditService.getCreditDrafts() .subscribeOn(Schedulers.io()) .observeOn(Schedulers.computation()) .flatMapObservable(Observable::fromIterable) .map(creditDraftMapper) .toList() .doOnSuccess(store::replaceAll) .toCompletable(); } @Inject  CreditRepository(@NonNull final ReactiveStore<String, CreditDraft> store,
                     @NonNull final CreditService creditService,
                     @NonNull final CreditDraftMapper creditDraftMapper); @NonNull Observable<Option<List<CreditDraft>>> getAllCreditDrafts(); @NonNull Completable fetchCreditDrafts(); }
CreditRepository { @NonNull public Completable fetchCreditDrafts() { return creditService.getCreditDrafts() .subscribeOn(Schedulers.io()) .observeOn(Schedulers.computation()) .flatMapObservable(Observable::fromIterable) .map(creditDraftMapper) .toList() .doOnSuccess(store::replaceAll) .toCompletable(); } @Inject  CreditRepository(@NonNull final ReactiveStore<String, CreditDraft> store,
                     @NonNull final CreditService creditService,
                     @NonNull final CreditDraftMapper creditDraftMapper); @NonNull Observable<Option<List<CreditDraft>>> getAllCreditDrafts(); @NonNull Completable fetchCreditDrafts();  }