use of org.qi4j.test.indexing.model.Nameable in project qi4j-sdk by Qi4j.
the class AbstractEntityFinderTest method script23.
@Test
public void script23() throws EntityFinderException {
Nameable nameable = templateFor(Nameable.class);
// Try using variables
Map<String, Object> variables = new HashMap<>(1);
variables.put("domain", "Gaming");
Iterable<EntityReference> entities = entityFinder.findEntities(Domain.class, eq(nameable.name(), variable("domain")), NO_SORTING, NO_FIRST_RESULT, NO_MAX_RESULTS, variables);
assertNames(entities, "Gaming");
}
use of org.qi4j.test.indexing.model.Nameable in project qi4j-sdk by Qi4j.
the class AbstractEntityFinderTest method script22.
@Test
public void script22() throws EntityFinderException {
Nameable nameable = templateFor(Nameable.class);
// should return Jack and Joe Doe
Iterable<EntityReference> entities = entityFinder.findEntities(Nameable.class, matches(nameable.name(), "J.*Doe"), NO_SORTING, NO_FIRST_RESULT, NO_MAX_RESULTS, NO_VARIABLES);
assertNames(entities, JACK, JOE);
}
use of org.qi4j.test.indexing.model.Nameable in project qi4j-sdk by Qi4j.
the class AbstractEntityFinderTest method script18.
@Test
public void script18() throws EntityFinderException {
// should return all Nameable entities sorted by name
Nameable nameable = templateFor(Nameable.class);
final String[] allNames = NameableAssert.allNames();
Arrays.sort(allNames);
Iterable<EntityReference> entities = entityFinder.findEntities(Nameable.class, ALL, new OrderBy[] { orderBy(nameable.name()) }, NO_FIRST_RESULT, NO_MAX_RESULTS, NO_VARIABLES);
assertNames(false, entities, allNames);
}
use of org.qi4j.test.indexing.model.Nameable in project qi4j-sdk by Qi4j.
the class AbstractEntityFinderTest method script19.
@Test
public void script19() throws EntityFinderException {
// should return all Nameable entities with a name > "B" sorted by name
Nameable nameable = templateFor(Nameable.class);
List<String> largerThanB = new ArrayList<>();
for (String name : NameableAssert.allNames()) {
if (name.compareTo("B") > 0) {
largerThanB.add(name);
}
}
Collections.sort(largerThanB);
Iterable<EntityReference> entities = entityFinder.findEntities(Nameable.class, gt(nameable.name(), "B"), new OrderBy[] { orderBy(nameable.name()) }, NO_FIRST_RESULT, NO_MAX_RESULTS, NO_VARIABLES);
assertNames(false, entities, largerThanB.toArray(new String[largerThanB.size()]));
}
use of org.qi4j.test.indexing.model.Nameable in project qi4j-sdk by Qi4j.
the class AbstractQueryTest method script16.
@Test
public void script16() throws EntityFinderException {
QueryBuilder<Nameable> qb = this.module.newQueryBuilder(Nameable.class);
// should return only 2 entities
Nameable nameable = templateFor(Nameable.class);
Query<Nameable> query = unitOfWork.newQuery(qb);
query.orderBy(orderBy(nameable.name()));
query.maxResults(2);
System.out.println("*** script16: " + query);
verifyOrderedResults(query, "Ann Doe", "Cars");
}