use of org.molgenis.data.support.QueryImpl in project molgenis by molgenis.
the class QueryGeneratorTest method generateOneQueryRuleNotEqualsHtmlNull.
@Test
public void generateOneQueryRuleNotEqualsHtmlNull() {
String value = null;
Query<Entity> q = new QueryImpl<>().not().eq(htmlAttrName, value);
QueryBuilder query = queryGenerator.createQueryBuilder(q, entityType);
QueryBuilder expectedQuery = boolQuery().mustNot(constantScoreQuery(boolQuery().mustNot(existsQuery(htmlAttrName))));
assertQueryBuilderEquals(query, expectedQuery);
}
use of org.molgenis.data.support.QueryImpl in project molgenis by molgenis.
the class QueryGeneratorTest method generateOneQueryRuleNotEqualsScriptNull.
// TODO enable when implemented in QueryGenerator (see note in QueryGenerator)
// @Test
// public void generateOneQueryRuleNotEqualsMrefNull()
// {
// }
@Test
public void generateOneQueryRuleNotEqualsScriptNull() {
String value = null;
Query<Entity> q = new QueryImpl<>().not().eq(scriptAttrName, value);
QueryBuilder query = queryGenerator.createQueryBuilder(q, entityType);
QueryBuilder expectedQuery = boolQuery().mustNot(constantScoreQuery(boolQuery().mustNot(existsQuery(scriptAttrName))));
assertQueryBuilderEquals(query, expectedQuery);
}
use of org.molgenis.data.support.QueryImpl in project molgenis by molgenis.
the class QueryGeneratorReferencesTest method generateOneQueryRuleNotEqualsCompoundPartString.
@Test
public void generateOneQueryRuleNotEqualsCompoundPartString() {
String value = "value";
Query<Entity> q = new QueryImpl<>().not().eq(PREFIX + refCompoundPart0AttributeName, value);
QueryBuilder query = queryGenerator.createQueryBuilder(q, entityType);
QueryBuilder expectedQuery = boolQuery().mustNot(constantScoreQuery(nestedQuery(REF_ENTITY_ATT, termQuery(PREFIX + refCompoundPart0AttributeName + '.' + FIELD_NOT_ANALYZED, value), ScoreMode.Avg)));
assertQueryBuilderEquals(query, expectedQuery);
}
use of org.molgenis.data.support.QueryImpl in project molgenis by molgenis.
the class L3CacheRepositoryDecoratorTest method beforeMethod.
@BeforeMethod
public void beforeMethod() {
entityType = entityTypeFactory.create(repositoryName);
entityType.addAttribute(attributeFactory.create().setDataType(INT).setName(ID), ROLE_ID);
entityType.addAttribute(attributeFactory.create().setName(COUNTRY));
when(entityManager.create(entityType, NO_POPULATE)).thenReturn(new DynamicEntity(entityType));
entity1 = entityManager.create(entityType, NO_POPULATE);
entity1.set(ID, 1);
entity1.set(COUNTRY, "NL");
entity2 = entityManager.create(entityType, NO_POPULATE);
entity2.set(ID, 2);
entity2.set(COUNTRY, "NL");
entity3 = entityManager.create(entityType, NO_POPULATE);
entity3.set(ID, 3);
entity3.set(COUNTRY, "GB");
when(delegateRepository.getCapabilities()).thenReturn(Sets.newHashSet(CACHEABLE));
l3CacheRepositoryDecorator = new L3CacheRepositoryDecorator(delegateRepository, l3Cache, transactionInformation);
verify(delegateRepository).getCapabilities();
query = new QueryImpl<>().eq(COUNTRY, "GB");
query.pageSize(10);
query.sort(new Sort().on(COUNTRY));
query.setFetch(fetch);
when(delegateRepository.getEntityType()).thenReturn(entityType);
when(delegateRepository.getName()).thenReturn(repositoryName);
}
use of org.molgenis.data.support.QueryImpl in project molgenis by molgenis.
the class OneClickImporterNamingServiceTest method testGetLabelWithPostFixWhenNoDuplicate.
@Test
public void testGetLabelWithPostFixWhenNoDuplicate() {
String label = "label";
when(dataService.findAll(ENTITY_TYPE_META_DATA, new QueryImpl<EntityType>().like(LABEL, label), EntityType.class)).thenReturn(Stream.empty());
oneClickImporterNamingService = new OneClickImporterNamingServiceImpl(dataService);
String actual = oneClickImporterNamingService.getLabelWithPostFix(label);
String expected = "label";
assertEquals(actual, expected);
}
Aggregations