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

The following examples show how to use org.junit.jupiter.api.extension.ParameterContext#isAnnotated() . 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: FlowableEventExtension.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
@Override
public Object resolveParameter(ParameterContext parameterContext, ExtensionContext context) {
    FlowableEventTestHelper flowableTestHelper = getTestHelper(context);
    if (parameterContext.isAnnotated(EventDeploymentId.class)) {
        return flowableTestHelper.getDeploymentIdFromDeploymentAnnotation();
    }

    Class<?> parameterType = parameterContext.getParameter().getType();
    EventRegistryEngine eventRegistryEngine = flowableTestHelper.getEventRegistryEngine();
    if (parameterType.isInstance(eventRegistryEngine)) {
        return eventRegistryEngine;
    } else if (FlowableEventTestHelper.class.equals(parameterType)) {
        return flowableTestHelper;
    }

    try {
        return EventRegistryEngine.class.getDeclaredMethod("get" + parameterType.getSimpleName()).invoke(eventRegistryEngine);
    } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException ex) {
        throw new ParameterResolutionException("Could not find service " + parameterType, ex);
    }
}
 
Example 2
Source File: FlowableDmnExtension.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
@Override
public Object resolveParameter(ParameterContext parameterContext, ExtensionContext context) {
    FlowableDmnTestHelper flowableTestHelper = getTestHelper(context);
    if (parameterContext.isAnnotated(DmnDeploymentId.class)) {
        return flowableTestHelper.getDeploymentIdFromDeploymentAnnotation();
    }

    Class<?> parameterType = parameterContext.getParameter().getType();
    DmnEngine dmnEngine = flowableTestHelper.getDmnEngine();
    if (parameterType.isInstance(dmnEngine)) {
        return dmnEngine;
    } else if (FlowableDmnTestHelper.class.equals(parameterType)) {
        return flowableTestHelper;
    }

    try {
        return DmnEngine.class.getDeclaredMethod("get" + parameterType.getSimpleName()).invoke(dmnEngine);
    } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException ex) {
        throw new ParameterResolutionException("Could not find service " + parameterType, ex);
    }
}
 
Example 3
Source File: FlowableCmmnExtension.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
@Override
public Object resolveParameter(ParameterContext parameterContext, ExtensionContext context) {
    FlowableCmmnTestHelper flowableTestHelper = getTestHelper(context);
    if (parameterContext.isAnnotated(CmmnDeploymentId.class)) {
        return flowableTestHelper.getDeploymentIdFromDeploymentAnnotation();
    }

    Class<?> parameterType = parameterContext.getParameter().getType();
    CmmnEngine cmmnEngine = flowableTestHelper.getCmmnEngine();
    if (parameterType.isInstance(cmmnEngine)) {
        return cmmnEngine;
    } else if (FlowableCmmnTestHelper.class.equals(parameterType)) {
        return flowableTestHelper;
    }

    try {
        return CmmnEngine.class.getDeclaredMethod("get" + parameterType.getSimpleName()).invoke(cmmnEngine);
    } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException ex) {
        throw new ParameterResolutionException("Could not find service " + parameterType, ex);
    }
}
 
Example 4
Source File: FlowableFormExtension.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
@Override
public Object resolveParameter(ParameterContext parameterContext, ExtensionContext context) {
    FlowableFormTestHelper flowableTestHelper = getTestHelper(context);
    if (parameterContext.isAnnotated(FormDeploymentId.class)) {
        return flowableTestHelper.getDeploymentIdFromDeploymentAnnotation();
    }

    Class<?> parameterType = parameterContext.getParameter().getType();
    FormEngine formEngine = flowableTestHelper.getFormEngine();
    if (parameterType.isInstance(formEngine)) {
        return formEngine;
    } else if (FlowableFormTestHelper.class.equals(parameterType)) {
        return flowableTestHelper;
    }

    try {
        return FormEngine.class.getDeclaredMethod("get" + parameterType.getSimpleName()).invoke(formEngine);
    } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException ex) {
        throw new ParameterResolutionException("Could not find service " + parameterType, ex);
    }
}
 
Example 5
Source File: FlowableExtension.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
@Override
public Object resolveParameter(ParameterContext parameterContext, ExtensionContext context) {
    FlowableTestHelper flowableTestHelper = getTestHelper(context);
    if (parameterContext.isAnnotated(DeploymentId.class)) {
        return flowableTestHelper.getDeploymentIdFromDeploymentAnnotation();
    }

    Class<?> parameterType = parameterContext.getParameter().getType();
    ProcessEngine processEngine = flowableTestHelper.getProcessEngine();
    if (parameterType.isInstance(processEngine)) {
        return processEngine;
    } else if (FlowableTestHelper.class.equals(parameterType)) {
        return flowableTestHelper;
    } else if (FlowableMockSupport.class.equals(parameterType)) {
        return flowableTestHelper.getMockSupport();
    }

    try {
        return ProcessEngine.class.getDeclaredMethod("get" + parameterType.getSimpleName()).invoke(processEngine);
    } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException ex) {
        throw new ParameterResolutionException("Could not find service " + parameterType, ex);
    }
}
 
Example 6
Source File: ParameterHolder.java    From GitToolBox with Apache License 2.0 5 votes vote down vote up
boolean matches(ParameterContext parameterContext) {
  boolean typeMatch = type.isAssignableFrom(parameterContext.getParameter().getType());
  if (annotationType != null) {
    return typeMatch && parameterContext.isAnnotated(annotationType);
  }
  return typeMatch;
}
 
Example 7
Source File: InternalFlowableExtension.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public Object resolveParameter(ParameterContext parameterContext, ExtensionContext context) {
    if (parameterContext.isAnnotated(DeploymentId.class)) {
        return getStore(context).get(context.getUniqueId() + ANNOTATION_DEPLOYMENT_ID_KEY, String.class);
    }
    return getProcessEngine(context);
}
 
Example 8
Source File: InternalFlowableFormExtension.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public Object resolveParameter(ParameterContext parameterContext, ExtensionContext context) {
    if (parameterContext.isAnnotated(FormDeploymentId.class)) {
        return getStore(context).get(context.getUniqueId() + ANNOTATION_DEPLOYMENT_ID_KEY, String.class);
    }
    return getFormEngine(context);
}
 
Example 9
Source File: FlowableExtension.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
@Override
public boolean supportsParameter(ParameterContext parameterContext, ExtensionContext context) {
    Class<?> parameterType = parameterContext.getParameter().getType();
    return SUPPORTED_PARAMETERS.contains(parameterType) || FlowableTestHelper.class.equals(parameterType) || FlowableMockSupport.class.equals(parameterType)
        || parameterContext.isAnnotated(DeploymentId.class);
}
 
Example 10
Source File: FlowableEventExtension.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
@Override
public boolean supportsParameter(ParameterContext parameterContext, ExtensionContext context) {
    Class<?> parameterType = parameterContext.getParameter().getType();
    return SUPPORTED_PARAMETERS.contains(parameterType) || FlowableEventTestHelper.class.equals(parameterType)
        || parameterContext.isAnnotated(EventDeploymentId.class);
}
 
Example 11
Source File: FlowableFormExtension.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
@Override
public boolean supportsParameter(ParameterContext parameterContext, ExtensionContext context) {
    Class<?> parameterType = parameterContext.getParameter().getType();
    return SUPPORTED_PARAMETERS.contains(parameterType) || FlowableFormTestHelper.class.equals(parameterType)
        || parameterContext.isAnnotated(FormDeploymentId.class);
}
 
Example 12
Source File: InternalFlowableFormExtension.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
@Override
public boolean supportsParameter(ParameterContext parameterContext, ExtensionContext context) {
    Class<?> parameterType = parameterContext.getParameter().getType();
    return FormEngine.class.equals(parameterType) || parameterContext.isAnnotated(FormDeploymentId.class);
}
 
Example 13
Source File: RedisServerExtension.java    From incubator-tuweni with Apache License 2.0 4 votes vote down vote up
@Override
public boolean supportsParameter(ParameterContext parameterContext, ExtensionContext extensionContext)
    throws ParameterResolutionException {
  return Integer.class.equals(parameterContext.getParameter().getType())
      && parameterContext.isAnnotated(RedisPort.class);
}
 
Example 14
Source File: InternalFlowableExtension.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
@Override
public boolean supportsParameter(ParameterContext parameterContext, ExtensionContext context) {
    Class<?> parameterType = parameterContext.getParameter().getType();
    return ProcessEngine.class.equals(parameterType) || parameterContext.isAnnotated(DeploymentId.class);
}
 
Example 15
Source File: FlowableCmmnExtension.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
@Override
public boolean supportsParameter(ParameterContext parameterContext, ExtensionContext context) {
    Class<?> parameterType = parameterContext.getParameter().getType();
    return SUPPORTED_PARAMETERS.contains(parameterType) || FlowableCmmnTestHelper.class.equals(parameterType)
        || parameterContext.isAnnotated(CmmnDeploymentId.class);
}
 
Example 16
Source File: FlowableDmnExtension.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
@Override
public boolean supportsParameter(ParameterContext parameterContext, ExtensionContext context) {
    Class<?> parameterType = parameterContext.getParameter().getType();
    return SUPPORTED_PARAMETERS.contains(parameterType) || FlowableDmnTestHelper.class.equals(parameterType)
        || parameterContext.isAnnotated(DmnDeploymentId.class);
}
 
Example 17
Source File: RedisServerExtension.java    From cava with Apache License 2.0 4 votes vote down vote up
@Override
public boolean supportsParameter(ParameterContext parameterContext, ExtensionContext extensionContext)
    throws ParameterResolutionException {
  return Integer.class.equals(parameterContext.getParameter().getType())
      && parameterContext.isAnnotated(RedisPort.class);
}