use of org.dbunit.dataset.ReplacementDataSet in project head by mifos.
the class DatabaseTestUtils method getDataSetWithNullsReplaced.
/**
* Given a data set, return a data set with [null] replaced by actual null objects
* @param dataSet
* @return replacementDataSet
*/
public ReplacementDataSet getDataSetWithNullsReplaced(IDataSet dataSet) {
ReplacementDataSet replacementDataSet = new ReplacementDataSet(dataSet);
replacementDataSet.addReplacementObject("[null]", null);
return replacementDataSet;
}
use of org.dbunit.dataset.ReplacementDataSet in project openmrs-core by openmrs.
the class BaseContextSensitiveTest method executeDataSet.
/**
* Runs the flat xml data file at the classpath location specified by
* <code>datasetFilename</code> This is a convenience method. It simply creates an
* {@link IDataSet} and calls {@link #executeDataSet(IDataSet)}
*
* @param datasetFilename String path/filename on the classpath of the xml data set to clean
* insert into the current database
* @see #getConnection()
* @see #executeDataSet(IDataSet)
*/
public void executeDataSet(String datasetFilename) {
// try to get the given filename from the cache
IDataSet xmlDataSetToRun = cachedDatasets.get(datasetFilename);
// if we didn't find it in the cache, load it
if (xmlDataSetToRun == null) {
File file = new File(datasetFilename);
InputStream fileInInputStreamFormat = null;
Reader reader = null;
try {
try {
// if its a classpath path to the file
if (file.exists()) {
fileInInputStreamFormat = new FileInputStream(datasetFilename);
} else {
fileInInputStreamFormat = getClass().getClassLoader().getResourceAsStream(datasetFilename);
if (fileInInputStreamFormat == null)
throw new FileNotFoundException("Unable to find '" + datasetFilename + "' in the classpath");
}
reader = new InputStreamReader(fileInInputStreamFormat);
ReplacementDataSet replacementDataSet = new ReplacementDataSet(new FlatXmlDataSet(reader, false, true, false));
replacementDataSet.addReplacementObject("[NULL]", null);
xmlDataSetToRun = replacementDataSet;
reader.close();
} catch (DataSetException | IOException e) {
throw new DatabaseUnitRuntimeException(e);
}
} finally {
IOUtils.closeQuietly(fileInInputStreamFormat);
IOUtils.closeQuietly(reader);
}
// cache the xmldataset for future runs of this file
cachedDatasets.put(datasetFilename, xmlDataSetToRun);
}
executeDataSet(xmlDataSetToRun);
}
use of org.dbunit.dataset.ReplacementDataSet in project cals-api by ca-cwds.
the class RFA1aCoreSubmitApplicationTest method testIfSubstituteCareProviderUCWasCreatedProperly.
private void testIfSubstituteCareProviderUCWasCreatedProperly(String substituteCareProviderId1, String substituteCareProviderId2) throws Exception {
DBUnitAssertHelper helper = DBUnitAssertHelper.builder(dbUnitSupport).setExpectedResultTemplatePath("/dbunit/SubstituteCareProviderUC.xml").setTestedTableName("SBPVD_UC").build();
ReplacementDataSet expectedDataSet = helper.getExpectedDataSet();
expectedDataSet.addReplacementObject("$substituteCareProviderId1", substituteCareProviderId1);
expectedDataSet.addReplacementObject("$substituteCareProviderId2", substituteCareProviderId2);
helper.assertEquals(new String[] { "PKSB_PVDRT", "LST_UPD_TS" }, new String[] { "FIRST_NM" });
}
use of org.dbunit.dataset.ReplacementDataSet in project cals-api by ca-cwds.
the class RFA1aCoreSubmitApplicationTest method testIfSubstituteCareProviderWasCreatedProperly.
private void testIfSubstituteCareProviderWasCreatedProperly(String substituteCareProviderId1, String substituteCareProviderId2) throws Exception {
DBUnitAssertHelper helper = DBUnitAssertHelper.builder(dbUnitSupport).setExpectedResultTemplatePath("/dbunit/SubstituteCareProvider.xml").setTestedTableName("SB_PVDRT").build();
ReplacementDataSet expectedDataSet = helper.getExpectedDataSet();
expectedDataSet.addReplacementObject("$substituteCareProviderId1", substituteCareProviderId1);
expectedDataSet.addReplacementObject("$substituteCareProviderId2", substituteCareProviderId2);
helper.assertEquals(new String[] { "IDENTIFIER", "LST_UPD_TS", "LIS_PER_ID", "ETH_UD_CD", "HISP_UD_CD", "PASSBC_CD" }, new String[] { "FIRST_NM" });
}
use of org.dbunit.dataset.ReplacementDataSet in project cals-api by ca-cwds.
the class RFA1aCoreSubmitApplicationTest method testIfCountyOwnershipWasCreatedProperly.
private void testIfCountyOwnershipWasCreatedProperly(String placementHomeId, String[] substituteCareProviderIds) throws Exception {
DBUnitAssertHelper helper = DBUnitAssertHelper.builder(dbUnitSupport).setExpectedResultTemplatePath("/dbunit/CountyOwnership.xml").setTestedTableName("CNTYOWNT").build();
ReplacementDataSet expectedDataSet = helper.getExpectedDataSet();
expectedDataSet.addReplacementObject("$placementHomeId", placementHomeId);
expectedDataSet.addReplacementObject("$substituteCareProviderId1", substituteCareProviderIds[0]);
expectedDataSet.addReplacementObject("$substituteCareProviderId2", substituteCareProviderIds[1]);
helper.assertEquals(new String[] { "IDENTIFIER", "BKGRCHK_DT", "LST_UPD_TS" }, new String[] { "ENTITY_ID" });
}
Aggregations