Search in sources :

Example 11 with EntityReference

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

the class AbstractEntityFinderTest method script23.

@Test
public void script23() throws EntityFinderException {
    Nameable nameable = templateFor(Nameable.class);
    // Try using variables
    Map<String, Object> variables = new HashMap<>(1);
    variables.put("domain", "Gaming");
    Iterable<EntityReference> entities = entityFinder.findEntities(Domain.class, eq(nameable.name(), variable("domain")), NO_SORTING, NO_FIRST_RESULT, NO_MAX_RESULTS, variables);
    assertNames(entities, "Gaming");
}
Also used : Nameable(org.qi4j.test.indexing.model.Nameable) HashMap(java.util.HashMap) EntityReference(org.qi4j.api.entity.EntityReference) Test(org.junit.Test)

Example 12 with EntityReference

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

the class AbstractEntityFinderTest method script22.

@Test
public void script22() throws EntityFinderException {
    Nameable nameable = templateFor(Nameable.class);
    // should return Jack and Joe Doe
    Iterable<EntityReference> entities = entityFinder.findEntities(Nameable.class, matches(nameable.name(), "J.*Doe"), NO_SORTING, NO_FIRST_RESULT, NO_MAX_RESULTS, NO_VARIABLES);
    assertNames(entities, JACK, JOE);
}
Also used : Nameable(org.qi4j.test.indexing.model.Nameable) EntityReference(org.qi4j.api.entity.EntityReference) Test(org.junit.Test)

Example 13 with EntityReference

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

the class AbstractEntityFinderTest method script06.

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

Example 14 with EntityReference

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

the class AbstractEntityFinderTest method script18.

@Test
public void script18() throws EntityFinderException {
    // should return all Nameable entities sorted by name
    Nameable nameable = templateFor(Nameable.class);
    final String[] allNames = NameableAssert.allNames();
    Arrays.sort(allNames);
    Iterable<EntityReference> entities = entityFinder.findEntities(Nameable.class, ALL, new OrderBy[] { orderBy(nameable.name()) }, NO_FIRST_RESULT, NO_MAX_RESULTS, NO_VARIABLES);
    assertNames(false, entities, allNames);
}
Also used : Nameable(org.qi4j.test.indexing.model.Nameable) EntityReference(org.qi4j.api.entity.EntityReference) Test(org.junit.Test)

Example 15 with EntityReference

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

the class AbstractEntityFinderTest method script04.

@Test
public void script04() throws EntityFinderException {
    Person person = templateFor(Person.class);
    // should return Joe and Ann Doe
    Iterable<EntityReference> entities = entityFinder.findEntities(Person.class, eq(person.placeOfBirth().get().name(), "Kuala Lumpur"), NO_SORTING, NO_FIRST_RESULT, NO_MAX_RESULTS, NO_VARIABLES);
    assertNames(entities, JOE, 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