@SuppressWarnings("unchecked") @Test void findAllUnknownIndexExceptionRecoverable() { Stream<Object> entityStream = mock(Stream.class); when(searchService.search(repositoryEntityType, unsupportedQuery)) .thenThrow(new UnknownIndexException("msg")) .thenReturn(entityStream); indexedRepositoryDecorator.findAll(unsupportedQuery); verify(searchService, times(2)).search(repositoryEntityType, unsupportedQuery); verify(delegateRepository).findAll(any(Stream.class), isNull()); }
@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);  }