Search in sources :

Example 16 with EntityReference

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

the class AbstractEntityFinderTest method script14.

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

Example 17 with EntityReference

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

the class AbstractEntityFinderTest method script11.

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

Example 18 with EntityReference

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

the class AbstractEntityFinderTest method script19.

@Test
public void script19() throws EntityFinderException {
    // should return all Nameable entities with a name > "B" sorted by name
    Nameable nameable = templateFor(Nameable.class);
    List<String> largerThanB = new ArrayList<>();
    for (String name : NameableAssert.allNames()) {
        if (name.compareTo("B") > 0) {
            largerThanB.add(name);
        }
    }
    Collections.sort(largerThanB);
    Iterable<EntityReference> entities = entityFinder.findEntities(Nameable.class, gt(nameable.name(), "B"), new OrderBy[] { orderBy(nameable.name()) }, NO_FIRST_RESULT, NO_MAX_RESULTS, NO_VARIABLES);
    assertNames(false, entities, largerThanB.toArray(new String[largerThanB.size()]));
}
Also used : Nameable(org.qi4j.test.indexing.model.Nameable) ArrayList(java.util.ArrayList) EntityReference(org.qi4j.api.entity.EntityReference) Test(org.junit.Test)

Example 19 with EntityReference

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

the class AbstractEntityFinderTest method script05.

@Test
public void script05() throws EntityFinderException {
    Person person = templateFor(Person.class);
    // should return Joe Doe
    Iterable<EntityReference> entities = entityFinder.findEntities(Person.class, eq(person.mother().get().placeOfBirth().get().name(), "Kuala Lumpur"), NO_SORTING, NO_FIRST_RESULT, NO_MAX_RESULTS, NO_VARIABLES);
    assertNames(entities, JOE);
}
Also used : EntityReference(org.qi4j.api.entity.EntityReference) Person(org.qi4j.test.indexing.model.Person) Test(org.junit.Test)

Example 20 with EntityReference

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

the class AbstractEntityFinderTest method script09.

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