Class IsActualWithinToleranceOfExpectedTimestampValueComparer
java.lang.Object
org.dbunit.assertion.comparer.value.ValueComparerBase
org.dbunit.assertion.comparer.value.ValueComparerTemplateBase
org.dbunit.assertion.comparer.value.IsActualWithinToleranceOfExpectedTimestampValueComparer
- All Implemented Interfaces:
ValueComparer
public class IsActualWithinToleranceOfExpectedTimestampValueComparer
extends ValueComparerTemplateBase
ValueComparer implementation for Timestamps that verifies
actual value is within a low and high milliseconds tolerance range of
expected value.
Note: If actual and expected values are both null, the comparison passes.- Since:
- 2.6.0
- Author:
- Jeff Jensen
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final longstatic final longstatic final longstatic final longstatic final longstatic final longstatic final longstatic final longstatic final longstatic final longstatic final longFields inherited from class org.dbunit.assertion.comparer.value.ValueComparerBase
BASE_FAIL_MSG -
Constructor Summary
ConstructorsConstructorDescriptionIsActualWithinToleranceOfExpectedTimestampValueComparer(long lowToleranceValueInMillis, long highToleranceValueInMillis) Create instance specifying the allowed actual time difference range from expected. -
Method Summary
Modifier and TypeMethodDescriptionprotected longcalcTimeDifference(long actualTimeInMillis, long expectedTimeInMillis) protected longconvertValueToTimeInMillis(Object timestampValue) protected ObjectgetCastedValue(Object value, DataType type) protected Stringprotected booleanisExpected(ITable expectedTable, ITable actualTable, int rowNum, String columnName, DataType dataType, Object expectedValue, Object actualValue) protected booleanisExpectedWithNull(Object expectedValue, Object actualValue) Since one is a known null, isExpected=true when they equal.protected booleanisExpectedWithoutNull(Object expectedValue, Object actualValue, DataType dataType) Neither is null so compare values with tolerance.protected booleanisTolerant(long diffTime) Methods inherited from class org.dbunit.assertion.comparer.value.ValueComparerTemplateBase
doCompare, makeFailMessageMethods inherited from class org.dbunit.assertion.comparer.value.ValueComparerBase
compare, toString
-
Field Details
-
ONE_SECOND_IN_MILLIS
public static final long ONE_SECOND_IN_MILLIS- See Also:
-
TWO_SECONDS_IN_MILLIS
public static final long TWO_SECONDS_IN_MILLIS- See Also:
-
THREE_SECONDS_IN_MILLIS
public static final long THREE_SECONDS_IN_MILLIS- See Also:
-
FOUR_SECONDS_IN_MILLIS
public static final long FOUR_SECONDS_IN_MILLIS- See Also:
-
FIVE_SECONDS_IN_MILLIS
public static final long FIVE_SECONDS_IN_MILLIS- See Also:
-
ONE_MINUTE_IN_MILLIS
public static final long ONE_MINUTE_IN_MILLIS- See Also:
-
TWO_MINUTES_IN_MILLIS
public static final long TWO_MINUTES_IN_MILLIS- See Also:
-
THREE_MINUTES_IN_MILLIS
public static final long THREE_MINUTES_IN_MILLIS- See Also:
-
FOUR_MINUTES_IN_MILLIS
public static final long FOUR_MINUTES_IN_MILLIS- See Also:
-
FIVE_MINUTES_IN_MILLIS
public static final long FIVE_MINUTES_IN_MILLIS- See Also:
-
TEN_MINUTES_IN_MILLIS
public static final long TEN_MINUTES_IN_MILLIS- See Also:
-
-
Constructor Details
-
IsActualWithinToleranceOfExpectedTimestampValueComparer
public IsActualWithinToleranceOfExpectedTimestampValueComparer(long lowToleranceValueInMillis, long highToleranceValueInMillis) Create instance specifying the allowed actual time difference range from expected.- Parameters:
lowToleranceValueInMillis- The minimum time difference allowed.highToleranceValueInMillis- The maximum time difference allowed.
-
-
Method Details
-
isExpected
protected boolean isExpected(ITable expectedTable, ITable actualTable, int rowNum, String columnName, DataType dataType, Object expectedValue, Object actualValue) throws DatabaseUnitException - Specified by:
isExpectedin classValueComparerTemplateBase- Returns:
- true if comparing actual to expected is as expected.
- Throws:
DatabaseUnitException
-
isExpectedWithNull
Since one is a known null, isExpected=true when they equal. -
isExpectedWithoutNull
protected boolean isExpectedWithoutNull(Object expectedValue, Object actualValue, DataType dataType) throws TypeCastException Neither is null so compare values with tolerance.- Throws:
TypeCastException
-
getCastedValue
- Throws:
TypeCastException
-
isTolerant
protected boolean isTolerant(long diffTime) -
convertValueToTimeInMillis
-
calcTimeDifference
protected long calcTimeDifference(long actualTimeInMillis, long expectedTimeInMillis) -
getFailPhrase
- Specified by:
getFailPhrasein classValueComparerTemplateBase- Returns:
- The text snippet for substitution in
ValueComparerBase.BASE_FAIL_MSG.
-