XkcdStoreImpl implements XkcdStore { @Override public Observable<DomainStripe> currentStripe() { final long lastShownStripeNum = P.lastShownStripeNum.get(); Observable<DataStripe> base = Observable.create(new Observable.OnSubscribe<DataStripe>() { @Override public void call(final @NonNull Subscriber<? super DataStripe> subscriber) { subscriber.onStart(); final DataStripe currentRetrieved = mClient.getCurrentStripe().toBlocking().single(); if (currentRetrieved != null) { subscriber.onNext(currentRetrieved); XkcdStoreImpl.this.mXkcdDatabaseHandler.insertStripe( XkcdStoreImpl.this.mDatabaseEntityMapper.transform(currentRetrieved)); subscriber.onCompleted(); } } }); if (lastShownStripeNum != -1) { base = base.onErrorResumeNext(dataStripeWithNum(lastShownStripeNum)); } return mapToDomain(base).cache(); } @Inject  XkcdStoreImpl(final @NonNull XkcdClient client,
      final @NonNull DatabaseEntityMapper databaseEntityMapper,
      final @NonNull DomainEntityMapper entityMapper,
      final @NonNull XkcdDatabaseHandler xkcdDatabaseHandler); @Override Observable<DomainStripe> currentStripe(); @Override Observable<DomainStripe> stripeWithNum(final long stripeNum);  }
@Test public void testGetStripeCurrentSuccessful() { final DataStripe sourceStripe = generateRandomDataStripe(); final DomainStripe targetStripe = generateRandomDomainStripe(); given(mMockClient.getCurrentStripe()).willReturn(Observable.just(sourceStripe)); given(mMockDomainEntityMapper.transform(sourceStripe)).willReturn(targetStripe); final TestSubscriber<DomainStripe> testSubscriber = new TestSubscriber<>(); mSut.currentStripe().subscribe(testSubscriber); testSubscriber.assertNoErrors(); testSubscriber.assertReceivedOnNext(Collections.singletonList(targetStripe)); testSubscriber.assertCompleted(); }