CategoryRepository { public Single<List<Category>> retrieveAll() { if (memoryCache.get() != null) { return Single.just(memoryCache.get()); } return networkService.getCategories() .map(categoryResponse -> mapper.fromNetwork(categoryResponse.getTags())) .doOnSuccess(memoryCache::set) .doOnError(throwable-> Log.w(CategoryRepository.class.getSimpleName(),"Can't get categories",throwable)) .subscribeOn(Schedulers.io()); } CategoryRepository(CategoryNetworkService networkService, CategoryMapper mapper); Single<List<Category>> retrieveAll();  }
@Test public void retrieveAll_Success() { TestObserver<List<Category>> testObserver = new TestObserver<>(); repository.retrieveAll().subscribe(testObserver); testObserver.awaitTerminalEvent(); List<Category> result = testObserver.values().get(0); assertThat(result.get(0)).isEqualTo(category); }