Class FixtureWrapper<C>

  • Type Parameters:
    C - the fixture class

    public class FixtureWrapper<C>
    extends Object
    This wrapper is used to encapsulate fixture instances.
    Author:
    Rene Schneider - initial API and implementation
    • Field Detail

      • conversionContextProvider

        @Inject
        protected com.google.inject.Provider<ConversionContext> conversionContextProvider
        The conversion context provider.
    • Method Detail

      • release

        public void release()
        Releases the fixture instance.
      • getFixtureClass

        protected Class<?> getFixtureClass()
      • getFixtureInstance

        protected Object getFixtureInstance()
      • isCustomComparatorFixture

        public boolean isCustomComparatorFixture()
        Checks whether the wrapped fixture is a CustomComparatorFixture.
        Returns:
        true if it is
      • isCustomComparatorAndConversionFixture

        public boolean isCustomComparatorAndConversionFixture()
        Checks whether the wrapped fixture is a CustomComparatorAndConversionFixture.
        Returns:
        true if it is
      • isCustomStringConversionFixture

        public boolean isCustomStringConversionFixture()
        Checks whether the wrapped fixture is a CustomStringConversionFixture.
        Returns:
        true if it is
      • isResultAwareFixture

        public boolean isResultAwareFixture()
        Checks whether the wrapped fixture is a ResultAwareFixture.
        Returns:
        true if it is
      • isFinalizationTestFixture

        public boolean isFinalizationTestFixture()
        Checks whether the wrapped fixture is a isFinalizationTestFixture().
        Returns:
        true if it is
      • performCustomComparation

        public ComparisonResult performCustomComparation​(Object anExpectedResult,
                                                         Object aFixtureResult,
                                                         String aMethodName,
                                                         String aPropertyName)
        Performs a custom comparation using the wrapped fixture, which must be a CustomComparatorFixture. Only usable if isCustomComparatorFixture() returns true.
        Parameters:
        anExpectedResult - the expected result
        aFixtureResult - the result actually returned by the fixture
        aMethodName - the name of the fixture method
        aPropertyName - the name of the result property to be compared (null if it's the default result)
        Returns:
        true if comparation was successful, false otherwise
      • determineCustomConversionTargetType

        public Class<?> determineCustomConversionTargetType​(Object aFixtureResult,
                                                            String aMethodName,
                                                            String aPropertyName)
        Returns the type to which the expected result (the data given in the test script) that corresponds to the given fixture result is to be converted. This can only be used for CustomComparatorAndConversionFixture instances, which can be checked via isCustomComparatorAndConversionFixture().
        Parameters:
        aFixtureResult - the result value returned by the fixture call
        aMethodName - the fixture method that was called
        aPropertyName - the property name that is to be compared (null if it's the default result)
        Returns:
        the desired target type. "null" chooses the default conversion, but note that this does NOT mean "the conversion that would have been used if the fixture was just a CustomComparatorFixture", but "the conversion that has the highest priority for the data type found in the script".
      • performValueToFormattedStringConversion

        public FormattedString performValueToFormattedStringConversion​(Object aValue,
                                                                       String aFixtureMethod,
                                                                       boolean aForceIntermediateMapFlag,
                                                                       ConversionContext aConversionContext)
        Converts the given value to a string. This method either calls the ValueConverter#convertValueToString(Object, ConversionContext) method or delegates the conversion to the contained fixture instance, if it does implement the CustomStringConversionFixture interface.
        Parameters:
        aValue - the value to convert
        aFixtureMethod - the fixture method that was called to return the given value
        aForceIntermediateMapFlag - whether the conversion should force the usage of an intermediate map (useful for bean types)
        aConversionContext - the conversion context to use (may be null if the default shall be used)
        Returns:
        the converted string
      • execute

        public Object execute​(Map<String,​Object> someParameters)
                       throws Throwable
        Executes the fixture method, using the given set of parameters.
        Parameters:
        someParameters - a map of parameters
        Returns:
        the resulting object
        Throws:
        Throwable
      • performNullCheck

        protected void performNullCheck​(FixtureParameter anAnnotation,
                                        Object aValue)
        Validates given parameter values to comply with the FixtureParameter.nullable() setting.
        Parameters:
        anAnnotation - the fixture parameter annotation setting the rules
        aValue - the parameter value
      • retrieveExtendedResults

        public List<ExtendedResultFixture.ExtendedResult> retrieveExtendedResults​(ExtendedResultFixture.FixtureInvocationResult anInvocationResult)
        Call ExtendedResultFixture#provideExtendedResults() on the fixture - if it is an extended result fixture - and return the extended results.
        Returns:
        the extended result list, or null if the fixture does not support the protocol or didn't return anything
      • announceTableTestResults

        public void announceTableTestResults​(ValueOrEnumValueOrOperationCollection aDefaultResult,
                                             List<ResultTableHeader> someResultHeaders)
        Invoke the ResultAwareFixture method for the case of a 'tabletest' type fixture invocation.
        Parameters:
        aDefaultResult - The default result as given in the test script
        someResultHeaders - A list of named results used by the test
      • announceTestResultsInternal

        protected void announceTestResultsInternal​(ValueOrEnumValueOrOperationCollection aDefaultResult,
                                                   Set<String> aNamedResultSet)
        Actually performs the test result announcement call.
        Parameters:
        aDefaultResult - The default result as given in the test script
        aNamedResultSet - A list of named results used by the test
      • runFinalizationTest

        public String runFinalizationTest()
        Executes the finalization test for FinalizationTestFixtures.
        Returns:
        null if successful, an error message otherwise