Search in sources :

Example 1 with ClientTablePrimitives

use of org.apache.cayenne.testdo.table_primitives.ClientTablePrimitives in project cayenne by apache.

the class CayenneContextPrimitiveIT method testSelectEmptyPrimitives.

@Test
public void testSelectEmptyPrimitives() throws Exception {
    tTablePrimitives.insert(1, accessStackAdapter.supportsBoolean() ? true : 1, null);
    ClientTablePrimitives object = ObjectSelect.query(ClientTablePrimitives.class).selectFirst(context);
    assertTrue(object.isBooleanColumn());
    assertEquals(0, object.getIntColumn());
}
Also used : ClientTablePrimitives(org.apache.cayenne.testdo.table_primitives.ClientTablePrimitives) Test(org.junit.Test)

Example 2 with ClientTablePrimitives

use of org.apache.cayenne.testdo.table_primitives.ClientTablePrimitives in project cayenne by apache.

the class CayenneContextPrimitiveIT method testCommitChangesPrimitives.

@Test
public void testCommitChangesPrimitives() throws Exception {
    ClientTablePrimitives object = context.newObject(ClientTablePrimitives.class);
    object.setBooleanColumn(true);
    object.setIntColumn(3);
    context.commitChanges();
    assertTrue(tTablePrimitives.getBoolean("BOOLEAN_COLUMN"));
    assertEquals(3, tTablePrimitives.getInt("INT_COLUMN"));
    object.setBooleanColumn(false);
    object.setIntColumn(8);
    context.commitChanges();
    assertFalse(tTablePrimitives.getBoolean("BOOLEAN_COLUMN"));
    assertEquals(8, tTablePrimitives.getInt("INT_COLUMN"));
}
Also used : ClientTablePrimitives(org.apache.cayenne.testdo.table_primitives.ClientTablePrimitives) Test(org.junit.Test)

Example 3 with ClientTablePrimitives

use of org.apache.cayenne.testdo.table_primitives.ClientTablePrimitives in project cayenne by apache.

the class CayenneContextPrimitiveIT method testSelectPrimitives.

@Test
public void testSelectPrimitives() throws Exception {
    createTwoPrimitivesDataSet();
    SelectQuery query = new SelectQuery(ClientTablePrimitives.class);
    query.addOrdering("db:" + TablePrimitives.ID_PK_COLUMN, SortOrder.ASCENDING);
    List<ClientTablePrimitives> results = context.performQuery(query);
    assertTrue(results.get(0).isBooleanColumn());
    assertFalse(results.get(1).isBooleanColumn());
    assertEquals(0, results.get(0).getIntColumn());
    assertEquals(5, results.get(1).getIntColumn());
}
Also used : SelectQuery(org.apache.cayenne.query.SelectQuery) ClientTablePrimitives(org.apache.cayenne.testdo.table_primitives.ClientTablePrimitives) Test(org.junit.Test)

Example 4 with ClientTablePrimitives

use of org.apache.cayenne.testdo.table_primitives.ClientTablePrimitives in project cayenne by apache.

the class CayenneContextPrimitiveIT method testCommitEmptyChangesPrimitives.

@Test
public void testCommitEmptyChangesPrimitives() throws Exception {
    ClientTablePrimitives object = context.newObject(ClientTablePrimitives.class);
    context.commitChanges();
    assertFalse(tTablePrimitives.getBoolean("BOOLEAN_COLUMN"));
    assertEquals(0, tTablePrimitives.getInt("INT_COLUMN"));
    object.setBooleanColumn(true);
    object.setIntColumn(8);
    context.commitChanges();
    assertTrue(tTablePrimitives.getBoolean("BOOLEAN_COLUMN"));
    assertEquals(8, tTablePrimitives.getInt("INT_COLUMN"));
}
Also used : ClientTablePrimitives(org.apache.cayenne.testdo.table_primitives.ClientTablePrimitives) Test(org.junit.Test)

Aggregations

ClientTablePrimitives (org.apache.cayenne.testdo.table_primitives.ClientTablePrimitives)4 Test (org.junit.Test)4 SelectQuery (org.apache.cayenne.query.SelectQuery)1