@Test void findOneUnknownIndexExceptionUnrecoverable() { when(searchService.searchOne(repositoryEntityType, unsupportedQuery)) .thenThrow(new UnknownIndexException("msg")); Exception exception = assertThrows( MolgenisDataException.class, () -> indexedRepositoryDecorator.findOne(unsupportedQuery)); assertThat(exception.getMessage()) .containsPattern( "Error executing query, index for entity type 'My entity type' with id 'entity' does not exist"); }
@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);  }