Search in sources :

Example 6 with Person

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

the class AbstractComplexQueryTest method script06.

@Test
public void script06() {
    ValueBuilder<URL> urlBuilder = this.module.newValueBuilder(URL.class);
    ValueBuilder<Protocol> protocolBuilder = this.module.newValueBuilder(Protocol.class);
    ValueBuilder<QueryParam> queryParamBuilder = this.module.newValueBuilder(QueryParam.class);
    Protocol protocol = protocolBuilder.prototype();
    protocol.value().set("http");
    List<QueryParam> queryParams = new ArrayList<>(2);
    QueryParam param = queryParamBuilder.prototype();
    param.name().set("user");
    param.value().set("jackdoe");
    queryParams.add(queryParamBuilder.newInstance());
    queryParamBuilder = this.module.newValueBuilder(QueryParam.class);
    param = queryParamBuilder.prototype();
    param.name().set("password");
    param.value().set("somepassword");
    queryParams.add(queryParamBuilder.newInstance());
    URL url = urlBuilder.prototype();
    url.protocol().set(protocolBuilder.newInstance());
    url.queryParams().set(queryParams);
    QueryBuilder<Person> qb = this.module.newQueryBuilder(Person.class);
    Property<URL> websiteProp = templateFor(Person.class).personalWebsite();
    qb = qb.where(eq(websiteProp, urlBuilder.newInstance()));
    Query<Person> query = unitOfWork.newQuery(qb);
    System.out.println("*** script06: " + query);
    verifyUnorderedResults(query, JACK);
}
Also used : QueryParam(org.qi4j.test.indexing.model.QueryParam) ArrayList(java.util.ArrayList) Protocol(org.qi4j.test.indexing.model.Protocol) Person(org.qi4j.test.indexing.model.Person) URL(org.qi4j.test.indexing.model.URL) Test(org.junit.Test)

Example 7 with Person

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

the class AbstractQueryTest method script31.

@Test
@Ignore("Equality on Property<Map<?,?>> not implemented")
public void script31() {
    QueryBuilder<Person> qb = this.module.newQueryBuilder(Person.class);
    Person person = templateFor(Person.class);
    Map<String, String> info = new HashMap<>(0);
    Query<Person> query = unitOfWork.newQuery(qb.where(eq(person.additionalInfo(), info)));
    System.out.println("*** script31: " + query);
    verifyUnorderedResults(query, "Jack Doe");
}
Also used : HashMap(java.util.HashMap) Person(org.qi4j.test.indexing.model.Person) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 8 with Person

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

the class AbstractQueryTest method script23.

@Test
public void script23() throws EntityFinderException {
    QueryBuilder<Person> qb = this.module.newQueryBuilder(Person.class);
    Person person = templateFor(Person.class);
    Domain interests = oneOf(person.interests());
    Query<Person> query = unitOfWork.newQuery(qb.where(eq(interests.name(), "Cars")));
    System.out.println("*** script23: " + query);
    verifyOrderedResults(query, "Jack Doe");
}
Also used : Domain(org.qi4j.test.indexing.model.Domain) Person(org.qi4j.test.indexing.model.Person) Test(org.junit.Test)

Example 9 with Person

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

the class AbstractQueryTest method script12.

@Test
public void script12() throws EntityFinderException {
    QueryBuilder<Person> qb = this.module.newQueryBuilder(Person.class);
    Person person = templateFor(Person.class);
    Query<Person> query = unitOfWork.newQuery(qb.where(isNull(person.email())));
    System.out.println("*** script12: " + query);
    verifyUnorderedResults(query, "Ann Doe", "Jack Doe");
}
Also used : Person(org.qi4j.test.indexing.model.Person) Test(org.junit.Test)

Example 10 with Person

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

the class AbstractNamedQueryTest method script21.

@Test
public void script21() throws EntityFinderException {
    Person person = templateFor(Person.class);
    final Query<Person> query = unitOfWork.newQuery(this.module.newQueryBuilder(Person.class).where(queries.get("script21")));
    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