use of org.qi4j.test.indexing.model.Nameable in project qi4j-sdk by Qi4j.
the class AbstractQueryTest method script19.
@Test
public void script19() throws EntityFinderException {
QueryBuilder<Nameable> qb = this.module.newQueryBuilder(Nameable.class);
// should return all Nameable entities with a name > "D" sorted by name
Nameable nameable = templateFor(Nameable.class);
Query<Nameable> query = unitOfWork.newQuery(qb.where(gt(nameable.name(), "D")));
query.orderBy(orderBy(nameable.name()));
System.out.println("*** script19: " + query);
verifyOrderedResults(query, "Gaming", "Jack Doe", "Joe Doe", "Kuala Lumpur", "Penang", "Programming");
}
use of org.qi4j.test.indexing.model.Nameable in project qi4j-sdk by Qi4j.
the class NameableAssert method verifyUnorderedResults.
public static void verifyUnorderedResults(final Iterable<? extends Nameable> results, final String... names) {
List<String> expected = new ArrayList<>(Arrays.asList(names));
List<String> unexpected = new ArrayList<>();
for (Nameable result : results) {
String name = result.name().get();
if (!expected.remove(name)) {
unexpected.add(name);
}
}
if (!unexpected.isEmpty() || !expected.isEmpty()) {
String message = "";
if (!unexpected.isEmpty()) {
message += unexpected + " returned but not expected\n";
}
if (!expected.isEmpty()) {
message += expected + " expected but not returned\n";
}
fail(message.substring(0, message.length() - 1));
}
}
use of org.qi4j.test.indexing.model.Nameable in project qi4j-sdk by Qi4j.
the class NameableAssert method verifyOrderedResults.
public static void verifyOrderedResults(final Iterable<? extends Nameable> results, final String... names) {
List<String> expected = new ArrayList<>(Arrays.asList(names));
List<String> actual = new ArrayList<>();
for (Nameable result : results) {
actual.add(result.name().get());
}
assertThat("Result is incorrect", actual, equalTo(expected));
}
use of org.qi4j.test.indexing.model.Nameable in project qi4j-sdk by Qi4j.
the class AbstractNamedQueryTest method script18.
@Test
public void script18() throws EntityFinderException {
Nameable nameable = templateFor(Nameable.class);
final Query<Nameable> query = unitOfWork.newQuery(this.module.newQueryBuilder(Nameable.class).where(queries.get("script18")));
query.orderBy(orderBy(nameable.name()));
System.out.println("*** script18: " + query);
verifyOrderedResults(query, "Ann Doe", "Cars", "Cooking", "Gaming", "Jack Doe", "Joe Doe", "Kuala Lumpur", "Penang", "Programming");
}
use of org.qi4j.test.indexing.model.Nameable in project qi4j-sdk by Qi4j.
the class AbstractNamedQueryTest method script19.
@Test
public void script19() throws EntityFinderException {
Nameable nameable = templateFor(Nameable.class);
final Query<Nameable> query = unitOfWork.newQuery(this.module.newQueryBuilder(Nameable.class).where(queries.get("script19")));
query.orderBy(orderBy(nameable.name()));
System.out.println("*** script19: " + query);
verifyOrderedResults(query, "Gaming", "Jack Doe", "Joe Doe", "Kuala Lumpur", "Penang", "Programming");
}