@Test void unsupportedQueryWithNestedQueryRuleField() { String refAttrName = "refAttr"; String attrName = "attr"; String queryRuleField = refAttrName + '.' + attrName; Attribute refAttr = mock(Attribute.class); EntityType refEntityType = mock(EntityType.class); Attribute attr = mock(Attribute.class); when(refEntityType.getAttribute(attrName)).thenReturn(attr); when(refAttr.getRefEntity()).thenReturn(refEntityType); when(repositoryEntityType.getAttribute(refAttrName)).thenReturn(refAttr); @SuppressWarnings("unchecked") Query<Entity> q = mock(Query.class); QueryRule queryRule = mock(QueryRule.class); when(queryRule.getField()).thenReturn(queryRuleField); when(q.getRules()).thenReturn(singletonList(queryRule)); indexedRepositoryDecorator.count(q); verify(searchService).count(repositoryEntityType, q); verify(delegateRepository, never()).count(q); }
@Override public long count(Query<Entity> q) { if (querySupported(q)) { LOG.debug( "public long count({}) entityTypeId: [{}] repository: [{}]", q, getEntityType().getId(), DECORATED_REPOSITORY); return delegate().count(q); } else { LOG.debug( "public long count({}) entityTypeId: [{}] repository: [{}]", q, getEntityType().getId(), INDEX_REPOSITORY); return tryTwice(() -> searchService.count(getEntityType(), q)); } }
IndexedRepositoryDecorator extends AbstractRepositoryDecorator<Entity> { @Override public long count(Query<Entity> q) { if (querySupported(q)) { LOG.debug( "public long count({}) entityTypeId: [{}] repository: [{}]", q, getEntityType().getId(), DECORATED_REPOSITORY); return delegate().count(q); } else { LOG.debug( "public long count({}) entityTypeId: [{}] repository: [{}]", q, getEntityType().getId(), INDEX_REPOSITORY); return tryTwice(() -> searchService.count(getEntityType(), q)); } } }
IndexedRepositoryDecorator extends AbstractRepositoryDecorator<Entity> { @Override public long count(Query<Entity> q) { if (querySupported(q)) { LOG.debug( "public long count({}) entityTypeId: [{}] repository: [{}]", q, getEntityType().getId(), DECORATED_REPOSITORY); return delegate().count(q); } else { LOG.debug( "public long count({}) entityTypeId: [{}] repository: [{}]", q, getEntityType().getId(), INDEX_REPOSITORY); return tryTwice(() -> searchService.count(getEntityType(), q)); } } IndexedRepositoryDecorator(
      Repository<Entity> delegateRepository,
      SearchService searchService,
      IndexJobScheduler indexJobScheduler); }
IndexedRepositoryDecorator extends AbstractRepositoryDecorator<Entity> { @Override public long count(Query<Entity> q) { if (querySupported(q)) { LOG.debug( "public long count({}) entityTypeId: [{}] repository: [{}]", q, getEntityType().getId(), DECORATED_REPOSITORY); return delegate().count(q); } else { LOG.debug( "public long count({}) entityTypeId: [{}] repository: [{}]", q, getEntityType().getId(), INDEX_REPOSITORY); return tryTwice(() -> searchService.count(getEntityType(), q)); } } 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 long count(Query<Entity> q) { if (querySupported(q)) { LOG.debug( "public long count({}) entityTypeId: [{}] repository: [{}]", q, getEntityType().getId(), DECORATED_REPOSITORY); return delegate().count(q); } else { LOG.debug( "public long count({}) entityTypeId: [{}] repository: [{}]", q, getEntityType().getId(), INDEX_REPOSITORY); return tryTwice(() -> searchService.count(getEntityType(), q)); } } 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);  }