use of org.dbunit.dataset.DefaultDataSet in project gocd by gocd.
the class DatabaseAccessHelper method initialize.
private void initialize(DataSource dataSource) throws AmbiguousTableNameException {
databaseTester = new DataSourceDatabaseTester(dataSource);
databaseTester.setSetUpOperation(DatabaseOperation.CLEAN_INSERT);
databaseTester.setTearDownOperation(DatabaseOperation.DELETE_ALL);
DefaultDataSet dataSet = new DefaultDataSet();
dataSet.addTable(new DefaultTable("agents"));
dataSet.addTable(new DefaultTable("pipelines"));
dataSet.addTable(new DefaultTable("pipelinestates"));
dataSet.addTable(new DefaultTable("materials"));
dataSet.addTable(new DefaultTable("modifications"));
dataSet.addTable(new DefaultTable("pipelineMaterialRevisions"));
dataSet.addTable(new DefaultTable("modifiedFiles"));
dataSet.addTable(new DefaultTable("notificationfilters"));
dataSet.addTable(new DefaultTable("users"));
dataSet.addTable(new DefaultTable("stages"));
dataSet.addTable(new DefaultTable("pipelineLabelCounts"));
dataSet.addTable(new DefaultTable("environmentVariables"));
dataSet.addTable(new DefaultTable("artifactPlans"));
dataSet.addTable(new DefaultTable("buildStateTransitions"));
dataSet.addTable(new DefaultTable("resources"));
dataSet.addTable(new DefaultTable("builds"));
dataSet.addTable(new DefaultTable("stageArtifactCleanupProhibited"));
dataSet.addTable(new DefaultTable("serverBackups"));
dataSet.addTable(new DefaultTable("jobAgentMetadata"));
dataSet.addTable(new DefaultTable("AccessToken"));
databaseTester.setDataSet(dataSet);
}
use of org.dbunit.dataset.DefaultDataSet in project openmrs-core by openmrs.
the class BaseContextSensitiveTest method deleteAllData.
/**
* This is a convenience method to clear out all rows in all tables in the current connection.
* <p>
* This operation always results in a commit.
*
* @throws Exception
*/
public void deleteAllData() {
try {
Context.clearSession();
Connection connection = getConnection();
turnOffDBConstraints(connection);
IDatabaseConnection dbUnitConn = setupDatabaseConnection(connection);
// find all the tables for this connection
ResultSet resultSet = connection.getMetaData().getTables(null, "PUBLIC", "%", null);
DefaultDataSet dataset = new DefaultDataSet();
while (resultSet.next()) {
String tableName = resultSet.getString(3);
dataset.addTable(new DefaultTable(tableName));
}
// do the actual deleting/truncating
DatabaseOperation.DELETE_ALL.execute(dbUnitConn, dataset);
turnOnDBConstraints(connection);
connection.commit();
updateSearchIndex();
isBaseSetup = false;
} catch (SQLException | DatabaseUnitException e) {
throw new DatabaseUnitRuntimeException(e);
}
}
Aggregations