Search in sources :

Example 1 with QueryParam

use of org.qi4j.test.indexing.model.QueryParam 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 2 with QueryParam

use of org.qi4j.test.indexing.model.QueryParam 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<QueryParam>();
    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 3 with QueryParam

use of org.qi4j.test.indexing.model.QueryParam 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<QueryParam>();
    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)

Example 4 with QueryParam

use of org.qi4j.test.indexing.model.QueryParam 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<QueryParam>();
    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 5 with QueryParam

use of org.qi4j.test.indexing.model.QueryParam 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<QueryParam>();
    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)

Aggregations

QueryParam (org.qi4j.test.indexing.model.QueryParam)11 Test (org.junit.Test)10 Person (org.qi4j.test.indexing.model.Person)10 ArrayList (java.util.ArrayList)8 Collection (java.util.Collection)7 Protocol (org.qi4j.test.indexing.model.Protocol)3 URL (org.qi4j.test.indexing.model.URL)3 List (java.util.List)1 Ignore (org.junit.Ignore)1 EntityBuilder (org.qi4j.api.entity.EntityBuilder)1 UnitOfWork (org.qi4j.api.unitofwork.UnitOfWork)1 ValueBuilder (org.qi4j.api.value.ValueBuilder)1 ValueBuilderFactory (org.qi4j.api.value.ValueBuilderFactory)1 Account (org.qi4j.test.indexing.model.Account)1 Address (org.qi4j.test.indexing.model.Address)1 Cat (org.qi4j.test.indexing.model.Cat)1 City (org.qi4j.test.indexing.model.City)1 Domain (org.qi4j.test.indexing.model.Domain)1 Female (org.qi4j.test.indexing.model.Female)1 Male (org.qi4j.test.indexing.model.Male)1