CloudUserDataStore implements UserDataStore { @Override public Observable<UserEntity> userEntityDetails(final int userId) { return this.restApi.userEntityById(userId) .doOnNext(saveToCacheAction); } CloudUserDataStore(RestApi restApi, UserCache userCache); @Override Observable<List<UserEntity>> userEntityList(); @Override Observable<UserEntity> userEntityDetails(final int userId);  }
@Test public void testGetUserEntityDetailsFromApi() { UserEntity fakeUserEntity = new UserEntity(); Observable<UserEntity> fakeObservable = Observable.just(fakeUserEntity); given(mockRestApi.userEntityById(FAKE_USER_ID)).willReturn(fakeObservable); cloudUserDataStore.userEntityDetails(FAKE_USER_ID); verify(mockRestApi).userEntityById(FAKE_USER_ID); }