本文整理汇总了Java中org.dbunit.dataset.filter.DefaultColumnFilter.excludedColumnsTable方法的典型用法代码示例。如果您正苦于以下问题:Java DefaultColumnFilter.excludedColumnsTable方法的具体用法?Java DefaultColumnFilter.excludedColumnsTable怎么用?Java DefaultColumnFilter.excludedColumnsTable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.dbunit.dataset.filter.DefaultColumnFilter
的用法示例。
在下文中一共展示了DefaultColumnFilter.excludedColumnsTable方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: assertTableContent
import org.dbunit.dataset.filter.DefaultColumnFilter; //导入方法依赖的package包/类
protected void assertTableContent(IDataSet expectedDataSet, String tableName, String[] excludedColumns) throws SQLException, Exception {
IDataSet actualDataSet = getConnection().createDataSet();
ITable expectedTable = expectedDataSet.getTable(tableName);
ITable actualTable = actualDataSet.getTable(tableName);
if (excludedColumns != null) {
expectedTable = DefaultColumnFilter.excludedColumnsTable(expectedTable, excludedColumns);
actualTable = DefaultColumnFilter.excludedColumnsTable(actualTable, excludedColumns);
}
Assertion.assertEquals(expectedTable, actualTable);
}
示例2: compareExpectedWithActual
import org.dbunit.dataset.filter.DefaultColumnFilter; //导入方法依赖的package包/类
/**
* Vergelijkt een actuele dataset met de verwachte dataset. Alle records in de verwachte dataset dienen ook voor te
* komen in de actuele dataset. Tabellen die niet in de expected set voorkomen worden genegeerd.
* <p>
* @param expected De expected dataset.
* @throws DatabaseUnitException on error
* @throws SQLException on error
*/
protected void compareExpectedWithActual(final IDataSet expected) throws SQLException, DatabaseUnitException {
if (expected == null) {
throw new IllegalArgumentException("Argument 'expected' is null");
}
final IDatabaseConnection connection = createConnection();
try {
final IDataSet actual = createActualSet(connection);
final String[] expTableNames = expected.getTableNames();
for (final String currentTableName : expTableNames) {
// prepareer verwachtte tabel
final ITable expTable = expected.getTable(currentTableName);
final Column[] columnsExp = expTable.getTableMetaData().getColumns();
// Zoek naar kolommen met waarde: [NOTNULLCHECK] zodat deze geexclude worden. Deze worden later per rij
// gecontroleerd
final Set<String> excludeButNotEmptyColumnsSet = new HashSet<>();
final Map<Integer, String> excludeButNotEmptyColumns = new HashMap<>();
for (final Column column : columnsExp) {
for (int i = 0; i < expTable.getRowCount(); i++) {
final Object value = expTable.getValue(i, column.getColumnName());
if (value != null && value.toString().equals("[NOTNULLCHECK]")) {
excludeButNotEmptyColumnsSet.add(column.getColumnName());
excludeButNotEmptyColumns.put(i, column.getColumnName());
}
}
}
final String[] excludeButNotEmptyColumnsArray = excludeButNotEmptyColumnsSet.toArray(new String[0]);
final ITable filteredTableExp = DefaultColumnFilter.excludedColumnsTable(expTable, excludeButNotEmptyColumnsArray);
final ITable sortedExp = new SortedTable(filteredTableExp);
final ITable currentTimestampColumnFilteredExp = new ColumnFilterTable(sortedExp, new CurrentTimestampColumnFilter());
// prepareer actuele tabel
final ITable actTable = actual.getTable(currentTableName);
final ITable filteredTable = DefaultColumnFilter.excludedColumnsTable(actTable, excludeButNotEmptyColumnsArray);
final ITable sortedActTable = new SortedTable(filteredTable);
final ITable primaryKeyFilteredActTable = new RowFilterTable(sortedActTable, new PrimaryKeyRowFilter(expTable));
final ITable currentTimestampRowFilteredActTable = new RowFilterTable(primaryKeyFilteredActTable, new CurrentTimestampRowFilter(expTable));
final ITable currentTimestampColumnFilteredActTable =
new ColumnFilterTable(currentTimestampRowFilteredActTable, new CurrentTimestampColumnFilter());
try {
ASSERT.assertEquals(currentTimestampColumnFilteredExp, currentTimestampColumnFilteredActTable);
if (excludeButNotEmptyColumns.size() > 0) {
for (int rij = 0; rij < actTable.getRowCount(); rij++) {
final String excludeColumName = excludeButNotEmptyColumns.get(rij);
if (excludeColumName != null && actTable.getValue(rij, excludeColumName) == null) {
LOG.error("****** NotNullCheck column was leeg in actual result: " + excludeColumName);
throw new AssertionFailedError();
}
}
}
} catch (final AssertionFailedError assertionError) {
LOG.error("****** De volgende records zijn aangetroffen in de database:");
LOG.error(FORMATTER.format(sortedActTable));
LOG.error("****** Terwijl minimaal de volgende EXPECTED records verwacht worden:");
LOG.error(FORMATTER.format(sortedExp));
throw assertionError;
}
}
} finally {
connection.close();
}
}
示例3: filter
import org.dbunit.dataset.filter.DefaultColumnFilter; //导入方法依赖的package包/类
private ITable filter(final ITable table, final String[] columnsToFilter) throws DataSetException {
final ITable filteredTable = DefaultColumnFilter.excludedColumnsTable(table, columnsToFilter);
return applyCustomFilters(filteredTable);
}