Search in sources :

Example 16 with Nameable

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

the class AbstractQueryTest method script18.

@Test
public void script18() throws EntityFinderException {
    QueryBuilder<Nameable> qb = this.module.newQueryBuilder(Nameable.class);
    // should return all Nameable entities sorted by name
    Nameable nameable = templateFor(Nameable.class);
    Query<Nameable> query = unitOfWork.newQuery(qb);
    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");
}
Also used : Nameable(org.qi4j.test.indexing.model.Nameable) Test(org.junit.Test)

Example 17 with Nameable

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

the class AbstractQueryTest method script24.

@Test
public void script24() throws EntityFinderException {
    final QueryBuilder<Domain> qb = this.module.newQueryBuilder(Domain.class);
    final Nameable nameable = templateFor(Nameable.class);
    final Query<Domain> query = unitOfWork.newQuery(qb.where(eq(nameable.name(), "Gaming")));
    System.out.println("*** script24: " + query);
    assertThat(query.find().name().get(), is(equalTo("Gaming")));
}
Also used : Nameable(org.qi4j.test.indexing.model.Nameable) Domain(org.qi4j.test.indexing.model.Domain) Test(org.junit.Test)

Example 18 with Nameable

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

the class AbstractQueryTest method script02.

@Test
public void script02() throws EntityFinderException {
    final QueryBuilder<Domain> qb = this.module.newQueryBuilder(Domain.class);
    final Nameable nameable = templateFor(Nameable.class);
    final Query<Domain> query = unitOfWork.newQuery(qb.where(eq(nameable.name(), "Gaming")));
    System.out.println("*** script02: " + query);
    verifyUnorderedResults(query, "Gaming");
}
Also used : Nameable(org.qi4j.test.indexing.model.Nameable) Domain(org.qi4j.test.indexing.model.Domain) Test(org.junit.Test)

Example 19 with Nameable

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

the class AbstractQueryTest method script17.

@Test
public void script17() throws EntityFinderException {
    QueryBuilder<Nameable> qb = this.module.newQueryBuilder(Nameable.class);
    // should return only 3 entities starting with forth one
    Nameable nameable = templateFor(Nameable.class);
    Query<Nameable> query = unitOfWork.newQuery(qb);
    query.orderBy(orderBy(nameable.name()));
    query.firstResult(3);
    query.maxResults(2);
    System.out.println("*** script17: " + query);
    verifyOrderedResults(query, "Gaming", "Jack 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