Package org.junit.jupiter.params
Class ParameterizedTestMethodContext
- java.lang.Object
-
- org.junit.jupiter.params.ParameterizedTestMethodContext
-
class ParameterizedTestMethodContext extends java.lang.ObjectEncapsulates access to the parameters of a parameterized test method and caches the converters and aggregators used to resolve them.- Since:
- 5.3
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static classParameterizedTestMethodContext.Aggregator(package private) static classParameterizedTestMethodContext.Converter(package private) static interfaceParameterizedTestMethodContext.Resolver(package private) static classParameterizedTestMethodContext.ResolverType
-
Field Summary
Fields Modifier and Type Field Description private java.lang.reflect.Parameter[]parametersprivate ParameterizedTestMethodContext.Resolver[]resolversprivate java.util.List<ParameterizedTestMethodContext.ResolverType>resolverTypes
-
Constructor Summary
Constructors Constructor Description ParameterizedTestMethodContext(java.lang.reflect.Method testMethod)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) intgetParameterCount()Get the number of parameters of theMethodrepresented by this context.(package private) java.util.Optional<java.lang.String>getParameterName(int parameterIndex)Get the name of theParameterwith the supplied index, if it is present and declared before the aggregators.private ParameterizedTestMethodContext.ResolvergetResolver(ParameterContext parameterContext)(package private) booleanhasAggregator()Determine if theMethodrepresented by this context declares at least oneParameterthat is an aggregator.(package private) booleanhasPotentiallyValidSignature()Determine if theMethodrepresented by this context has a potentially valid signature (i.e., formal parameter declarations) with regard to aggregators.(package private) intindexOfFirstAggregator()(package private) booleanisAggregator(int parameterIndex)Determine if theParameterwith the supplied index is an aggregator (i.e., of typeArgumentsAccessoror annotated withAggregateWith).private static booleanisAggregator(java.lang.reflect.Parameter parameter)Determine if the suppliedParameteris an aggregator (i.e., of typeArgumentsAccessoror annotated withAggregateWith).private static ParameterResolutionExceptionparameterResolutionException(java.lang.String message, java.lang.Exception cause, ParameterContext parameterContext)(package private) java.lang.Objectresolve(ParameterContext parameterContext, java.lang.Object[] arguments)Resolve the parameter for the supplied context using the supplied arguments.
-
-
-
Field Detail
-
parameters
private final java.lang.reflect.Parameter[] parameters
-
resolvers
private final ParameterizedTestMethodContext.Resolver[] resolvers
-
resolverTypes
private final java.util.List<ParameterizedTestMethodContext.ResolverType> resolverTypes
-
-
Method Detail
-
isAggregator
private static boolean isAggregator(java.lang.reflect.Parameter parameter)
Determine if the suppliedParameteris an aggregator (i.e., of typeArgumentsAccessoror annotated withAggregateWith).- Returns:
trueif the parameter is an aggregator
-
hasPotentiallyValidSignature
boolean hasPotentiallyValidSignature()
Determine if theMethodrepresented 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.
- zero or more indexed arguments come first.
- zero or more aggregators come next.
- zero or more arguments supplied by other
ParameterResolverimplementations come last.
- Returns:
trueif the method has a potentially valid signature
-
getParameterCount
int getParameterCount()
Get the number of parameters of theMethodrepresented by this context.
-
getParameterName
java.util.Optional<java.lang.String> getParameterName(int parameterIndex)
Get the name of theParameterwith the supplied index, if it is present and declared before the aggregators.- Returns:
- an
Optionalcontaining the name of the parameter
-
hasAggregator
boolean hasAggregator()
Determine if theMethodrepresented by this context declares at least oneParameterthat is an aggregator.- Returns:
trueif the method has an aggregator
-
isAggregator
boolean isAggregator(int parameterIndex)
Determine if theParameterwith the supplied index is an aggregator (i.e., of typeArgumentsAccessoror annotated withAggregateWith).- Returns:
trueif the parameter is an aggregator
-
indexOfFirstAggregator
int indexOfFirstAggregator()
- Returns:
- the index of the first aggregator, or
-1if not found
-
resolve
java.lang.Object resolve(ParameterContext parameterContext, java.lang.Object[] arguments)
Resolve the parameter for the supplied context using the supplied arguments.
-
getResolver
private ParameterizedTestMethodContext.Resolver getResolver(ParameterContext parameterContext)
-
parameterResolutionException
private static ParameterResolutionException parameterResolutionException(java.lang.String message, java.lang.Exception cause, ParameterContext parameterContext)
-
-