Search in sources :

Example 1 with ReturnTypesMap1

use of org.apache.cayenne.testdo.return_types.ReturnTypesMap1 in project cayenne by apache.

the class DataContextCharTypeIT method testCharTrimming.

@Test
public void testCharTrimming() {
    if (unitDbAdapter.supportsLobs()) {
        ReturnTypesMap1 map1 = context.newObject(ReturnTypesMap1.class);
        map1.setCharColumn("  text   ");
        ReturnTypesMap1 map2 = context.newObject(ReturnTypesMap1.class);
        map2.setCharColumn("  text");
        ReturnTypesMap1 map3 = context.newObject(ReturnTypesMap1.class);
        map3.setCharColumn("text     ");
        context.commitChanges();
        List<ReturnTypesMap1> result = ObjectSelect.query(ReturnTypesMap1.class).where(ReturnTypesMap1.CHAR_COLUMN.eq("  text")).select(context);
        assertTrue("CHAR type trimming is not valid.", result.get(0).getCharColumn().startsWith("  text"));
        assertTrue("CHAR type trimming is not valid.", result.get(1).getCharColumn().startsWith("  text"));
        result = ObjectSelect.query(ReturnTypesMap1.class).where(ReturnTypesMap1.CHAR_COLUMN.eq("text")).select(context);
        assertTrue("CHAR type trimming is not valid.", result.get(0).getCharColumn().startsWith("text"));
    }
}
Also used : ReturnTypesMap1(org.apache.cayenne.testdo.return_types.ReturnTypesMap1) Test(org.junit.Test)

Example 2 with ReturnTypesMap1

use of org.apache.cayenne.testdo.return_types.ReturnTypesMap1 in project cayenne by apache.

the class ReturnTypesMappingIT method testTIME2.

@Test
public void testTIME2() throws Exception {
    ReturnTypesMap1 test = context.newObject(ReturnTypesMap1.class);
    Calendar cal = Calendar.getInstance();
    cal.clear();
    cal.set(2003, Calendar.FEBRUARY, 1, 1, 20, 30);
    Date timeValue = new Time(cal.getTime().getTime());
    test.setTimeColumn(timeValue);
    context.commitChanges();
    ReturnTypesMap1 testRead = ObjectSelect.query(ReturnTypesMap1.class).selectOne(context);
    Date columnValue = testRead.getTimeColumn();
    assertNotNull(columnValue);
    assertEquals(Date.class, columnValue.getClass());
    assertEquals(timeValue.toString(), new Time(columnValue.getTime()).toString());
}
Also used : ReturnTypesMap1(org.apache.cayenne.testdo.return_types.ReturnTypesMap1) Calendar(java.util.Calendar) Time(java.sql.Time) Date(java.util.Date) Test(org.junit.Test)

Example 3 with ReturnTypesMap1

use of org.apache.cayenne.testdo.return_types.ReturnTypesMap1 in project cayenne by apache.

the class ReturnTypesMappingIT method testBIT.

@Test
public void testBIT() throws Exception {
    String columnName = "BIT_COLUMN";
    ReturnTypesMap1 test = context.newObject(ReturnTypesMap1.class);
    Boolean bitValue = true;
    test.setBitColumn(bitValue);
    context.commitChanges();
    DataRow testRead = (DataRow) context.performQuery(MappedSelect.query("SelectReturnTypesMap1")).get(0);
    Object columnValue = testRead.get(columnName);
    assertNotNull(columnValue);
    assertTrue(Boolean.class.equals(columnValue.getClass()) || Short.class.equals(columnValue.getClass()) || Integer.class.equals(columnValue.getClass()));
    assertTrue(bitValue.equals(columnValue) || ((Number) columnValue).intValue() == 1);
}
Also used : ReturnTypesMap1(org.apache.cayenne.testdo.return_types.ReturnTypesMap1) DataRow(org.apache.cayenne.DataRow) Test(org.junit.Test)

Example 4 with ReturnTypesMap1

use of org.apache.cayenne.testdo.return_types.ReturnTypesMap1 in project cayenne by apache.

the class ReturnTypesMappingIT method testDOUBLE2.

@Test
public void testDOUBLE2() throws Exception {
    ReturnTypesMap1 test = context.newObject(ReturnTypesMap1.class);
    Double doubleValue = 3298.4349783d;
    test.setDoubleColumn(doubleValue);
    context.commitChanges();
    ReturnTypesMap1 testRead = ObjectSelect.query(ReturnTypesMap1.class).selectFirst(context);
    Double columnValue = testRead.getDoubleColumn();
    assertNotNull(columnValue);
    assertEquals(Double.class, columnValue.getClass());
    assertEquals(doubleValue, columnValue);
}
Also used : ReturnTypesMap1(org.apache.cayenne.testdo.return_types.ReturnTypesMap1) Test(org.junit.Test)

Example 5 with ReturnTypesMap1

use of org.apache.cayenne.testdo.return_types.ReturnTypesMap1 in project cayenne by apache.

the class ReturnTypesMappingIT method testNUMERIC.

@Test
public void testNUMERIC() throws Exception {
    String columnName = "NUMERIC_COLUMN";
    ReturnTypesMap1 test = context.newObject(ReturnTypesMap1.class);
    BigDecimal numericValue = new BigDecimal("578438.57843");
    test.setNumericColumn(numericValue);
    context.commitChanges();
    DataRow testRead = (DataRow) context.performQuery(MappedSelect.query("SelectReturnTypesMap1")).get(0);
    Object columnValue = testRead.get(columnName);
    assertNotNull(columnValue);
    assertEquals(BigDecimal.class, columnValue.getClass());
    assertEquals(numericValue, columnValue);
}
Also used : ReturnTypesMap1(org.apache.cayenne.testdo.return_types.ReturnTypesMap1) DataRow(org.apache.cayenne.DataRow) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Aggregations

ReturnTypesMap1 (org.apache.cayenne.testdo.return_types.ReturnTypesMap1)42 Test (org.junit.Test)42 DataRow (org.apache.cayenne.DataRow)20 Date (java.util.Date)6 BigDecimal (java.math.BigDecimal)4 Calendar (java.util.Calendar)4 Expression (org.apache.cayenne.exp.Expression)4 ASTObjPath (org.apache.cayenne.exp.parser.ASTObjPath)4 ASTScalar (org.apache.cayenne.exp.parser.ASTScalar)4 ASTEqual (org.apache.cayenne.exp.parser.ASTEqual)3 Time (java.sql.Time)2 ASTBitwiseAnd (org.apache.cayenne.exp.parser.ASTBitwiseAnd)1 ASTBitwiseNot (org.apache.cayenne.exp.parser.ASTBitwiseNot)1 ASTBitwiseOr (org.apache.cayenne.exp.parser.ASTBitwiseOr)1 ASTBitwiseXor (org.apache.cayenne.exp.parser.ASTBitwiseXor)1 ASTGreater (org.apache.cayenne.exp.parser.ASTGreater)1