use of org.apache.cayenne.access.MockOperationObserver in project cayenne by apache.
the class SQLTemplateActionIT method testSelectUtilDate.
@Test
public void testSelectUtilDate() throws Exception {
createFourArtists();
String templateString = "SELECT #result('DATE_OF_BIRTH' 'java.util.Date' 'DOB') " + "FROM ARTIST WHERE ARTIST_ID = #bind($id)";
SQLTemplate template = new SQLTemplate(Object.class, templateString);
sqlTemplateCustomizer.updateSQLTemplate(template);
Map<String, Object> bindings = new HashMap<>();
bindings.put("id", 101);
template.setParameters(bindings);
SQLAction plan = adapter.getAction(template, node);
MockOperationObserver observer = new MockOperationObserver();
try (Connection c = dataSourceFactory.getSharedDataSource().getConnection()) {
plan.performAction(c, observer);
}
List<DataRow> rows = observer.rowsForQuery(template);
assertNotNull(rows);
assertEquals(1, rows.size());
DataRow row = rows.get(0);
assertNotNull(row.get("DOB"));
assertEquals(java.util.Date.class, row.get("DOB").getClass());
}
Aggregations