@Test void findOneUnknownIndexExceptionRecoverable() { Entity entity0 = mock(Entity.class); when(searchService.searchOne(repositoryEntityType, unsupportedQuery)) .thenThrow(new UnknownIndexException("msg")) .thenReturn(entity0); indexedRepositoryDecorator.findOne(unsupportedQuery); verify(searchService, times(2)).searchOne(repositoryEntityType, unsupportedQuery); verify(delegateRepository).findOneById(any(Object.class), isNull()); }
@Override public Entity findOne(Query<Entity> q) { if (querySupported(q)) { LOG.debug( "public Entity findOne({}) entityTypeId: [{}] repository: [{}]", q, getEntityType().getId(), DECORATED_REPOSITORY); return delegate().findOne(q); } else { LOG.debug( "public Entity findOne({}) entityTypeId: [{}] repository: [{}]", q, getEntityType().getId(), INDEX_REPOSITORY); Object entityId = tryTwice(() -> searchService.searchOne(getEntityType(), q)); return entityId != null ? delegate().findOneById(entityId, q.getFetch()) : null; } }
IndexedRepositoryDecorator extends AbstractRepositoryDecorator<Entity> { @Override public Entity findOne(Query<Entity> q) { if (querySupported(q)) { LOG.debug( "public Entity findOne({}) entityTypeId: [{}] repository: [{}]", q, getEntityType().getId(), DECORATED_REPOSITORY); return delegate().findOne(q); } else { LOG.debug( "public Entity findOne({}) entityTypeId: [{}] repository: [{}]", q, getEntityType().getId(), INDEX_REPOSITORY); Object entityId = tryTwice(() -> searchService.searchOne(getEntityType(), q)); return entityId != null ? delegate().findOneById(entityId, q.getFetch()) : null; } } }
IndexedRepositoryDecorator extends AbstractRepositoryDecorator<Entity> { @Override public Entity findOne(Query<Entity> q) { if (querySupported(q)) { LOG.debug( "public Entity findOne({}) entityTypeId: [{}] repository: [{}]", q, getEntityType().getId(), DECORATED_REPOSITORY); return delegate().findOne(q); } else { LOG.debug( "public Entity findOne({}) entityTypeId: [{}] repository: [{}]", q, getEntityType().getId(), INDEX_REPOSITORY); Object entityId = tryTwice(() -> searchService.searchOne(getEntityType(), q)); return entityId != null ? delegate().findOneById(entityId, q.getFetch()) : null; } } IndexedRepositoryDecorator(
      Repository<Entity> delegateRepository,
      SearchService searchService,
      IndexJobScheduler indexJobScheduler); }
IndexedRepositoryDecorator extends AbstractRepositoryDecorator<Entity> { @Override public Entity findOne(Query<Entity> q) { if (querySupported(q)) { LOG.debug( "public Entity findOne({}) entityTypeId: [{}] repository: [{}]", q, getEntityType().getId(), DECORATED_REPOSITORY); return delegate().findOne(q); } else { LOG.debug( "public Entity findOne({}) entityTypeId: [{}] repository: [{}]", q, getEntityType().getId(), INDEX_REPOSITORY); Object entityId = tryTwice(() -> searchService.searchOne(getEntityType(), q)); return entityId != null ? delegate().findOneById(entityId, q.getFetch()) : null; } } 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 Entity findOne(Query<Entity> q) { if (querySupported(q)) { LOG.debug( "public Entity findOne({}) entityTypeId: [{}] repository: [{}]", q, getEntityType().getId(), DECORATED_REPOSITORY); return delegate().findOne(q); } else { LOG.debug( "public Entity findOne({}) entityTypeId: [{}] repository: [{}]", q, getEntityType().getId(), INDEX_REPOSITORY); Object entityId = tryTwice(() -> searchService.searchOne(getEntityType(), q)); return entityId != null ? delegate().findOneById(entityId, q.getFetch()) : null; } } 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);  }