Class IsActualContainingExpectedStringValueComparer

All Implemented Interfaces:
ValueComparer

public class IsActualContainingExpectedStringValueComparer extends ValueComparerTemplateBase
ValueComparer implementation that verifies actual value contains expected value by converting to Strings and using String.contains(CharSequence). Special case: if both are null, they match.
Since:
2.7.0
Author:
Jeff Jensen
  • Constructor Details

    • IsActualContainingExpectedStringValueComparer

      public IsActualContainingExpectedStringValueComparer()
  • Method Details

    • isExpected

      protected boolean isExpected(ITable expectedTable, ITable actualTable, int rowNum, String columnName, DataType dataType, Object expectedValue, Object actualValue) throws DatabaseUnitException
      Description copied from class: ValueComparerTemplateBase
      Determines whether the actual value compares as expected against the expected value.
      Specified by:
      isExpected in class ValueComparerTemplateBase
      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.
    • isContaining

      protected boolean isContaining(Object expectedValue, Object actualValue) throws TypeCastException
      Returns whether the actual value, converted to a string, contains the expected value, also converted to a string.
      Parameters:
      expectedValue - the expected value.
      actualValue - the actual value.
      Returns:
      true if the actual value's string form contains the expected value's string form.
      Throws:
      TypeCastException - if either value cannot be converted to a string.
    • getFailPhrase

      protected String getFailPhrase()
      Description copied from class: ValueComparerTemplateBase
      Returns the text snippet for substitution in ValueComparerBase.BASE_FAIL_MSG.
      Specified by:
      getFailPhrase in class ValueComparerTemplateBase
      Returns:
      The text snippet for substitution in ValueComparerBase.BASE_FAIL_MSG.