use of org.dbunit.dataset.ReplacementDataSet in project cals-api by ca-cwds.
the class RFA1aCoreSubmitApplicationTest method testIfPlacementHomeInformationWasCreatedProperly.
private void testIfPlacementHomeInformationWasCreatedProperly(String placementHomeId, String substituteCareProviderId1, String substituteCareProviderId2) throws Exception {
DBUnitAssertHelper helper = DBUnitAssertHelper.builder(dbUnitSupport).setExpectedResultTemplatePath("/dbunit/PlacementHomeInformation.xml").setTestedTableName("HM_SCP_T").build();
ReplacementDataSet expectedDataSet = helper.getExpectedDataSet();
expectedDataSet.addReplacementObject("$placementHomeId", placementHomeId);
expectedDataSet.addReplacementObject("$substituteCareProviderId1", substituteCareProviderId1);
expectedDataSet.addReplacementObject("$substituteCareProviderId2", substituteCareProviderId2);
helper.assertEquals(new String[] { "THIRD_ID", "LST_UPD_TS" }, new String[] { "SCPRVD_IND" });
}
use of org.dbunit.dataset.ReplacementDataSet in project cals-api by ca-cwds.
the class RFA1aCoreSubmitApplicationTest method testIfPlacementHomeProfileWasCreatedProperly.
private void testIfPlacementHomeProfileWasCreatedProperly(String placementHomeId) throws Exception {
DBUnitAssertHelper helper = DBUnitAssertHelper.builder(dbUnitSupport).setExpectedResultTemplatePath("/dbunit/PlacementHomeProfile.xml").setTestedTableName("HM_PRFT").appendTableFilter("FKPLC_HM_T", placementHomeId).build();
ReplacementDataSet expectedDataSet = helper.getExpectedDataSet();
expectedDataSet.addReplacementObject("$placementHomeId", placementHomeId);
helper.assertEquals(new String[] { "THIRD_ID", "LST_UPD_TS" });
}
use of org.dbunit.dataset.ReplacementDataSet in project cals-api by ca-cwds.
the class DBUnitAssertHelper method getReplacementDataSet.
private ReplacementDataSet getReplacementDataSet(IDataSet dataSet) throws Exception {
ReplacementDataSet replacementDataSet = new ReplacementDataSet(dataSet);
replacementDataSet.addReplacementObject("[NULL]", null);
replacementDataSet.addReplacementObject("[CURRENT_DATE]", LocalDate.now().toString());
return replacementDataSet;
}
use of org.dbunit.dataset.ReplacementDataSet in project sharding-jdbc by shardingjdbc.
the class SQLAssertHelper method executeQueryWithPreparedStatement.
/**
* Execute query with prepared statement.
*
* @param isExecute is execute method
* @param abstractDataSourceAdapter data source adapter
* @param parameters parameters
* @param file file
*
* @throws MalformedURLException malformed URL exception
* @throws SQLException SQL exception
* @throws DatabaseUnitException database unit exception
*/
public void executeQueryWithPreparedStatement(final boolean isExecute, final AbstractDataSourceAdapter abstractDataSourceAdapter, final List<String> parameters, final File file) throws MalformedURLException, SQLException, DatabaseUnitException {
try (Connection conn = abstractDataSourceAdapter.getConnection();
PreparedStatement preparedStatement = conn.prepareStatement(SQLPlaceholderUtil.replacePreparedStatement(sql))) {
setParameters(preparedStatement, parameters);
ReplacementDataSet expectedDataSet = new ReplacementDataSet(new FlatXmlDataSetBuilder().build(file));
expectedDataSet.addReplacementObject("[null]", null);
for (ITable each : expectedDataSet.getTables()) {
String tableName = each.getTableMetaData().getTableName();
IDatabaseConnection connection = DBUnitUtil.getConnection(new DatabaseEnvironment(DatabaseType.valueFrom(conn.getMetaData().getDatabaseProductName())), conn);
ITable actualTable;
if (isExecute) {
actualTable = createTable(tableName, preparedStatement, connection);
} else {
actualTable = connection.createTable(tableName, preparedStatement);
}
Assertion.assertEquals(expectedDataSet.getTable(tableName), actualTable);
}
}
}
use of org.dbunit.dataset.ReplacementDataSet in project sharding-jdbc by shardingjdbc.
the class SQLAssertHelper method executeQueryWithStatement.
/**
* Execute query with statement.
*
* @param abstractDataSourceAdapter data source adapter
* @param parameters parameters
* @param file file
*
* @throws MalformedURLException malformed URL exception
* @throws SQLException SQL exception
* @throws DatabaseUnitException database unit exception
*/
public void executeQueryWithStatement(final AbstractDataSourceAdapter abstractDataSourceAdapter, final List<String> parameters, final File file) throws MalformedURLException, SQLException, DatabaseUnitException {
try (Connection conn = abstractDataSourceAdapter.getConnection()) {
String querySql = SQLPlaceholderUtil.replaceStatement(sql, parameters.toArray());
ReplacementDataSet expectedDataSet = new ReplacementDataSet(new FlatXmlDataSetBuilder().build(file));
expectedDataSet.addReplacementObject("[null]", null);
for (ITable each : expectedDataSet.getTables()) {
String tableName = each.getTableMetaData().getTableName();
IDatabaseConnection connection = DBUnitUtil.getConnection(new DatabaseEnvironment(DatabaseType.valueFrom(conn.getMetaData().getDatabaseProductName())), conn);
ITable actualTable = connection.createQueryTable(tableName, querySql);
// TODO customized CachedResultSetTable with statement
Assertion.assertEquals(expectedDataSet.getTable(tableName), actualTable);
}
}
}
Aggregations