Search in sources :

Example 1 with PrimitivesTestEntity

use of org.apache.cayenne.testdo.primitive.PrimitivesTestEntity in project cayenne by apache.

the class PrimitiveAttributesIT method testSelect.

@Test
public void testSelect() throws Exception {
    TableHelper tPrimitives = new TableHelper(dbHelper, "PRIMITIVES_TEST");
    tPrimitives.setColumns("ID", "BOOLEAN_COLUMN", "INT_COLUMN", "CHAR_COLUMN");
    tPrimitives.insert(1, true, -100, String.valueOf('a')).insert(2, false, 0, String.valueOf('~')).insert(3, true, Integer.MAX_VALUE, String.valueOf('Z'));
    List<PrimitivesTestEntity> result = ObjectSelect.query(PrimitivesTestEntity.class).orderBy(PrimitivesTestEntity.INT_COLUMN.asc()).select(context);
    assertEquals(3, result.size());
    assertEquals(-100, result.get(0).getIntColumn());
    assertEquals('a', result.get(0).getCharColumn());
    assertTrue(result.get(0).isBooleanColumn());
    assertEquals(0, result.get(1).getIntColumn());
    assertEquals('~', result.get(1).getCharColumn());
    assertFalse(result.get(1).isBooleanColumn());
    assertEquals(Integer.MAX_VALUE, result.get(2).getIntColumn());
    assertEquals('Z', result.get(2).getCharColumn());
    assertTrue(result.get(2).isBooleanColumn());
}
Also used : PrimitivesTestEntity(org.apache.cayenne.testdo.primitive.PrimitivesTestEntity) TableHelper(org.apache.cayenne.test.jdbc.TableHelper) Test(org.junit.Test)

Example 2 with PrimitivesTestEntity

use of org.apache.cayenne.testdo.primitive.PrimitivesTestEntity in project cayenne by apache.

the class PrimitiveAttributesIT method testCommit.

@Test
public void testCommit() {
    PrimitivesTestEntity e = context.newObject(PrimitivesTestEntity.class);
    e.setBooleanColumn(true);
    e.setIntColumn(88);
    e.setCharColumn('B');
    context.commitChanges();
}
Also used : PrimitivesTestEntity(org.apache.cayenne.testdo.primitive.PrimitivesTestEntity) Test(org.junit.Test)

Aggregations

PrimitivesTestEntity (org.apache.cayenne.testdo.primitive.PrimitivesTestEntity)2 Test (org.junit.Test)2 TableHelper (org.apache.cayenne.test.jdbc.TableHelper)1