use of org.apache.cayenne.DataRow in project cayenne by apache.
the class ReturnTypesMappingIT method testBOOLEAN.
@Test
public void testBOOLEAN() throws Exception {
String columnName = "BOOLEAN_COLUMN";
ReturnTypesMap1 test = context.newObject(ReturnTypesMap1.class);
Boolean booleanValue = true;
test.setBooleanColumn(booleanValue);
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(booleanValue.equals(columnValue) || ((Number) columnValue).intValue() == 1);
}
use of org.apache.cayenne.DataRow in project cayenne by apache.
the class ReturnTypesMappingIT method testTINYINT.
@Test
public void testTINYINT() throws Exception {
String columnName = "TINYINT_COLUMN";
ReturnTypesMap1 test = context.newObject(ReturnTypesMap1.class);
Byte tinyintValue = 89;
Integer intValue = 89;
test.setTinyintColumn(tinyintValue);
context.commitChanges();
DataRow testRead = (DataRow) context.performQuery(MappedSelect.query("SelectReturnTypesMap1")).get(0);
Object columnValue = testRead.get(columnName);
assertNotNull(columnValue);
if (unitDbAdapter.onlyGenericNumberType()) {
assertEquals(Integer.class, columnValue.getClass());
} else {
assertEquals(Short.class, columnValue.getClass());
}
assertEquals(tinyintValue.intValue(), ((Number) columnValue).intValue());
}
use of org.apache.cayenne.DataRow in project cayenne by apache.
the class ReturnTypesMappingIT method testVARBINARY.
@Test
public void testVARBINARY() throws Exception {
if (unitDbAdapter.supportsLobs()) {
String columnName = "VARBINARY_COLUMN";
ReturnTypesMap2 test = context.newObject(ReturnTypesMap2.class);
byte[] varbinaryValue = { 3, 4, 5, -6, 7, 0, 2, 9, 45, 64, 3, 127, -128, -60 };
test.setVarbinaryColumn(varbinaryValue);
context.commitChanges();
DataRow testRead = (DataRow) context.performQuery(MappedSelect.query("SelectReturnTypesMap2")).get(0);
Object columnValue = testRead.get(columnName);
assertNotNull(columnValue);
assertEquals(byte[].class, columnValue.getClass());
assertTrue(Arrays.equals(varbinaryValue, (byte[]) columnValue));
}
}
use of org.apache.cayenne.DataRow in project cayenne by apache.
the class ReturnTypesMappingIT method testDATE.
@Test
public void testDATE() throws Exception {
String columnName = "DATE_COLUMN";
ReturnTypesMap1 test = context.newObject(ReturnTypesMap1.class);
Calendar cal = Calendar.getInstance();
cal.clear();
cal.set(2002, 1, 1);
Date dateValue = cal.getTime();
test.setDateColumn(dateValue);
context.commitChanges();
DataRow testRead = (DataRow) context.performQuery(MappedSelect.query("SelectReturnTypesMap1")).get(0);
Object columnValue = testRead.get(columnName);
assertNotNull(columnValue);
assertEquals(Date.class, columnValue.getClass());
assertEquals(dateValue.toString(), columnValue.toString());
}
use of org.apache.cayenne.DataRow in project cayenne by apache.
the class ReturnTypesMappingIT method testCHAR.
@Test
public void testCHAR() throws Exception {
String columnName = "CHAR_COLUMN";
ReturnTypesMap1 test = context.newObject(ReturnTypesMap1.class);
String charValue = "Char string for tests!";
test.setCharColumn(charValue);
context.commitChanges();
DataRow testRead = (DataRow) context.performQuery(MappedSelect.query("SelectReturnTypesMap1")).get(0);
Object columnValue = testRead.get(columnName);
assertNotNull(columnValue);
assertEquals(String.class, columnValue.getClass());
assertEquals(charValue, columnValue);
}
Aggregations