Search in sources :

Example 1 with IndexJobScheduler

use of org.molgenis.data.index.job.IndexJobScheduler in project molgenis by molgenis.

the class IndexedRepositoryDecoratorTest method setUp.

@SuppressWarnings("unchecked")
@BeforeMethod
public void setUp() throws IOException {
    searchService = mock(SearchService.class);
    delegateRepository = mock(Repository.class);
    String entityTypeId = "entity";
    repositoryEntityType = mock(EntityType.class);
    when(repositoryEntityType.getId()).thenReturn(entityTypeId);
    when(repositoryEntityType.getLabel()).thenReturn("My entity type");
    idAttrName = "id";
    Attribute idAttr = when(mock(Attribute.class).getName()).thenReturn(idAttrName).getMock();
    when(idAttr.getExpression()).thenReturn(null);
    when(repositoryEntityType.getIdAttribute()).thenReturn(idAttr);
    when(delegateRepository.getEntityType()).thenReturn(repositoryEntityType);
    when(delegateRepository.getName()).thenReturn("entity");
    when(delegateRepository.getCapabilities()).thenReturn(EnumSet.of(QUERYABLE, MANAGABLE, VALIDATE_NOTNULL_CONSTRAINT));
    when(delegateRepository.getQueryOperators()).thenReturn(EnumSet.of(IN, LESS, EQUALS, AND, OR));
    IndexJobScheduler indexJobScheduler = mock(IndexJobScheduler.class);
    indexedRepositoryDecorator = new IndexedRepositoryDecorator(delegateRepository, searchService, indexJobScheduler);
    when(repositoryEntityType.getAtomicAttributes()).thenReturn(newArrayList(idAttr));
    query = mock(Query.class);
    QueryRule rule1 = mock(QueryRule.class);
    QueryRule rule2 = mock(QueryRule.class);
    when(rule1.getOperator()).thenReturn(IN);
    when(rule2.getOperator()).thenReturn(EQUALS);
    List<QueryRule> queryRules = newArrayList(rule1, rule2);
    when(query.getRules()).thenReturn(queryRules);
    unsupportedQuery = mock(Query.class);
    QueryRule unsupportedRule = mock(QueryRule.class);
    when(unsupportedRule.getOperator()).thenReturn(FUZZY_MATCH);
    List<QueryRule> unsupportedQueryRules = newArrayList(rule1, rule2, unsupportedRule);
    when(unsupportedQuery.getRules()).thenReturn(unsupportedQueryRules);
}
Also used : EntityType(org.molgenis.data.meta.model.EntityType) AggregateQuery(org.molgenis.data.aggregation.AggregateQuery) Attribute(org.molgenis.data.meta.model.Attribute) IndexJobScheduler(org.molgenis.data.index.job.IndexJobScheduler) BeforeMethod(org.testng.annotations.BeforeMethod)

Aggregations

AggregateQuery (org.molgenis.data.aggregation.AggregateQuery)1 IndexJobScheduler (org.molgenis.data.index.job.IndexJobScheduler)1 Attribute (org.molgenis.data.meta.model.Attribute)1 EntityType (org.molgenis.data.meta.model.EntityType)1 BeforeMethod (org.testng.annotations.BeforeMethod)1