Search in sources :

Example 11 with Nameable

use of org.qi4j.test.indexing.model.Nameable in project qi4j-sdk by Qi4j.

the class AbstractQueryTest method script07.

@Test
@SuppressWarnings("unchecked")
public void script07() throws EntityFinderException {
    QueryBuilder<Nameable> qb = this.module.newQueryBuilder(Nameable.class);
    Person person = templateFor(Person.class);
    Query<Nameable> query = unitOfWork.newQuery(qb.where(and(ge(person.yearOfBirth(), 1900), eq(person.placeOfBirth().get().name(), "Penang"))));
    System.out.println("*** script07: " + query);
    verifyUnorderedResults(query, "Jack Doe");
}
Also used : Nameable(org.qi4j.test.indexing.model.Nameable) Person(org.qi4j.test.indexing.model.Person) Test(org.junit.Test)

Example 12 with Nameable

use of org.qi4j.test.indexing.model.Nameable in project qi4j-sdk by Qi4j.

the class AbstractEntityFinderTest method script02.

@Test
public void script02() throws EntityFinderException {
    Nameable nameable = templateFor(Nameable.class);
    // should return Gaming domain
    Iterable<EntityReference> entities = entityFinder.findEntities(Domain.class, eq(nameable.name(), "Gaming"), NO_SORTING, NO_FIRST_RESULT, NO_MAX_RESULTS, NO_VARIABLES);
    assertNames(entities, "Gaming");
}
Also used : Nameable(org.qi4j.test.indexing.model.Nameable) EntityReference(org.qi4j.api.entity.EntityReference) Test(org.junit.Test)

Example 13 with Nameable

use of org.qi4j.test.indexing.model.Nameable in project qi4j-sdk by Qi4j.

the class AbstractNamedQueryTest method script16.

@Test
public void script16() throws EntityFinderException {
    Nameable nameable = templateFor(Nameable.class);
    final Query<Nameable> query = unitOfWork.newQuery(this.module.newQueryBuilder(Nameable.class).where(queries.get("script16")));
    query.orderBy(orderBy(nameable.name()));
    query.maxResults(2);
    System.out.println("*** script16: " + query);
    verifyOrderedResults(query, "Ann Doe", "Cars");
}
Also used : Nameable(org.qi4j.test.indexing.model.Nameable) Test(org.junit.Test)

Example 14 with Nameable

use of org.qi4j.test.indexing.model.Nameable in project qi4j-sdk by Qi4j.

the class AbstractQueryTest method script22.

@Test
public void script22() throws EntityFinderException {
    QueryBuilder<Nameable> qb = this.module.newQueryBuilder(Nameable.class);
    Nameable nameable = templateFor(Nameable.class);
    // should return Jack and Joe Doe
    Query<Nameable> query = unitOfWork.newQuery(qb.where(matches(nameable.name(), "J.*Doe")));
    System.out.println("*** script22: " + query);
    verifyUnorderedResults(query, "Jack Doe", "Joe Doe");
}
Also used : Nameable(org.qi4j.test.indexing.model.Nameable) Test(org.junit.Test)

Example 15 with Nameable

use of org.qi4j.test.indexing.model.Nameable in project qi4j-sdk by Qi4j.

the class AbstractNamedQueryTest method script17.

@Test
public void script17() throws EntityFinderException {
    Nameable nameable = templateFor(Nameable.class);
    final Query<Nameable> query = unitOfWork.newQuery(this.module.newQueryBuilder(Nameable.class).where(queries.get("script17")));
    query.orderBy(orderBy(nameable.name()));
    query.firstResult(3);
    query.maxResults(3);
    System.out.println("*** script17: " + query);
    verifyOrderedResults(query, "Gaming", "Jack Doe", "Joe Doe");
}
Also used : Nameable(org.qi4j.test.indexing.model.Nameable) Test(org.junit.Test)

Aggregations

Nameable (org.qi4j.test.indexing.model.Nameable)19 Test (org.junit.Test)17 EntityReference (org.qi4j.api.entity.EntityReference)5 ArrayList (java.util.ArrayList)3 Domain (org.qi4j.test.indexing.model.Domain)2 HashMap (java.util.HashMap)1 Person (org.qi4j.test.indexing.model.Person)1