Class ConditionalSetBiValueComparer<T>

java.lang.Object
org.dbunit.assertion.comparer.value.ValueComparerBase
org.dbunit.assertion.comparer.value.ConditionalSetBiValueComparer<T>
Type Parameters:
T - The type of the value used to determine which ValueComparer to use.
All Implemented Interfaces:
ValueComparer

public class ConditionalSetBiValueComparer<T> extends ValueComparerBase
Use one of two ValueComparers based on a value present or not in a set of values. When the value returned by the actualValueFactory is in values, use the inValuesValueComparer on the row; otherwise, use the notInValuesValueComparer on the row.
Since:
2.6.0
Author:
Jeff Jensen
  • Constructor Details

    • ConditionalSetBiValueComparer

      public ConditionalSetBiValueComparer(ValueFactory<T> actualValueFactory, Set<T> values, ValueComparer inValuesValueComparer, ValueComparer notInValuesValueComparer)
      Creates a comparer that selects between two ValueComparers based on whether a value derived from the actual row is present in a set of values.
      Parameters:
      actualValueFactory - Factory to make the value to lookup in the values list.
      values - List of values that mean to use the inValuesValueComparer.
      inValuesValueComparer - The ValueComparer used when the value from the actualValueFactory is in the values map.
      notInValuesValueComparer - The ValueComparer used when the value from the actualValueFactory is not in the values map.
  • Method Details

    • doCompare

      public String doCompare(ITable expectedTable, ITable actualTable, int rowNum, String columnName, DataType dataType, Object expectedValue, Object actualValue) throws DatabaseUnitException
      Description copied from class: ValueComparerBase
      Do the comparison and return a fail message or null if comparison passes.
      Specified by:
      doCompare in class ValueComparerBase
      Parameters:
      expectedTable - Table containing all expected results.
      actualTable - Table containing all actual results.
      rowNum - The current row number comparing.
      columnName - The name of the current column comparing.
      dataType - The DataType for the current column comparing.
      expectedValue - The current expected value for the column.
      actualValue - The current actual value for the column.
      Returns:
      compare failure message or null if successful compare.
      Throws:
      DatabaseUnitException - if the comparison cannot be performed.
      See Also:
    • isActualValueInValues

      protected boolean isActualValueInValues(ITable actualTable, int rowNum) throws DataSetException
      Returns whether the value derived from the given row of the actual table is present in values.
      Parameters:
      actualTable - the actual table to derive the value from.
      rowNum - the row number to derive the value from.
      Returns:
      true if the derived value is present in values.
      Throws:
      DataSetException - if the value cannot be derived from the actual table.
    • toString

      public String toString()
      Overrides:
      toString in class ValueComparerBase