Class ValueComparerTemplateBase

java.lang.Object
org.dbunit.assertion.comparer.value.ValueComparerBase
org.dbunit.assertion.comparer.value.ValueComparerTemplateBase
All Implemented Interfaces:
ValueComparer
Direct Known Subclasses:
IsActualContainingExpectedStringValueComparer, IsActualEqualToExpectedJsonValueComparer, IsActualEqualToExpectedValueComparer, IsActualEqualToExpectedWithEmptyFailMessageValueComparer, IsActualGreaterThanExpectedValueComparer, IsActualGreaterThanOrEqualToExpectedValueComparer, IsActualLessThanExpectedValueComparer, IsActualLessThanOrEqualToExpectedValueComparer, IsActualNotEqualToExpectedValueComparer, IsActualNotNullValueComparer, IsActualNullValueComparer, IsActualWithinToleranceOfExpectedTimestampValueComparer, NeverFailsValueComparer, TimestampIgnoreMillisValueComparerBase

public abstract class ValueComparerTemplateBase extends ValueComparerBase
Base class for ValueComparers, providing template methods and common elements.
Since:
2.6.0
Author:
Jeff Jensen
  • Constructor Details

    • ValueComparerTemplateBase

      public ValueComparerTemplateBase()
  • Method Details

    • doCompare

      protected String doCompare(ITable expectedTable, ITable actualTable, int rowNum, String columnName, DataType dataType, Object expectedValue, Object actualValue) throws DatabaseUnitException
      Do the comparison and return a fail message or null if comparison passes. This implementation calls isExpected(ITable, ITable, int, String, DataType, Object, Object).
      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:
    • makeFailMessage

      protected String makeFailMessage(Object expectedValue, Object actualValue)
      Makes the fail message using getFailPhrase().
      Parameters:
      expectedValue - the current expected value for the column.
      actualValue - the current actual value for the column.
      Returns:
      the formatted fail message with the fail phrase.
    • isExpected

      protected abstract boolean isExpected(ITable expectedTable, ITable actualTable, int rowNum, String columnName, DataType dataType, Object expectedValue, Object actualValue) throws DatabaseUnitException
      Determines whether the actual value compares as expected against the expected value.
      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:
      true if comparing actual to expected is as expected.
      Throws:
      DatabaseUnitException - if the comparison cannot be performed.
    • getFailPhrase

      protected abstract String getFailPhrase()
      Returns the text snippet for substitution in ValueComparerBase.BASE_FAIL_MSG.
      Returns:
      The text snippet for substitution in ValueComparerBase.BASE_FAIL_MSG.