String template = "SELECT #result('id' 'int') FROM SUS1";
SQLTemplate query = new SQLTemplate(Object.class, template);
DataMap map = getDataMap();
assertNotNull(map);
DataNode dataNode = createDataNode(map);
int sizeDB = getNameTablesInDB(dataNode).size();
MockOperationObserver observer = new MockOperationObserver();
setStrategy(ThrowOnPartialOrCreateSchemaStrategy.class.getName(), dataNode);
try {
dataNode.performQueries(Collections.singletonList((Query) query), observer);
Map<String, Boolean> nameTables = getNameTablesInDB(dataNode);
assertTrue(nameTables.get("sus1") != null || nameTables.get("SUS1") != null);
int sizeDB2 = getNameTablesInDB(dataNode).size();
assertEquals(2, sizeDB2 - sizeDB);
dataNode.performQueries(Collections.singletonList((Query) query), observer);
int sizeDB3 = getNameTablesInDB(dataNode).size();
assertEquals(sizeDB2, sizeDB3);
}
finally {
DataNode dataNode2 = createDataNode(map);
dataNode2.setSchemaUpdateStrategy((SchemaUpdateStrategy) Class.forName(
dataNode2.getSchemaUpdateStrategyName()).newInstance());
dropTables(map, dataNode2, observer);
}
assertEquals(getNameTablesInDB(dataNode).size(), sizeDB);
}