Search in sources :

Example 51 with Person

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

the class AbstractEntityFinderTest method script07.

@Test
@SuppressWarnings("unchecked")
public void script07() throws EntityFinderException {
    Person person = templateFor(Person.class);
    // should return Jack Doe
    Iterable<EntityReference> entities = entityFinder.findEntities(Nameable.class, and(ge(person.yearOfBirth(), 1900), eq(person.placeOfBirth().get().name(), "Penang")), NO_SORTING, NO_FIRST_RESULT, NO_MAX_RESULTS, NO_VARIABLES);
    assertNames(entities, JACK);
}
Also used : EntityReference(org.qi4j.api.entity.EntityReference) Person(org.qi4j.test.indexing.model.Person) Test(org.junit.Test)

Example 52 with Person

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

the class AbstractEntityFinderTest method script10.

@Test
public void script10() throws EntityFinderException {
    Person person = templateFor(Person.class);
    // should return Joe and Jack Doe
    Iterable<EntityReference> entities = entityFinder.findEntities(Person.class, not(eq(person.yearOfBirth(), 1975)), NO_SORTING, NO_FIRST_RESULT, NO_MAX_RESULTS, NO_VARIABLES);
    assertNames(entities, JOE, JACK);
}
Also used : EntityReference(org.qi4j.api.entity.EntityReference) Person(org.qi4j.test.indexing.model.Person) Test(org.junit.Test)

Example 53 with Person

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

the class AbstractEntityFinderTest method script20.

@Test
public void script20() throws EntityFinderException {
    // should return all Persons born after 1973 (Ann and Joe Doe) sorted descending by name
    Person person = templateFor(Person.class);
    Iterable<EntityReference> entities = entityFinder.findEntities(Person.class, gt(person.yearOfBirth(), 1973), new OrderBy[] { orderBy(person.name(), OrderBy.Order.DESCENDING) }, NO_FIRST_RESULT, NO_MAX_RESULTS, NO_VARIABLES);
    assertNames(false, entities, JOE, ANN);
}
Also used : EntityReference(org.qi4j.api.entity.EntityReference) Person(org.qi4j.test.indexing.model.Person) Test(org.junit.Test)

Example 54 with Person

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

the class AbstractEntityFinderTest method script21.

@Test
public void script21() throws EntityFinderException {
    // should return all Persons sorted name of the city they were born
    Person person = templateFor(Person.class);
    Iterable<EntityReference> entities = entityFinder.findEntities(Person.class, ALL, new OrderBy[] { orderBy(person.placeOfBirth().get().name()), orderBy(person.name()) }, NO_FIRST_RESULT, NO_MAX_RESULTS, NO_VARIABLES);
    assertNames(false, entities, ANN, JOE, JACK);
}
Also used : EntityReference(org.qi4j.api.entity.EntityReference) Person(org.qi4j.test.indexing.model.Person) Test(org.junit.Test)

Example 55 with Person

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

the class AbstractQueryTest method script21.

@Test
public void script21() throws EntityFinderException {
    QueryBuilder<Person> qb = this.module.newQueryBuilder(Person.class);
    // should return all Persons sorted by name of the city they were born, and then by year they were born
    Person person = templateFor(Person.class);
    Query<Person> query = unitOfWork.newQuery(qb);
    query.orderBy(orderBy(person.placeOfBirth().get().name()), orderBy(person.yearOfBirth()));
    System.out.println("*** script21: " + query);
    verifyOrderedResults(query, "Ann Doe", "Joe Doe", "Jack Doe");
}
Also used : Person(org.qi4j.test.indexing.model.Person) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)76 Person (org.qi4j.test.indexing.model.Person)76 LocalDateTime (org.joda.time.LocalDateTime)12 EntityReference (org.qi4j.api.entity.EntityReference)11 QueryParam (org.qi4j.test.indexing.model.QueryParam)10 DateTime (org.joda.time.DateTime)8 ArrayList (java.util.ArrayList)7 Collection (java.util.Collection)7 LocalDate (org.joda.time.LocalDate)4 BigDecimal (java.math.BigDecimal)3 BigInteger (java.math.BigInteger)3 Ignore (org.junit.Ignore)3 Address (org.qi4j.test.indexing.model.Address)2 City (org.qi4j.test.indexing.model.City)2 Domain (org.qi4j.test.indexing.model.Domain)2 Female (org.qi4j.test.indexing.model.Female)2 Male (org.qi4j.test.indexing.model.Male)2 Protocol (org.qi4j.test.indexing.model.Protocol)2 URL (org.qi4j.test.indexing.model.URL)2 HashMap (java.util.HashMap)1