Package org.dbunit

Class VerifyTableDefinition

java.lang.Object
org.dbunit.VerifyTableDefinition

public class VerifyTableDefinition extends Object
Defines a database table to verify (assert on data), specifying include and exclude column filters and optional ValueComparers.
Since:
2.4.8
Version:
$Revision$ $Date$
Author:
Jeff Jensen jeffjensen AT users.sourceforge.net, Last changed by: $Author$
  • Constructor Details

    • VerifyTableDefinition

      public VerifyTableDefinition(String table, String[] excludeColumns)
      Create a valid instance with all columns compared except exclude the specified columns.
      Parameters:
      table - The name of the table - required.
      excludeColumns - The columns in the table to ignore (filter out) in expected vs actual comparisons; null or empty array to exclude no columns.
    • VerifyTableDefinition

      public VerifyTableDefinition(String table, ValueComparer defaultValueComparer, Map<String,ValueComparer> columnValueComparers)
      Create a valid instance with all columns compared and use the specified defaultValueComparer for all column comparisons not in the columnValueComparers Map.
      Parameters:
      table - The name of the table - required.
      defaultValueComparer - ValueComparer to use with column value comparisons when the column name for the table is not in the columnValueComparers Map. Can be null and will default.
      columnValueComparers - Map of ValueComparers to use for specific columns. Key is column name, value is ValueComparer to use for comparison of that column. Can be null and will default to defaultValueComparer for all columns in all tables.
      Since:
      2.6.0
    • VerifyTableDefinition

      public VerifyTableDefinition(String table, String[] excludeColumns, ValueComparer defaultValueComparer, Map<String,ValueComparer> columnValueComparers)
      Create a valid instance with all columns compared and exclude the specified columns, and use the specified defaultValueComparer for all column comparisons not in the columnValueComparers Map.
      Parameters:
      table - The name of the table - required.
      excludeColumns - The columns in the table to ignore (filter out) in expected vs actual comparisons; null or empty array to exclude no columns.
      defaultValueComparer - ValueComparer to use with column value comparisons when the column name for the table is not in the columnValueComparers Map. Can be null and will default.
      columnValueComparers - Map of ValueComparers to use for specific columns. Key is column name, value is ValueComparer to use for comparison of that column. Can be null and will default to defaultValueComparer for all columns in all tables.
      Since:
      2.6.0
    • VerifyTableDefinition

      public VerifyTableDefinition(String table, String[] excludeColumns, String[] includeColumns)
      Create a valid instance specifying exclude and include columns.
      Parameters:
      table - The name of the table.
      excludeColumns - The columns in the table to ignore (filter out) in expected vs actual comparisons; null or empty array to exclude no columns.
      includeColumns - The columns in the table to include in expected vs actual comparisons; null to include all columns, empty array to include no columns.
    • VerifyTableDefinition

      public VerifyTableDefinition(String table, String[] excludeColumns, String[] includeColumns, ValueComparer defaultValueComparer, Map<String,ValueComparer> columnValueComparers)
      Create a valid instance specifying exclude and include columns and use the specified defaultValueComparer for all column comparisons not in the columnValueComparers Map.
      Parameters:
      table - The name of the table.
      excludeColumns - The columns in the table to ignore (filter out) in expected vs actual comparisons; null or empty array to exclude no columns.
      includeColumns - The columns in the table to include in expected vs actual comparisons; null to include all columns, empty array to include no columns.
      defaultValueComparer - ValueComparer to use with column value comparisons when the column name for the table is not in the columnValueComparers Map. Can be null and will default.
      columnValueComparers - Map of ValueComparers to use for specific columns. Key is column name, value is ValueComparer to use for comparison of that column. Can be null and will default to defaultValueComparer for all columns in all tables.
      Since:
      2.6.0
    • VerifyTableDefinition

      public VerifyTableDefinition(String table, String[] excludeColumns, ValueComparer defaultValueComparer, Map<String,ValueComparer> columnValueComparers, boolean sortOnFilteredColumnsOnly)
      Create a valid instance with all columns compared and exclude the specified columns, use the specified defaultValueComparer for all column comparisons not in the columnValueComparers Map, and specify whether to sort by only the filtered columns. The common case for opting into sortOnFilteredColumnsOnly when include filters are not also needed.
      Parameters:
      table - The name of the table - required.
      excludeColumns - The columns in the table to ignore (filter out) in expected vs actual comparisons; null or empty array to exclude no columns.
      defaultValueComparer - ValueComparer to use with column value comparisons when the column name for the table is not in the columnValueComparers Map. Can be null and will default.
      columnValueComparers - Map of ValueComparers to use for specific columns. Key is column name, value is ValueComparer to use for comparison of that column. Can be null and will default to defaultValueComparer for all columns in all tables.
      sortOnFilteredColumnsOnly - True to sort the expected and actual tables by only this table's filtered columns instead of by all of the actual table's native columns. See sortOnFilteredColumnsOnly.
      Since:
      3.5.0
    • VerifyTableDefinition

      public VerifyTableDefinition(String table, String[] excludeColumns, String[] includeColumns, ValueComparer defaultValueComparer, Map<String,ValueComparer> columnValueComparers, boolean sortOnFilteredColumnsOnly)
      Create a valid instance specifying exclude and include columns, value comparers, and whether to sort by only the filtered columns.
      Parameters:
      table - The name of the table.
      excludeColumns - The columns in the table to ignore (filter out) in expected vs actual comparisons; null or empty array to exclude no columns.
      includeColumns - The columns in the table to include in expected vs actual comparisons; null to include all columns, empty array to include no columns.
      defaultValueComparer - ValueComparer to use with column value comparisons when the column name for the table is not in the columnValueComparers Map. Can be null and will default.
      columnValueComparers - Map of ValueComparers to use for specific columns. Key is column name, value is ValueComparer to use for comparison of that column. Can be null and will default to defaultValueComparer for all columns in all tables.
      sortOnFilteredColumnsOnly - True to sort the expected and actual tables by only this table's filtered columns instead of by all of the actual table's native columns. See sortOnFilteredColumnsOnly.
      Since:
      3.5.0
  • Method Details

    • getTableName

      public String getTableName()
      Returns the table name.
      Returns:
      the table name.
    • getColumnExclusionFilters

      public String[] getColumnExclusionFilters()
      Returns the column names excluded from verification.
      Returns:
      the column names excluded from verification.
    • getColumnInclusionFilters

      public String[] getColumnInclusionFilters()
      Returns the column names included in verification.
      Returns:
      the column names included in verification.
    • getDefaultValueComparer

      public ValueComparer getDefaultValueComparer()
      Returns the default value comparer used for columns without a specific one.
      Returns:
      the default value comparer used for columns without a specific one.
      Since:
      2.6.0
    • getColumnValueComparers

      public Map<String,ValueComparer> getColumnValueComparers()
      Returns the per-column value comparers.
      Returns:
      the per-column value comparers.
      Since:
      2.6.0
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • arrayToString

      protected String arrayToString(String[] array)
      Returns a null-safe string representation of the given array.
      Parameters:
      array - the array to format, possibly null.
      Returns:
      a null-safe string representation of the given array.
    • getVerifyTableDefinitionVerifier

      public VerifyTableDefinitionVerifier getVerifyTableDefinitionVerifier()
      Returns the verifier used to validate this instance.
      Returns:
      the verifier used to validate this instance.
    • setVerifyTableDefinitionVerifier

      public void setVerifyTableDefinitionVerifier(VerifyTableDefinitionVerifier verifyTableDefinitionVerifier)
      Sets the verifier used to validate this instance.
      Parameters:
      verifyTableDefinitionVerifier - the verifier used to validate this instance.
    • isSortOnFilteredColumnsOnly

      public boolean isSortOnFilteredColumnsOnly()
      Returns whether this table sorts by only its filtered columns instead of all native columns.
      Returns:
      True if it sorts by only its filtered columns, false if by all native columns.
      Since:
      3.5.0
      See Also:
      • sortOnFilteredColumnsOnly
    • setSortOnFilteredColumnsOnly

      public void setSortOnFilteredColumnsOnly(boolean sortOnFilteredColumnsOnly)
      Sets whether this table sorts by only its filtered columns instead of all native columns. Default is false.
      Parameters:
      sortOnFilteredColumnsOnly - True to sort by only its filtered columns, false to sort by all native columns.
      Since:
      3.5.0
      See Also:
      • sortOnFilteredColumnsOnly