use of org.apache.stanbol.entityhub.servicesapi.query.FieldQuery in project stanbol by apache.
the class YardTest method testFindRepresentationText.
/**
* Same as {@link #testFindText()} but using
* {@link Yard#findRepresentation(FieldQuery)} to execute the queries
*/
@Test
public void testFindRepresentationText() {
//init the test data
FieldQueryTestData data = getFieldQueryTestData();
//query for all languages and value1
FieldQuery query = getYard().getQueryFactory().createFieldQuery();
query.setConstraint(data.textField, new TextConstraint(data.textValue1.getText()));
validateQueryResults(query, getYard().findRepresentation(query), Arrays.asList(data.r1.getId(), data.r1en.getId(), data.r1de.getId()), Arrays.asList(data.textField, data.refField, data.intField));
//same for value2
query = getYard().getQueryFactory().createFieldQuery();
query.setConstraint(data.textField, new TextConstraint(data.textValue2.getText()));
validateQueryResults(query, getYard().findRepresentation(query), Arrays.asList(data.r2.getId(), data.r2en.getId(), data.r2de.getId()), Arrays.asList(data.textField, data.refField, data.intField));
}
use of org.apache.stanbol.entityhub.servicesapi.query.FieldQuery in project stanbol by apache.
the class YardTest method testQeuryFactory.
/*
* All the follow up tests where added as part of STANBOL-1202
*/
/**
* Simple test for the QueryFactory
*/
@Test
public void testQeuryFactory() {
FieldQueryFactory qf = getYard().getQueryFactory();
Assert.assertNotNull("The getter for the FieldQueryFactory MUST NOT return NULL!", qf);
FieldQuery query = qf.createFieldQuery();
Assert.assertNotNull("The FieldQueryFactory returned NULL as query", query);
}
use of org.apache.stanbol.entityhub.servicesapi.query.FieldQuery in project stanbol by apache.
the class YardTest method testFindTextOfLanguage.
/**
* Test a simple {@link TextConstraint} for any language
*/
@Test
public void testFindTextOfLanguage() {
//init the test data
FieldQueryTestData data = getFieldQueryTestData();
//value1@en
FieldQuery query = getYard().getQueryFactory().createFieldQuery();
query.setConstraint(data.textField, new TextConstraint(data.textValue1.getText(), "en"));
query.addSelectedField(data.textField);
query.addSelectedField(data.refField);
validateQueryResults(query, getYard().find(query), Arrays.asList(data.r1en.getId()), Arrays.asList(data.textField, data.refField));
//value2@de
query = getYard().getQueryFactory().createFieldQuery();
query.setConstraint(data.textField, new TextConstraint(data.textValue2.getText(), "de"));
query.addSelectedField(data.textField);
query.addSelectedField(data.refField);
validateQueryResults(query, getYard().find(query), Arrays.asList(data.r2de.getId()), Arrays.asList(data.textField, data.refField));
//value1@null
query = getYard().getQueryFactory().createFieldQuery();
query.setConstraint(data.textField, new TextConstraint(data.textValue1.getText(), (String) null));
query.addSelectedField(data.textField);
query.addSelectedField(data.refField);
validateQueryResults(query, getYard().find(query), Arrays.asList(data.r1.getId()), Arrays.asList(data.textField, data.refField));
//value1@null,en
query = getYard().getQueryFactory().createFieldQuery();
query.setConstraint(data.textField, new TextConstraint(data.textValue1.getText(), null, "en"));
query.addSelectedField(data.textField);
query.addSelectedField(data.refField);
validateQueryResults(query, getYard().find(query), Arrays.asList(data.r1.getId(), data.r1en.getId()), Arrays.asList(data.textField, data.refField));
//value1@en,de
query = getYard().getQueryFactory().createFieldQuery();
query.setConstraint(data.textField, new TextConstraint(data.textValue1.getText(), "en", "de"));
query.addSelectedField(data.textField);
query.addSelectedField(data.refField);
validateQueryResults(query, getYard().find(query), Arrays.asList(data.r1en.getId(), data.r1de.getId()), Arrays.asList(data.textField, data.refField));
}
use of org.apache.stanbol.entityhub.servicesapi.query.FieldQuery in project stanbol by apache.
the class YardTest method testFindValues.
/**
* Tests simple {@link ValueConstraint}s
*/
@Test
public void testFindValues() {
//init the test data
FieldQueryTestData data = getFieldQueryTestData();
//query for all languages and value1
FieldQuery query = getYard().getQueryFactory().createFieldQuery();
query.setConstraint(data.intField, new ValueConstraint(data.intValue1));
query.addSelectedField(data.intField);
query.addSelectedField(data.textField);
validateQueryResults(query, getYard().find(query), Arrays.asList(data.r1.getId(), data.r1en.getId(), data.r1de.getId()), Arrays.asList(data.intField, data.textField));
//same for value2
query = getYard().getQueryFactory().createFieldQuery();
query.setConstraint(data.intField, new ValueConstraint(data.intValue2));
query.addSelectedField(data.intField);
query.addSelectedField(data.textField);
validateQueryResults(query, getYard().find(query), Arrays.asList(data.r2.getId(), data.r2en.getId(), data.r2de.getId()), Arrays.asList(data.intField, data.textField));
}
use of org.apache.stanbol.entityhub.servicesapi.query.FieldQuery in project stanbol by apache.
the class YardTest method testFindText.
/**
* Test a simple {@link TextConstraint} for any language
*/
@Test
public void testFindText() {
//init the test data
FieldQueryTestData data = getFieldQueryTestData();
//query for all languages and value1
FieldQuery query = getYard().getQueryFactory().createFieldQuery();
query.setConstraint(data.textField, new TextConstraint(data.textValue1.getText()));
query.addSelectedField(data.textField);
query.addSelectedField(data.refField);
validateQueryResults(query, getYard().find(query), Arrays.asList(data.r1.getId(), data.r1en.getId(), data.r1de.getId()), Arrays.asList(data.textField, data.refField));
//same for value2
query = getYard().getQueryFactory().createFieldQuery();
query.setConstraint(data.textField, new TextConstraint(data.textValue2.getText()));
query.addSelectedField(data.textField);
query.addSelectedField(data.refField);
validateQueryResults(query, getYard().find(query), Arrays.asList(data.r2.getId(), data.r2en.getId(), data.r2de.getId()), Arrays.asList(data.textField, data.refField));
}
Aggregations