Class ExecutableInvoker
java.lang.Object
org.junit.jupiter.engine.execution.ExecutableInvoker
ExecutableInvoker encapsulates the invocation of a
Executable (i.e., method or constructor),
including support for dynamic resolution of method parameters via
ParameterResolvers.- Since:
- 5.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final InvocationInterceptorChainprivate static final Logger -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static StringasLabel(Executable executable) <T> Tinvoke(Constructor<T> constructor, Optional<Object> outerInstance, ExtensionContext extensionContext, ExtensionRegistry extensionRegistry, ExecutableInvoker.ReflectiveInterceptorCall<Constructor<T>, T> interceptorCall) Invoke the supplied constructor with the supplied outer instance and dynamic parameter resolution.<T> Tinvoke(Method method, Object target, ExtensionContext extensionContext, ExtensionRegistry extensionRegistry, ExecutableInvoker.ReflectiveInterceptorCall<Method, T> interceptorCall) Invoke the suppliedstaticmethod with dynamic parameter resolution.private <E extends Executable,T>
Tinvoke(InvocationInterceptor.Invocation<T> originalInvocation, ReflectiveInvocationContext<E> invocationContext, ExtensionContext extensionContext, ExtensionRegistry extensionRegistry, ExecutableInvoker.ReflectiveInterceptorCall<E, T> call) private ObjectresolveParameter(ParameterContext parameterContext, Executable executable, ExtensionContext extensionContext, ExtensionRegistry extensionRegistry) private Object[]resolveParameters(Executable executable, Optional<Object> target, Optional<Object> outerInstance, ExtensionContext extensionContext, ExtensionRegistry extensionRegistry) Resolve the array of parameters for the supplied executable, target, and outer instance.private Object[]resolveParameters(Method method, Optional<Object> target, ExtensionContext extensionContext, ExtensionRegistry extensionRegistry) Resolve the array of parameters for the supplied method and target.private voidvalidateResolvedType(Parameter parameter, Object value, Executable executable, ParameterResolver resolver)
-
Field Details
-
logger
-
interceptorChain
-
-
Constructor Details
-
ExecutableInvoker
public ExecutableInvoker()
-
-
Method Details
-
invoke
public <T> T invoke(Constructor<T> constructor, Optional<Object> outerInstance, ExtensionContext extensionContext, ExtensionRegistry extensionRegistry, ExecutableInvoker.ReflectiveInterceptorCall<Constructor<T>, T> interceptorCall) Invoke the supplied constructor with the supplied outer instance and dynamic parameter resolution.This method should only be used to invoke the constructor for an inner class.
- Parameters:
constructor- the constructor to invoke and resolve parameters forouterInstance- the outer instance to supply as the first argument to the constructor; empty, for top-level classesextensionContext- the currentExtensionContextextensionRegistry- theExtensionRegistryto retrieveParameterResolversfrominterceptorCall- the call for intercepting this constructor invocation via all registered interceptors
-
invoke
public <T> T invoke(Method method, Object target, ExtensionContext extensionContext, ExtensionRegistry extensionRegistry, ExecutableInvoker.ReflectiveInterceptorCall<Method, T> interceptorCall) Invoke the suppliedstaticmethod with dynamic parameter resolution.- Parameters:
method- the method to invoke and resolve parameters forextensionContext- the currentExtensionContextextensionRegistry- theExtensionRegistryto retrieveParameterResolversfrominterceptorCall- the call for intercepting this method invocation via all registered interceptors
-
invoke
private <E extends Executable,T> T invoke(InvocationInterceptor.Invocation<T> originalInvocation, ReflectiveInvocationContext<E> invocationContext, ExtensionContext extensionContext, ExtensionRegistry extensionRegistry, ExecutableInvoker.ReflectiveInterceptorCall<E, T> call) -
resolveParameters
private Object[] resolveParameters(Method method, Optional<Object> target, ExtensionContext extensionContext, ExtensionRegistry extensionRegistry) Resolve the array of parameters for the supplied method and target.- Parameters:
method- the method for which to resolve parameterstarget- anOptionalcontaining the target on which the executable will be invoked; nevernullbut should be empty for static methods and constructorsextensionContext- the currentExtensionContextextensionRegistry- theExtensionRegistryto retrieveParameterResolversfrom- Returns:
- the array of Objects to be used as parameters in the executable
invocation; never
nullthough potentially empty
-
resolveParameters
private Object[] resolveParameters(Executable executable, Optional<Object> target, Optional<Object> outerInstance, ExtensionContext extensionContext, ExtensionRegistry extensionRegistry) Resolve the array of parameters for the supplied executable, target, and outer instance.- Parameters:
executable- the executable for which to resolve parameterstarget- anOptionalcontaining the target on which the executable will be invoked; nevernullbut should be empty for static methods and constructorsouterInstance- the outer instance that will be supplied as the first argument to a constructor for an inner class; should benullfor methods and constructors for top-level or static classesextensionContext- the currentExtensionContextextensionRegistry- theExtensionRegistryto retrieveParameterResolversfrom- Returns:
- the array of Objects to be used as parameters in the executable
invocation; never
nullthough potentially empty
-
resolveParameter
private Object resolveParameter(ParameterContext parameterContext, Executable executable, ExtensionContext extensionContext, ExtensionRegistry extensionRegistry) -
validateResolvedType
private void validateResolvedType(Parameter parameter, Object value, Executable executable, ParameterResolver resolver) -
asLabel
-