Search in sources :

Example 36 with EntityReference

use of org.qi4j.api.entity.EntityReference in project qi4j-sdk by Qi4j.

the class AbstractEntityFinderTest method script13.

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

Example 37 with EntityReference

use of org.qi4j.api.entity.EntityReference 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 38 with EntityReference

use of org.qi4j.api.entity.EntityReference 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)

Example 39 with EntityReference

use of org.qi4j.api.entity.EntityReference in project qi4j-sdk by Qi4j.

the class AbstractEntityFinderTest method script07.

@Test
@SuppressWarnings("unchecked")
public void script07() throws EntityFinderException {
    Person person = templateFor(Person.class);
    // should return Jack Doe
    Iterable<EntityReference> entities = entityFinder.findEntities(Nameable.class, and(ge(person.yearOfBirth(), 1900), eq(person.placeOfBirth().get().name(), "Penang")), NO_SORTING, NO_FIRST_RESULT, NO_MAX_RESULTS, NO_VARIABLES);
    assertNames(entities, JACK);
}
Also used : EntityReference(org.qi4j.api.entity.EntityReference) Person(org.qi4j.test.indexing.model.Person) Test(org.junit.Test)

Example 40 with EntityReference

use of org.qi4j.api.entity.EntityReference in project qi4j-sdk by Qi4j.

the class AbstractEntityFinderTest method script02.

@Test
public void script02() throws EntityFinderException {
    Nameable nameable = templateFor(Nameable.class);
    // should return Gaming domain
    Iterable<EntityReference> entities = entityFinder.findEntities(Domain.class, eq(nameable.name(), "Gaming"), NO_SORTING, NO_FIRST_RESULT, NO_MAX_RESULTS, NO_VARIABLES);
    assertNames(entities, "Gaming");
}
Also used : Nameable(org.qi4j.test.indexing.model.Nameable) EntityReference(org.qi4j.api.entity.EntityReference) Test(org.junit.Test)

Aggregations

EntityReference (org.qi4j.api.entity.EntityReference)60 Test (org.junit.Test)23 ArrayList (java.util.ArrayList)13 AssociationDescriptor (org.qi4j.api.association.AssociationDescriptor)12 EntityDescriptor (org.qi4j.api.entity.EntityDescriptor)11 PropertyDescriptor (org.qi4j.api.property.PropertyDescriptor)11 Person (org.qi4j.test.indexing.model.Person)11 HashMap (java.util.HashMap)9 Map (java.util.Map)9 QualifiedName (org.qi4j.api.common.QualifiedName)9 EntityNotFoundException (org.qi4j.spi.entitystore.EntityNotFoundException)9 EntityStoreException (org.qi4j.spi.entitystore.EntityStoreException)9 Writer (java.io.Writer)8 IOException (java.io.IOException)7 LinkedHashMap (java.util.LinkedHashMap)7 List (java.util.List)7 JSONException (org.json.JSONException)6 JSONObject (org.json.JSONObject)6 StringWriter (java.io.StringWriter)5 JSONArray (org.json.JSONArray)5