Search in sources :

Example 31 with PersonLongAutoID

use of siena.base.test.model.PersonLongAutoID in project siena by mandubian.

the class BaseTest method testGetByKeyNonExisting.

public void testGetByKeyNonExisting() {
    PersonLongAutoID pers = getByKeyPersonLongAutoID(12345678L);
    assertNull(pers);
}
Also used : PersonLongAutoID(siena.base.test.model.PersonLongAutoID)

Example 32 with PersonLongAutoID

use of siena.base.test.model.PersonLongAutoID in project siena by mandubian.

the class BaseTest method testDumpRestoreQueryFilterSimple.

public void testDumpRestoreQueryFilterSimple() {
    Query<PersonLongAutoID> query = pm.createQuery(PersonLongAutoID.class).filter("firstName", "abcde");
    QueryFilterSimple qf = (QueryFilterSimple) query.getFilters().get(0);
    String str = JsonSerializer.serialize(qf).toString();
    assertNotNull(str);
    QueryFilterSimple qfRes = (QueryFilterSimple) JsonSerializer.deserialize(QueryFilter.class, Json.loads(str));
    assertNotNull(qfRes);
    assertEquals(qf.operator, qfRes.operator);
    assertEquals(qf.value, qfRes.value);
    assertEquals(qf.field.getName(), qfRes.field.getName());
}
Also used : QueryFilter(siena.QueryFilter) QueryFilterSimple(siena.QueryFilterSimple) PersonLongAutoID(siena.base.test.model.PersonLongAutoID)

Example 33 with PersonLongAutoID

use of siena.base.test.model.PersonLongAutoID in project siena by mandubian.

the class BaseTest method testDumpRestoreQueryOrder.

public void testDumpRestoreQueryOrder() {
    Query<PersonLongAutoID> query = pm.createQuery(PersonLongAutoID.class).order("firstName");
    QueryOrder qo = (QueryOrder) query.getOrders().get(0);
    String str = JsonSerializer.serialize(qo).toString();
    assertNotNull(str);
    QueryOrder qoRes = (QueryOrder) JsonSerializer.deserialize(QueryOrder.class, Json.loads(str));
    assertNotNull(qoRes);
    assertEquals(qo.ascending, qoRes.ascending);
    assertEquals(qo.field.getName(), qoRes.field.getName());
}
Also used : PersonLongAutoID(siena.base.test.model.PersonLongAutoID) QueryOrder(siena.QueryOrder)

Example 34 with PersonLongAutoID

use of siena.base.test.model.PersonLongAutoID in project siena by mandubian.

the class BaseTestNoAutoInc_3_ITER method testIterLimitOffsetLongAutoID.

public void testIterLimitOffsetLongAutoID() {
    if (supportsAutoincrement()) {
        Iterable<PersonLongAutoID> people = pm.createQuery(PersonLongAutoID.class).order("n").iter(2, 1);
        assertNotNull(people);
        PersonLongAutoID[] array = new PersonLongAutoID[] { LongAutoID_CURIE, LongAutoID_EINSTEIN };
        int i = 0;
        for (PersonLongAutoID person : people) {
            assertEquals(array[i], person);
            i++;
        }
    } else {
        try {
            Iterable<PersonLongAutoID> people = pm.createQuery(PersonLongAutoID.class).order("n").iter(2, 1);
        } catch (SienaRestrictedApiException ex) {
            return;
        }
        fail();
    }
}
Also used : SienaRestrictedApiException(siena.SienaRestrictedApiException) PersonLongAutoID(siena.base.test.model.PersonLongAutoID)

Example 35 with PersonLongAutoID

use of siena.base.test.model.PersonLongAutoID in project siena by mandubian.

the class BaseTestNoAutoInc_1_CRUD method testSaveLongAutoID.

public void testSaveLongAutoID() {
    if (supportsAutoincrement()) {
        PersonLongAutoID maxwell = new PersonLongAutoID();
        maxwell.firstName = "James Clerk";
        maxwell.lastName = "Maxwell";
        maxwell.city = "Edinburgh";
        maxwell.n = 4;
        pm.save(maxwell);
        assertNotNull(maxwell.id);
        List<PersonLongAutoID> people = queryPersonLongAutoIDOrderBy("n", 0, false).fetch();
        assertEquals(4, people.size());
        assertEquals(LongAutoID_TESLA, people.get(0));
        assertEquals(LongAutoID_CURIE, people.get(1));
        assertEquals(LongAutoID_EINSTEIN, people.get(2));
        assertEquals(maxwell, people.get(3));
        maxwell.firstName = "James Clerk UPD";
        maxwell.lastName = "Maxwell UPD";
        maxwell.city = "Edinburgh UPD";
        maxwell.n = 5;
        pm.save(maxwell);
        assertNotNull(maxwell.id);
        people = queryPersonLongAutoIDOrderBy("n", 0, false).fetch();
        assertEquals(4, people.size());
        assertEquals(LongAutoID_TESLA, people.get(0));
        assertEquals(LongAutoID_CURIE, people.get(1));
        assertEquals(LongAutoID_EINSTEIN, people.get(2));
        assertEquals(maxwell, people.get(3));
    } else {
        try {
            PersonLongAutoID maxwell = new PersonLongAutoID();
            maxwell.firstName = "James Clerk";
            maxwell.lastName = "Maxwell";
            maxwell.city = "Edinburgh";
            maxwell.n = 4;
            pm.save(maxwell);
        } catch (SienaRestrictedApiException ex) {
            return;
        }
        fail();
    }
}
Also used : SienaRestrictedApiException(siena.SienaRestrictedApiException) PersonLongAutoID(siena.base.test.model.PersonLongAutoID)

Aggregations

PersonLongAutoID (siena.base.test.model.PersonLongAutoID)47 SienaRestrictedApiException (siena.SienaRestrictedApiException)11 ArrayList (java.util.ArrayList)3 List (java.util.List)3 QueryFilter (siena.QueryFilter)2 QueryOption (siena.core.options.QueryOption)2 QueryOptionPage (siena.core.options.QueryOptionPage)2 Json (siena.Json)1 QueryFilterSearch (siena.QueryFilterSearch)1 QueryFilterSimple (siena.QueryFilterSimple)1 QueryOrder (siena.QueryOrder)1