Search in sources :

Example 71 with Parameter

use of java.lang.reflect.Parameter in project junit-servers by mjeanroy.

the class JunitServerExtensionTest method verifySupportsParameter.

private void verifySupportsParameter(String methodName, Class<?> klass) throws Exception {
    final JunitServerExtension extension = new JunitServerExtension();
    final FixtureClass testInstance = new FixtureClass();
    final FakeExtensionContext context = new FakeExtensionContext(testInstance);
    extension.beforeAll(context);
    final Method method = getClass().getMethod(methodName, klass);
    final Parameter parameter = method.getParameters()[0];
    final ParameterContext parameterContext = new FakeParameterContext(parameter);
    assertThat(extension.supportsParameter(parameterContext, context)).isTrue();
}
Also used : FixtureClass(com.github.mjeanroy.junit.servers.utils.fixtures.FixtureClass) Parameter(java.lang.reflect.Parameter) ParameterContext(org.junit.jupiter.api.extension.ParameterContext) Method(java.lang.reflect.Method)

Example 72 with Parameter

use of java.lang.reflect.Parameter in project junit-servers by mjeanroy.

the class CaptureSystemOutExtension method supportsParameter.

@Override
public boolean supportsParameter(ParameterContext parameterContext, ExtensionContext extensionContext) throws ParameterResolutionException {
    Parameter parameter = parameterContext.getParameter();
    Class<?> parameterType = parameter.getType();
    return CaptureSystemOut.class.isAssignableFrom(parameterType);
}
Also used : Parameter(java.lang.reflect.Parameter)

Example 73 with Parameter

use of java.lang.reflect.Parameter in project junit-servers by mjeanroy.

the class WireMockExtension method supportsParameter.

@Override
public boolean supportsParameter(ParameterContext parameterContext, ExtensionContext extensionContext) throws ParameterResolutionException {
    Parameter parameter = parameterContext.getParameter();
    Class<?> parameterType = parameter.getType();
    return WireMockServer.class.isAssignableFrom(parameterType);
}
Also used : Parameter(java.lang.reflect.Parameter)

Example 74 with Parameter

use of java.lang.reflect.Parameter in project junit-servers by mjeanroy.

the class JunitServerExtension method supportsParameter.

@Override
public boolean supportsParameter(ParameterContext parameterContext, ExtensionContext extensionContext) throws ParameterResolutionException {
    final Parameter parameter = parameterContext.getParameter();
    final Class<?> parameterClass = parameter.getType();
    // Fast case: a perfect match.
    if (RESOLVERS.containsKey(parameterClass)) {
        return true;
    }
    for (Class<?> klass : RESOLVERS.keySet()) {
        if (klass.isAssignableFrom(parameterClass)) {
            return true;
        }
    }
    return false;
}
Also used : Parameter(java.lang.reflect.Parameter)

Example 75 with Parameter

use of java.lang.reflect.Parameter in project dbunit-plus by mjeanroy.

the class DbUnitExtension method supportsParameter.

@Override
public boolean supportsParameter(ParameterContext parameterContext, ExtensionContext extensionContext) throws ParameterResolutionException {
    final Parameter parameter = parameterContext.getParameter();
    final Class<?> parameterClass = parameter.getType();
    return Connection.class.isAssignableFrom(parameterClass);
}
Also used : Parameter(java.lang.reflect.Parameter)

Aggregations

Parameter (java.lang.reflect.Parameter)740 Method (java.lang.reflect.Method)266 ArrayList (java.util.ArrayList)136 Annotation (java.lang.annotation.Annotation)90 List (java.util.List)87 HashMap (java.util.HashMap)75 Type (java.lang.reflect.Type)74 Map (java.util.Map)70 Constructor (java.lang.reflect.Constructor)60 Test (org.junit.jupiter.api.Test)58 Arrays (java.util.Arrays)51 Executable (java.lang.reflect.Executable)50 InvocationTargetException (java.lang.reflect.InvocationTargetException)48 Field (java.lang.reflect.Field)44 Collectors (java.util.stream.Collectors)44 ParameterizedType (java.lang.reflect.ParameterizedType)42 Test (org.junit.Test)42 Optional (java.util.Optional)41 Set (java.util.Set)37 Modifier (java.lang.reflect.Modifier)29