@Test void findAllStreamFetch() { Fetch fetch = new Fetch(); Object id0 = "id0"; Object id1 = "id1"; Entity entity0 = mock(Entity.class); Entity entity1 = mock(Entity.class); Stream<Object> entityIds = Stream.of(id0, id1); when(delegateRepository.findAll(entityIds, fetch)).thenReturn(Stream.of(entity0, entity1)); Stream<Entity> expectedEntities = indexedRepositoryDecorator.findAll(entityIds, fetch); assertEquals(asList(entity0, entity1), expectedEntities.collect(toList())); verifyZeroInteractions(searchService); }
@Override public Stream<Entity> findAll(Query<Entity> q) { if (querySupported(q)) { LOG.debug( "public Entity findAll({}) entityTypeId: [{}] repository: [{}]", q, getEntityType().getId(), DECORATED_REPOSITORY); return delegate().findAll(q); } else { LOG.debug( "public Entity findAll({}) entityTypeId: [{}] repository: [{}]", q, getEntityType().getId(), INDEX_REPOSITORY); Stream<Object> entityIds = tryTwice(() -> searchService.search(getEntityType(), q)); return delegate().findAll(entityIds, q.getFetch()); } }
IndexedRepositoryDecorator extends AbstractRepositoryDecorator<Entity> { @Override public Stream<Entity> findAll(Query<Entity> q) { if (querySupported(q)) { LOG.debug( "public Entity findAll({}) entityTypeId: [{}] repository: [{}]", q, getEntityType().getId(), DECORATED_REPOSITORY); return delegate().findAll(q); } else { LOG.debug( "public Entity findAll({}) entityTypeId: [{}] repository: [{}]", q, getEntityType().getId(), INDEX_REPOSITORY); Stream<Object> entityIds = tryTwice(() -> searchService.search(getEntityType(), q)); return delegate().findAll(entityIds, q.getFetch()); } } }
IndexedRepositoryDecorator extends AbstractRepositoryDecorator<Entity> { @Override public Stream<Entity> findAll(Query<Entity> q) { if (querySupported(q)) { LOG.debug( "public Entity findAll({}) entityTypeId: [{}] repository: [{}]", q, getEntityType().getId(), DECORATED_REPOSITORY); return delegate().findAll(q); } else { LOG.debug( "public Entity findAll({}) entityTypeId: [{}] repository: [{}]", q, getEntityType().getId(), INDEX_REPOSITORY); Stream<Object> entityIds = tryTwice(() -> searchService.search(getEntityType(), q)); return delegate().findAll(entityIds, q.getFetch()); } } IndexedRepositoryDecorator(
      Repository<Entity> delegateRepository,
      SearchService searchService,
      IndexJobScheduler indexJobScheduler); }
IndexedRepositoryDecorator extends AbstractRepositoryDecorator<Entity> { @Override public Stream<Entity> findAll(Query<Entity> q) { if (querySupported(q)) { LOG.debug( "public Entity findAll({}) entityTypeId: [{}] repository: [{}]", q, getEntityType().getId(), DECORATED_REPOSITORY); return delegate().findAll(q); } else { LOG.debug( "public Entity findAll({}) entityTypeId: [{}] repository: [{}]", q, getEntityType().getId(), INDEX_REPOSITORY); Stream<Object> entityIds = tryTwice(() -> searchService.search(getEntityType(), q)); return delegate().findAll(entityIds, q.getFetch()); } } IndexedRepositoryDecorator(
      Repository<Entity> delegateRepository,
      SearchService searchService,
      IndexJobScheduler indexJobScheduler); @Override Entity findOne(Query<Entity> q); @Override Stream<Entity> findAll(Query<Entity> q); @Override Set<RepositoryCapability> getCapabilities(); @Override Set<Operator> getQueryOperators(); @Override long count(Query<Entity> q); @Override AggregateResult aggregate(AggregateQuery aggregateQuery); }
IndexedRepositoryDecorator extends AbstractRepositoryDecorator<Entity> { @Override public Stream<Entity> findAll(Query<Entity> q) { if (querySupported(q)) { LOG.debug( "public Entity findAll({}) entityTypeId: [{}] repository: [{}]", q, getEntityType().getId(), DECORATED_REPOSITORY); return delegate().findAll(q); } else { LOG.debug( "public Entity findAll({}) entityTypeId: [{}] repository: [{}]", q, getEntityType().getId(), INDEX_REPOSITORY); Stream<Object> entityIds = tryTwice(() -> searchService.search(getEntityType(), q)); return delegate().findAll(entityIds, q.getFetch()); } } IndexedRepositoryDecorator(
      Repository<Entity> delegateRepository,
      SearchService searchService,
      IndexJobScheduler indexJobScheduler); @Override Entity findOne(Query<Entity> q); @Override Stream<Entity> findAll(Query<Entity> q); @Override Set<RepositoryCapability> getCapabilities(); @Override Set<Operator> getQueryOperators(); @Override long count(Query<Entity> q); @Override AggregateResult aggregate(AggregateQuery aggregateQuery);  }