Class ParameterizedTestMethodContext


  • class ParameterizedTestMethodContext
    extends java.lang.Object
    Encapsulates access to the parameters of a parameterized test method and caches the converters and aggregators used to resolve them.
    Since:
    5.3
    • Constructor Detail

      • ParameterizedTestMethodContext

        ParameterizedTestMethodContext​(java.lang.reflect.Method testMethod)
    • Method Detail

      • isAggregator

        private static boolean isAggregator​(java.lang.reflect.Parameter parameter)
        Determine if the supplied Parameter is an aggregator (i.e., of type ArgumentsAccessor or annotated with AggregateWith).
        Returns:
        true if the parameter is an aggregator
      • hasPotentiallyValidSignature

        boolean hasPotentiallyValidSignature()
        Determine if the Method represented by this context has a potentially valid signature (i.e., formal parameter declarations) with regard to aggregators.

        This method takes a best-effort approach at enforcing the following policy for 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.
        Returns:
        true if the method has a potentially valid signature
      • getParameterCount

        int getParameterCount()
        Get the number of parameters of the Method represented by this context.
      • 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
      • hasAggregator

        boolean hasAggregator()
        Determine if the Method represented by this context declares at least one Parameter that is an aggregator.
        Returns:
        true if the method has an aggregator
      • isAggregator

        boolean isAggregator​(int parameterIndex)
        Determine if the Parameter with the supplied index is an aggregator (i.e., of type ArgumentsAccessor or annotated with AggregateWith).
        Returns:
        true if the parameter is an aggregator
      • indexOfFirstAggregator

        int indexOfFirstAggregator()
        Find the index of the first aggregator Parameter in the Method represented by this context.
        Returns:
        the index of the first aggregator, or -1 if not found
      • resolve

        java.lang.Object resolve​(org.junit.jupiter.api.extension.ParameterContext parameterContext,
                                 java.lang.Object[] arguments,
                                 int invocationIndex)
        Resolve the parameter for the supplied context using the supplied arguments.
      • parameterResolutionException

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