/** * Apply the specified exclude and include column filters to the specified table. * * @param table The table to apply the filters to. * @param excludeColumns The exclude filters; use null or empty array to mean exclude none. * @param includeColumns The include filters; use null to mean include all. * @return The filtered table. * @throws DataSetException */ public ITable applyColumnFilters(ITable table, String[] excludeColumns, String[] includeColumns) throws DataSetException { ITable filteredTable = table; if (table == null) { throw new IllegalArgumentException("table is null"); } // note: dbunit interprets an empty inclusion filter array as one // not wanting to compare anything! if (includeColumns == null) { LOG.debug("applyColumnFilters: including columns=(all)"); } else { LOG.debug("applyColumnFilters: including columns='{}'", new Object[] {includeColumns}); filteredTable = DefaultColumnFilter.includedColumnsTable(filteredTable, includeColumns); } if (excludeColumns == null || excludeColumns.length == 0) { LOG.debug("applyColumnFilters: excluding columns=(none)"); } else { LOG.debug("applyColumnFilters: excluding columns='{}'", new Object[] {excludeColumns}); filteredTable = DefaultColumnFilter.excludedColumnsTable(filteredTable, excludeColumns); } return filteredTable; }
public void testGetColumn() throws Exception { Column[] cols = new Column[] {new Column("COL1", DataType.UNKNOWN), new Column("COL2", DataType.UNKNOWN)}; DefaultTable table = new DefaultTable("MY_TABLE", cols); table.addRow(new Object[] {"value1", "value2"}); // Filter COL1 ITable tableFiltered = DefaultColumnFilter.excludedColumnsTable(table, new String[] {"COL1"}); DefaultFailureHandler failureHandler = new DefaultFailureHandler(cols); String info = failureHandler.getAdditionalInfo(tableFiltered, tableFiltered, 0, "COL1"); String expectedInfo = "Additional row info: ('COL1': expected=<value1>, actual=<value1>) ('COL2': expected=<value2>, actual=<value2>)"; assertEquals(expectedInfo, info); }