Class TimestampIgnoreMillisValueComparerBase

All Implemented Interfaces:
ValueComparer
Direct Known Subclasses:
IsActualGreaterThanExpectedWithIgnoreMillisValueComparer, IsActualGreaterThanOrEqualToExpectedWithIgnoreMillisValueComparer

public abstract class TimestampIgnoreMillisValueComparerBase extends ValueComparerTemplateBase
Base class for ValueComparer implementations that verify Timestamps, ignoring the milliseconds.
Since:
3.1.0
Author:
Jeff Jensen
  • Constructor Details

    • TimestampIgnoreMillisValueComparerBase

      public TimestampIgnoreMillisValueComparerBase()
  • 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.
    • isExpectedWithNull

      protected boolean isExpectedWithNull(Object expectedValue, Object actualValue)
      Determines whether the actual value matches the expected value when at least one of them is null.
      Parameters:
      expectedValue - the expected value, possibly null.
      actualValue - the actual value, possibly null.
      Returns:
      true if the values are considered equal.
    • isExpectedWithoutNull

      protected boolean isExpectedWithoutNull(DataType dataType, Object expectedValue, Object actualValue) throws TypeCastException
      Determines whether the actual value matches the expected value, ignoring milliseconds, given that neither is null.
      Parameters:
      dataType - the column's data type.
      expectedValue - the expected value, never null.
      actualValue - the actual value, never null.
      Returns:
      true if the values are considered equal, ignoring milliseconds.
      Throws:
      TypeCastException - if a value cannot be converted for comparison.
    • convertValueToTimeInMillis

      protected long convertValueToTimeInMillis(Object timestampValue)
      Converts the given value to milliseconds since the epoch.
      Parameters:
      timestampValue - the value to convert, a Timestamp or a String formatted as yyyy-MM-dd HH:mm:ss.
      Returns:
      the value converted to milliseconds since the epoch, or 0 if the value is neither.