use of org.apache.cayenne.access.MockOperationObserver in project cayenne by apache.
the class ThrowOnPartialSchemaStrategyIT method testThrowOnPartialStrategyTableNoExist.
@Test
public void testThrowOnPartialStrategyTableNoExist() throws Exception {
String template = "SELECT #result('ARTIST_ID' 'int') FROM ARTIST ORDER BY ARTIST_ID";
SQLTemplate query = new SQLTemplate(Object.class, template);
MockOperationObserver observer = new MockOperationObserver();
setStrategy(ThrowOnPartialSchemaStrategy.class);
try {
node.performQueries(Collections.singletonList((Query) query), observer);
} catch (CayenneRuntimeException e) {
assertNotNull(e);
}
try {
node.performQueries(Collections.singletonList((Query) query), observer);
} catch (CayenneRuntimeException e) {
assertNotNull(e);
}
}
use of org.apache.cayenne.access.MockOperationObserver in project cayenne by apache.
the class ThrowOnPartialSchemaStrategyIT method testThrowOnPartialStrategyTableExist.
@Test
public void testThrowOnPartialStrategyTableExist() throws Exception {
String template = "SELECT #result('ARTIST_ID' 'int') FROM ARTIST ORDER BY ARTIST_ID";
SQLTemplate query = new SQLTemplate(Object.class, template);
MockOperationObserver observer = new MockOperationObserver();
createOneTable("SUS1");
createOneTable("SUS2");
setStrategy(ThrowOnPartialSchemaStrategy.class);
node.performQueries(Collections.singletonList(query), observer);
}
use of org.apache.cayenne.access.MockOperationObserver in project cayenne by apache.
the class ThrowOnPartialSchemaStrategyIT method testThrowOnPartialStrategyWithOneTable.
@Test
public void testThrowOnPartialStrategyWithOneTable() throws Exception {
createOneTable("SUS1");
setStrategy(ThrowOnPartialSchemaStrategy.class);
String template = "SELECT #result('ARTIST_ID' 'int') FROM ARTIST ORDER BY ARTIST_ID";
SQLTemplate query = new SQLTemplate(Object.class, template);
MockOperationObserver observer = new MockOperationObserver();
try {
node.performQueries(Collections.singletonList(query), observer);
assertEquals(1, existingTables().size());
fail("Must have thrown on partial schema");
} catch (CayenneRuntimeException e) {
// expected
}
}
use of org.apache.cayenne.access.MockOperationObserver in project cayenne by apache.
the class ResultDirectiveIT method selectForQuery.
private Map<String, Object> selectForQuery(String sql) {
SQLTemplate template = new SQLTemplate(Artist.class, sql);
template.setColumnNamesCapitalization(CapsStrategy.UPPER);
MockOperationObserver observer = new MockOperationObserver();
runtime.getDataDomain().performQueries(Collections.singletonList(template), observer);
@SuppressWarnings("unchecked") List<Map<String, Object>> data = observer.rowsForQuery(template);
assertEquals(1, data.size());
Map<String, Object> row = data.get(0);
return row;
}
use of org.apache.cayenne.access.MockOperationObserver in project cayenne by apache.
the class BindDirectiveIT method performInsertForParameters.
/**
* Inserts row for given parameters
*
* @return inserted row
*/
private Map<String, ?> performInsertForParameters(Map<String, Object> parameters, String templateString) throws Exception {
// TODO: do we really care if an inserting SQLTemplate is executed via
// ObjectContext?
SQLTemplate template = new SQLTemplate(Object.class, templateString);
template.setParams(parameters);
MockOperationObserver observer = new MockOperationObserver();
node.performQueries(Collections.singletonList(template), observer);
return ObjectSelect.dataRowQuery(Artist.class).selectOne(context);
}
Aggregations