Class DefaultResultComparator

  • All Implemented Interfaces:
    ResultComparator

    public class DefaultResultComparator
    extends Object
    implements ResultComparator
    The standard result comparator component.
    Author:
    Rene Schneider - initial API and implementation
    • Field Detail

      • valueConverter

        @Inject
        protected ValueConverter valueConverter
        The value converter to use.
      • parameterResolver

        @Inject
        protected ParameterResolver parameterResolver
        The parameter resolver to use.
    • Constructor Detail

      • DefaultResultComparator

        public DefaultResultComparator()
    • Method Detail

      • performRegexCheck

        protected ComparisonResult performRegexCheck​(String aFixtureResult,
                                                     RegexValue anExpectedResult)
        Performs the regular expression based comparison between a fixture result and an expected regex. The pattern provided must be "found" in the value (it does not have to match the entire value, except if the pattern is anchored to the start and/or end).
        Parameters:
        aFixtureResult - the fixture result as a String
        anExpectedResult - the expected result
        Returns:
        SimpleComparisonResult.EQUAL (pattern found) or SimpleComparisonResult.NOT_EQUAL (pattern not found)
      • performEqualityCheck

        protected ComparisonResult performEqualityCheck​(Object aConvertedResult,
                                                        Object aConvertedExpectedResult,
                                                        ValueOrEnumValueOrOperation aRawExpectedResult)
        Perform the actual equality check between a real result returned from a fixture and a converted result gathered from the test scripts. A few special cases are handled here, but if no special case applies, this just runs a standard equals() comparison.
        Parameters:
        aConvertedResult - the actual result
        aConvertedExpectedResult - the expected result from the scripts, converted to the same type as the actual result
        aRawExpectedResult - the raw expected result object from the scripts (if determinable, null otherwise)
        Returns:
        true if equal, false otherwise
      • performEqualityCheckForMaps

        protected MapComparisonResult performEqualityCheckForMaps​(Map<?,​?> aResult,
                                                                  Map<?,​?> anExpectedResult,
                                                                  ValueOrEnumValueOrOperation aRawExpectedResult)
        Compare two Maps for equality. Maps are considered equal if all the values in the expected result are found in the actual result (there may well be more keys in the actual result than expected, except if one of the maps declares one of these "inexistent", in which case it may NOT exist in the other!).
        Parameters:
        aResult - the result returned by the fixture
        anExpectedResult - the expected result as in the script, converted for comparison
        aRawExpectedResult - the raw expected result as in the script, before conversion
        Returns:
        true if equal, false otherwise
      • performEqualityCheckForDates

        protected ComparisonResult performEqualityCheckForDates​(Date aResult,
                                                                Date anExpectedResult,
                                                                Object aRawExpectedResult)
        Compare two Dates for equality.
        Parameters:
        aResult - the result returned by the fixture
        anExpectedResult - the expected result as in the script, converted for comparison
        aRawExpectedResult - the raw expected result as in the script, before conversion
        Returns:
        true if equal, false otherwise
      • performEqualityCheckForJava8Dates

        protected ComparisonResult performEqualityCheckForJava8Dates​(Temporal aResult,
                                                                     Temporal anExpectedResult,
                                                                     Object aRawExpectedResult)
        Compare two Temporals for equality.
        Parameters:
        aResult - the result returned by the fixture
        anExpectedResult - the expected result as in the script, converted for comparison
        aRawExpectedResult - the raw expected result as in the script, before conversion
        Returns:
        true if equal, false otherwise
      • performEqualityCheckForObjects

        protected ComparisonResult performEqualityCheckForObjects​(Object aResult,
                                                                  Object anExpectedResult,
                                                                  Object aRawExpectedResult)
        Compare two objects. At this point it is expected that the previous stages have done all conversion work, iteration through arrays etc.
        Parameters:
        aResult - the result returned by the fixture
        anExpectedResult - the expected result as in the script, converted for comparison
        aRawExpectedResult - the raw expected result as in the script, before conversion
        Returns:
        true if equal, false otherwise