Java Code Examples for org.dbunit.dataset.ITable#getTableMetaData()

The following examples show how to use org.dbunit.dataset.ITable#getTableMetaData() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DatabaseWriterTest.java    From LicenseScout with Apache License 2.0 5 votes vote down vote up
/**
 * @param expectedDataSet
 * @param databaseDataSet
 * @param tablesNamesToCheck
 * @throws DataSetException
 * @throws DatabaseUnitException
 */
private void checkDatabase(final IDataSet expectedDataSet, final IDataSet databaseDataSet,
                           final List<String> tablesNamesToCheck)
        throws DataSetException, DatabaseUnitException {
    final DefaultColumnFilter columnFilter = createColumnFilter();
    for (final String tableName : tablesNamesToCheck) {
        final ITable actualTable = databaseDataSet.getTable(tableName);
        FilteredTableMetaData metaData = new FilteredTableMetaData(actualTable.getTableMetaData(), columnFilter);
        ITable actualTableFiltered = new CompositeTable(metaData, actualTable);
        final ITable expectedTable = expectedDataSet.getTable(tableName);
        Assertion.assertEquals(expectedTable, actualTableFiltered);
    }
}
 
Example 2
Source File: DataSetComparator.java    From jpa-unit with Apache License 2.0 5 votes vote down vote up
private ITable applyCustomFilters(final ITable table) throws DataSetException {
    ITable compositeTable = table;
    for (final Class<? extends IColumnFilter> columnFilter : columnFilters) {
        IColumnFilter customColumnFilter;
        try {
            customColumnFilter = columnFilter.newInstance();
        } catch (InstantiationException | IllegalAccessException e) {
            throw new JpaUnitException("Could not instanciate custom column filter", e);
        }
        final FilteredTableMetaData metaData = new FilteredTableMetaData(compositeTable.getTableMetaData(), customColumnFilter);
        compositeTable = new CompositeTable(metaData, compositeTable);
    }
    return compositeTable;
}