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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations