Search in sources :

Example 1 with Person

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

the class AbstractComplexQueryTest method script03.

@Test
public void script03() {
    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(eq(paramsProp, queryParams));
    Query<Person> query = unitOfWork.newQuery(qb);
    System.out.println("*** script03: " + 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 2 with Person

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

the class AbstractComplexQueryTest method script05.

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

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

the class AbstractComplexQueryTest method script02.

@Test
public void script02() {
    ValueBuilder<Address> addressBuilder = this.module.newValueBuilder(Address.class);
    Address address = addressBuilder.prototype();
    address.line1().set("Qi Street 4j");
    address.line2().set("Off main Java Street");
    address.zipcode().set("12345");
    QueryBuilder<Person> qb = this.module.newQueryBuilder(Person.class);
    Property<Address> addressProp = templateFor(Person.class).address();
    qb = qb.where(not(eq(addressProp, addressBuilder.newInstance())));
    Query<Person> query = unitOfWork.newQuery(qb);
    System.out.println("*** script02: " + query);
    verifyUnorderedResults(query, JOE, JACK);
}
Also used : Address(org.qi4j.test.indexing.model.Address) Person(org.qi4j.test.indexing.model.Person) Test(org.junit.Test)

Example 4 with Person

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

the class AbstractComplexQueryTest method script08.

@Test
public void script08() {
    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(contains(paramsProp, queryParamBuilder.newInstance()));
    Query<Person> query = unitOfWork.newQuery(qb);
    System.out.println("*** script08: " + query);
    verifyUnorderedResults(query, JACK);
}
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 5 with Person

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

the class AbstractComplexQueryTest method script11.

@Test
public void script11() {
    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(not(containsAll(paramsProp, queryParams)));
    Query<Person> query = unitOfWork.newQuery(qb);
    System.out.println("*** script11: " + query);
    verifyUnorderedResults(query, ANN, JOE);
}
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)

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