params.put("compare_date", startTime);
verifyDbSuccess(theController, "queryAccount", expectedSuccesses);
}
private void verifyDbSuccess(Controller theController, String dbConfigName, int expectedSuccesses) {
DatabaseReader reader = null;
logger.info("Verifying database success for database configuration: " + dbConfigName);
try {
reader = new DatabaseReader(theController.getConfig(), dbConfigName);
reader.open();
int readBatchSize = theController.getConfig().getInt(Config.DAO_READ_BATCH_SIZE);
List<Row> successRows = reader.readRowList(readBatchSize);
int rowsProcessed = 0;
assertNotNull("Error reading " + readBatchSize + " rows", successRows);
while(successRows.size() > 0) {
rowsProcessed += successRows.size();
logger.info("Verifying database success for next " + successRows.size() + " of total " + rowsProcessed + " rows");
assertTrue("No updated rows have been found in the database.", successRows.size() > 0);
successRows = reader.readRowList(readBatchSize);
}
assertEquals(expectedSuccesses, rowsProcessed);
} catch (DataAccessObjectInitializationException e) {
Assert.fail("Error initializing database operation success verification using dbConfig: " + dbConfigName +
", error:" + e.getMessage());
} catch (DataAccessObjectException e) {
Assert.fail("Error reading rows during database operation success verification using dbConfig: " + dbConfigName +
", error:" + e.getMessage());
} catch (ParameterLoadException e) {
Assert.fail("Error getting a config parameter: " + e.getMessage()
+ "during database operation success verification using dbConfig: " + dbConfigName);
} finally {
if(reader != null) reader.close();
}
}