Class ResolverFacade


  • class ResolverFacade
    extends java.lang.Object
    • Method Detail

      • create

        static ResolverFacade create​(java.lang.Class<?> clazz,
                                     java.util.List<java.lang.reflect.Field> fields)
      • create

        static ResolverFacade create​(java.lang.reflect.Method method,
                                     java.lang.annotation.Annotation annotation)
      • create

        private static ResolverFacade create​(java.lang.reflect.Executable executable,
                                             java.lang.annotation.Annotation annotation,
                                             int indexOffset)
        Create a new ResolverFacade for the supplied Executable.

        This method takes a best-effort approach at enforcing the following policy for parameterized class constructors and parameterized test methods that accept aggregators as arguments.

        1. zero or more indexed arguments come first.
        2. zero or more aggregators come next.
        3. zero or more arguments supplied by other ParameterResolver implementations come last.
      • isSupportedParameter

        boolean isSupportedParameter​(org.junit.jupiter.api.extension.ParameterContext parameterContext,
                                     EvaluatedArgumentSet arguments)
      • getParameterName

        java.util.Optional<java.lang.String> getParameterName​(int parameterIndex)
        Get the name of the parameter with the supplied index, if it is present and declared before the aggregators.
        Returns:
        an Optional containing the name of the parameter
      • determineConsumedArgumentLength

        int determineConsumedArgumentLength​(int totalLength)
        Determine the length of the arguments array that is considered consumed by the parameter declarations in this resolver.

        If an aggregator is present, all arguments are considered consumed. Otherwise, the consumed argument length is the minimum of the total length and the number of indexed parameter declarations.

      • determineConsumedArgumentCount

        int determineConsumedArgumentCount​(EvaluatedArgumentSet arguments)
        Determine the number of arguments that are considered consumed by the parameter declarations in this resolver.

        If an aggregator is present, all arguments are considered consumed. Otherwise, the consumed argument count, is the number of indexes that correspond to indexed parameter declarations.

      • resolve

        java.lang.Object resolve​(org.junit.jupiter.api.extension.ParameterContext parameterContext,
                                 org.junit.jupiter.api.extension.ExtensionContext extensionContext,
                                 EvaluatedArgumentSet arguments,
                                 int invocationIndex,
                                 ResolutionCache resolutionCache)
        Resolve the parameter for the supplied context using the supplied arguments.
      • resolveAndInjectFields

        void resolveAndInjectFields​(java.lang.Object testInstance,
                                    org.junit.jupiter.api.extension.ExtensionContext extensionContext,
                                    EvaluatedArgumentSet arguments,
                                    int invocationIndex,
                                    ResolutionCache resolutionCache)
      • getAllParameterDeclarations

        private java.util.stream.Stream<ParameterDeclaration> getAllParameterDeclarations()
      • resolve

        private java.lang.Object resolve​(ResolverFacade.ResolvableParameterDeclaration parameterDeclaration,
                                         org.junit.jupiter.api.extension.ExtensionContext extensionContext,
                                         EvaluatedArgumentSet arguments,
                                         int invocationIndex,
                                         java.util.Optional<org.junit.jupiter.api.extension.ParameterContext> parameterContext)
      • toLogicalIndex

        private int toLogicalIndex​(org.junit.jupiter.api.extension.ParameterContext parameterContext)
      • parameterName

        private static java.lang.String parameterName​(ParameterDeclaration actualDeclaration)
      • configurationErrorOrSuccess

        private static <T> T configurationErrorOrSuccess​(java.util.List<java.lang.String> errors,
                                                         java.util.function.Supplier<T> successfulResult)
      • validateIndexedParameters

        private static void validateIndexedParameters​(java.util.NavigableMap<java.lang.Integer,​java.util.List<ResolverFacade.FieldParameterDeclaration>> indexedParameters,
                                                      java.util.List<java.lang.String> errors)
      • validateIndexedParameterDeclarations

        private static void validateIndexedParameterDeclarations​(int index,
                                                                 java.util.List<ResolverFacade.FieldParameterDeclaration> declarations,
                                                                 java.util.List<java.lang.String> errors)
      • validateAggregatorParameters

        private static void validateAggregatorParameters​(java.util.Set<ResolverFacade.FieldParameterDeclaration> aggregatorParameters,
                                                         java.util.List<java.lang.String> errors)
      • parameterResolutionException

        private static org.junit.jupiter.api.extension.ParameterResolutionException parameterResolutionException​(java.lang.String message,
                                                                                                                 java.lang.Exception cause,
                                                                                                                 int index)