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);
}
Aggregations