View Javadoc
1   package org.dbunit.assertion.comparer.value;
2   
3   import static org.dbunit.assertion.comparer.value.IsActualWithinToleranceOfExpectedTimestampValueComparer.ONE_MINUTE_IN_MILLIS;
4   import static org.dbunit.assertion.comparer.value.IsActualWithinToleranceOfExpectedTimestampValueComparer.ONE_SECOND_IN_MILLIS;
5   
6   import org.dbunit.assertion.Difference;
7   
8   /**
9    * Convenience set of common {@link ValueComparer} instances.
10   *
11   * @author jjensen
12   * @since 2.6.0
13   */
14  public class ValueComparers
15  {
16      protected ValueComparers()
17      {
18      }
19  
20      /** @see IsActualEqualToExpectedValueComparer */
21      public static final ValueComparer isActualEqualToExpected =
22              new IsActualEqualToExpectedValueComparer();
23  
24      /**
25       * Same as {@link #isActualEqualToExpected} but its {@link ValueComparer}
26       * fail message is an empty String (the {@link Difference} fail message
27       * still exists). Use this one mainly for backwards compatibility so the
28       * {@link Difference} message stays the same.
29       * 
30       * @see IsActualEqualToExpectedWithEmptyFailMessageValueComparer
31       */
32      public static final ValueComparer isActualEqualToExpectedWithEmptyFailMessage =
33              new IsActualEqualToExpectedWithEmptyFailMessageValueComparer();
34  
35      /**
36       * Ignores nanoseconds as not all databases store it in Timestamp.
37       *
38       * @see IsActualWithinToleranceOfExpectedTimestampValueComparer
39       */
40      public static final ValueComparer isActualEqualToExpectedTimestampWithIgnoreNanos =
41              new IsActualWithinToleranceOfExpectedTimestampValueComparer(0, 0);
42  
43      /** @see IsActualNotEqualToExpectedValueComparer */
44      public static final ValueComparer isActualNotEqualToExpected =
45              new IsActualNotEqualToExpectedValueComparer();
46  
47      /** @see IsActualGreaterThanExpectedValueComparer */
48      public static final ValueComparer isActualGreaterThanExpected =
49              new IsActualGreaterThanExpectedValueComparer();
50  
51      /** @see IsActualGreaterThanOrEqualToExpectedValueComparer */
52      public static final ValueComparer isActualGreaterThanOrEqualToExpected =
53              new IsActualGreaterThanOrEqualToExpectedValueComparer();
54  
55      /** @see IsActualLessThanOrEqualToExpectedValueComparer */
56      public static final ValueComparer isActualLessOrEqualToThanExpected =
57              new IsActualLessThanOrEqualToExpectedValueComparer();
58  
59      /** @see IsActualLessThanExpectedValueComparer */
60      public static final ValueComparer isActualLessThanExpected =
61              new IsActualLessThanExpectedValueComparer();
62  
63      /** @see IsActualWithinToleranceOfExpectedTimestampValueComparer */
64      public static final ValueComparer isActualWithinOneSecondNewerOfExpectedTimestamp =
65              new IsActualWithinToleranceOfExpectedTimestampValueComparer(0,
66                      ONE_SECOND_IN_MILLIS);
67  
68      /** @see IsActualWithinToleranceOfExpectedTimestampValueComparer */
69      public static final ValueComparer isActualWithinOneSecondOlderOfExpectedTimestamp =
70              new IsActualWithinToleranceOfExpectedTimestampValueComparer(
71                      ONE_SECOND_IN_MILLIS, 0);
72  
73      /** @see IsActualWithinToleranceOfExpectedTimestampValueComparer */
74      public static final ValueComparer isActualWithinOneMinuteNewerOfExpectedTimestamp =
75              new IsActualWithinToleranceOfExpectedTimestampValueComparer(0,
76                      ONE_MINUTE_IN_MILLIS);
77  
78      /** @see IsActualWithinToleranceOfExpectedTimestampValueComparer */
79      public static final ValueComparer isActualWithinOneMinuteOlderOfExpectedTimestamp =
80              new IsActualWithinToleranceOfExpectedTimestampValueComparer(
81                      ONE_MINUTE_IN_MILLIS, 0);
82  
83      /** @see NeverFailsValueComparer */
84      public static final ValueComparer neverFails =
85              new NeverFailsValueComparer();
86  }