Search in sources :

Example 46 with Person

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

the class AbstractComplexQueryTest method script10.

@Test
public void script10() {
    ValueBuilder<QueryParam> queryParamBuilder = this.module.newValueBuilder(QueryParam.class);
    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());
    QueryBuilder<Person> qb = this.module.newQueryBuilder(Person.class);
    Property<Collection<QueryParam>> paramsProp = templateFor(Person.class).personalWebsite().get().queryParams();
    qb = qb.where(containsAll(paramsProp, queryParams));
    Query<Person> query = unitOfWork.newQuery(qb);
    System.out.println("*** script10: " + query);
    verifyUnorderedResults(query, JACK);
}
Also used : QueryParam(org.qi4j.test.indexing.model.QueryParam) ArrayList(java.util.ArrayList) Collection(java.util.Collection) Person(org.qi4j.test.indexing.model.Person) Test(org.junit.Test)

Example 47 with Person

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

the class AbstractComplexQueryTest method script09.

@Test
public void script09() {
    ValueBuilder<QueryParam> queryParamBuilder = this.module.newValueBuilder(QueryParam.class);
    QueryParam param = queryParamBuilder.prototype();
    param.name().set("user");
    param.value().set("jackdoe");
    QueryBuilder<Person> qb = this.module.newQueryBuilder(Person.class);
    Property<Collection<QueryParam>> paramsProp = templateFor(Person.class).personalWebsite().get().queryParams();
    qb = qb.where(not(contains(paramsProp, queryParamBuilder.newInstance())));
    Query<Person> query = unitOfWork.newQuery(qb);
    System.out.println("*** script09: " + query);
    verifyUnorderedResults(query, ANN, JOE);
}
Also used : QueryParam(org.qi4j.test.indexing.model.QueryParam) Collection(java.util.Collection) Person(org.qi4j.test.indexing.model.Person) Test(org.junit.Test)

Example 48 with Person

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

the class AbstractComplexQueryTest method script07.

@Test
public void script07() {
    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(not(eq(websiteProp, urlBuilder.newInstance())));
    Query<Person> query = unitOfWork.newQuery(qb);
    System.out.println("*** script07: " + query);
    verifyUnorderedResults(query, ANN, JOE);
}
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 49 with Person

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

the class AbstractEntityFinderTest method script12.

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

Example 50 with Person

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

the class AbstractEntityFinderTest method script08.

@Test
@SuppressWarnings("unchecked")
public void script08() throws EntityFinderException {
    Person person = templateFor(Person.class);
    // should return Jack and Ann Doe
    Iterable<EntityReference> entities = entityFinder.findEntities(Person.class, or(eq(person.yearOfBirth(), 1970), eq(person.yearOfBirth(), 1975)), NO_SORTING, NO_FIRST_RESULT, NO_MAX_RESULTS, NO_VARIABLES);
    assertNames(entities, JACK, ANN);
}
Also used : EntityReference(org.qi4j.api.entity.EntityReference) 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