Java Code Examples for org.junit.jupiter.api.extension.ParameterContext#getDeclaringExecutable()

The following examples show how to use org.junit.jupiter.api.extension.ParameterContext#getDeclaringExecutable() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WeldJunit5Extension.java    From weld-junit with Apache License 2.0 5 votes vote down vote up
@Override
public boolean supportsParameter(ParameterContext parameterContext, ExtensionContext extensionContext) throws ParameterResolutionException {
    // if weld container isn't up yet or if its not Method, we don't resolve it
    if (getContainerFromStore(extensionContext) == null || (!(parameterContext.getDeclaringExecutable() instanceof Method))) {
        return false;
    }
    List<Annotation> qualifiers = resolveQualifiers(parameterContext, getContainerFromStore(extensionContext).getBeanManager());
    // if we require explicit parameter injection (via global settings or annotation) and there are no qualifiers we don't resolve it
    if ((getExplicitInjectionInfoFromStore(extensionContext) || (methodRequiresExplicitParamInjection(parameterContext))) && qualifiers.isEmpty()) {
        return false;
    } else {
        return getContainerFromStore(extensionContext).select(parameterContext.getParameter().getType(), qualifiers.toArray(new Annotation[qualifiers.size()]))
                .isResolvable();
    }
}
 
Example 2
Source File: QuarkusTestExtension.java    From quarkus with Apache License 2.0 4 votes vote down vote up
/**
 * Return true if we need a parameter for constructor injection
 */
@Override
public boolean supportsParameter(ParameterContext parameterContext, ExtensionContext extensionContext)
        throws ParameterResolutionException {
    return parameterContext.getDeclaringExecutable() instanceof Constructor;
}