}
private void withOneTableForThrowOnPartialAndMixStrategy(String strategy) {
DbEntity entity = null;
String template = "SELECT #result('ARTIST_ID' 'int') FROM ARTIST ORDER BY ARTIST_ID";
SQLTemplate query = new SQLTemplate(Object.class, template);
DataMap map = getDataMap();
assertNotNull(map);
MockOperationObserver observer = new MockOperationObserver();
DataNode dataNode = createDataNode(map);
DataNode dataNode2 = createDataNode(map);
try {
int sizeDB = getNameTablesInDB(dataNode).size();
entity = createOneTable(dataNode);
int sizeDB2 = getNameTablesInDB(dataNode).size();
assertEquals(1, sizeDB2 - sizeDB);
setStrategy(strategy, dataNode2);
dataNode2.performQueries(Collections.singletonList((Query) query), observer);
}
catch (CayenneRuntimeException e) {
assertNotNull(e);
}
try {
dataNode2.performQueries(Collections.singletonList((Query) query), observer);
}
catch (CayenneRuntimeException e) {
assertNotNull(e);
}
finally {
if (entity != null) {
Collection<String> template2 = dataNode.getAdapter().dropTableStatements(
entity);
Iterator<String> it = template2.iterator();
List<Query> list = new ArrayList<Query>();
while (it.hasNext()) {
SQLTemplate q = new SQLTemplate(Object.class, it.next());
list.add(q);
}
dataNode.performQueries(list, observer);
}
}