Class ProcessEngineExtension
- java.lang.Object
-
- org.camunda.bpm.engine.test.junit5.ProcessEngineExtension
-
- All Implemented Interfaces:
ProcessEngineServices
,org.junit.jupiter.api.extension.AfterAllCallback
,org.junit.jupiter.api.extension.AfterTestExecutionCallback
,org.junit.jupiter.api.extension.BeforeTestExecutionCallback
,org.junit.jupiter.api.extension.Extension
,org.junit.jupiter.api.extension.ParameterResolver
,org.junit.jupiter.api.extension.TestInstancePostProcessor
,org.junit.jupiter.api.extension.TestWatcher
public class ProcessEngineExtension extends java.lang.Object implements org.junit.jupiter.api.extension.TestWatcher, org.junit.jupiter.api.extension.TestInstancePostProcessor, org.junit.jupiter.api.extension.BeforeTestExecutionCallback, org.junit.jupiter.api.extension.AfterTestExecutionCallback, org.junit.jupiter.api.extension.AfterAllCallback, org.junit.jupiter.api.extension.ParameterResolver, ProcessEngineServices
Junit 5 Extension to create and inject aProcessEngine
into the test class.If you provide a
camunda.cfg.xml
file on the classpath. This file is used to configure the process engine.
Usage:@ExtendWith(ProcessEngineExtension.class)
public class YourTest { // provide a property where the extension can inject the process engine public ProcessEngine processEngine; ... }If you want to choose the
Usage:camunda.cfg.xml
file that is used in the test programmatically, you can register the extension directly and use the builder pattern to configure it.
Usage with configuration:@RegisterExtension
ProcessEngineExtension extension = ProcessEngineExtension.builder() .configurationResource("myConfigurationFile.xml") .build();}You can declare a deployment with the
Deployment
annotation. This base class will make sure that this deployment gets deployed before the setUp andcascade deleted
after the tearDown.If you need the history service for your tests then you can specify the required history level of the test method or class, using the
RequiredHistoryLevel
annotation. If the current history level of the process engine is lower than the specified one then the test is skipped.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.List<java.lang.String>
additionalDeployments
protected AuthorizationService
authorizationService
protected CaseService
caseService
protected java.lang.String
configurationResource
protected DecisionService
decisionService
protected java.lang.String
deploymentId
protected boolean
ensureCleanAfterTest
protected ExternalTaskService
externalTaskService
protected FilterService
filterService
protected FormService
formService
protected HistoryService
historyService
protected IdentityService
identityService
protected static org.slf4j.Logger
LOG
protected ManagementService
managementService
protected ProcessEngine
processEngine
protected ProcessEngineConfigurationImpl
processEngineConfiguration
protected RepositoryService
repositoryService
protected RuntimeService
runtimeService
protected TaskService
taskService
-
Constructor Summary
Constructors Constructor Description ProcessEngineExtension()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
afterAll(org.junit.jupiter.api.extension.ExtensionContext context)
void
afterTestExecution(org.junit.jupiter.api.extension.ExtensionContext context)
void
beforeTestExecution(org.junit.jupiter.api.extension.ExtensionContext context)
ProcessEngineExtension
build()
static ProcessEngineExtension
builder()
protected void
clearServiceReferences()
ProcessEngineExtension
configurationResource(java.lang.String configurationResource)
ProcessEngineExtension
ensureCleanAfterTest(boolean ensureCleanAfterTest)
AuthorizationService
getAuthorizationService()
Returns the process engine'sAuthorizationService
.CaseService
getCaseService()
Returns the engine'sCaseService
.java.lang.String
getConfigurationResource()
DecisionService
getDecisionService()
Returns the engine'sDecisionService
.java.lang.String
getDeploymentId()
ExternalTaskService
getExternalTaskService()
Returns the engine'sExternalTaskService
.FilterService
getFilterService()
Returns the engine'sFilterService
.FormService
getFormService()
Returns the process engine'sFormService
.HistoryService
getHistoryService()
Returns the process engine'sHistoryService
.IdentityService
getIdentityService()
Returns the process engine'sIdentityService
.ManagementService
getManagementService()
Returns the process engine'sManagementService
.ProcessEngine
getProcessEngine()
ProcessEngineConfigurationImpl
getProcessEngineConfiguration()
RepositoryService
getRepositoryService()
Returns the process engine'sRepositoryService
.RuntimeService
getRuntimeService()
Returns the process engine'sRuntimeService
.TaskService
getTaskService()
Returns the process engine'sTaskService
.protected java.util.function.Supplier<java.lang.IllegalStateException>
illegalStateException(java.lang.String msg)
protected void
initializeProcessEngine()
protected void
initializeServices()
protected void
inject(java.lang.Object instance, java.lang.reflect.Field field)
boolean
isEnsureCleanAfterTest()
ProcessEngineExtension
manageDeployment(Deployment deployment)
void
postProcessTestInstance(java.lang.Object testInstance, org.junit.jupiter.api.extension.ExtensionContext context)
java.lang.Object
resolveParameter(org.junit.jupiter.api.extension.ParameterContext parameterContext, org.junit.jupiter.api.extension.ExtensionContext extensionContext)
void
setAuthorizationService(AuthorizationService authorizationService)
void
setCaseService(CaseService caseService)
void
setConfigurationResource(java.lang.String configurationResource)
void
setCurrentTime(java.util.Date currentTime)
void
setDecisionService(DecisionService decisionService)
void
setEnsureCleanAfterTest(boolean ensureCleanAfterTest)
void
setExternalTaskService(ExternalTaskService externalTaskService)
void
setFilterService(FilterService filterService)
void
setFormService(FormService formService)
void
setHistoryService(HistoryService historyService)
void
setIdentityService(IdentityService identityService)
void
setManagementService(ManagementService managementService)
void
setProcessEngine(ProcessEngine processEngine)
void
setProcessEngineConfiguration(ProcessEngineConfigurationImpl processEngineConfiguration)
void
setRepositoryService(RepositoryService repositoryService)
void
setRuntimeService(RuntimeService runtimeService)
void
setTaskService(TaskService taskService)
boolean
supportsParameter(org.junit.jupiter.api.extension.ParameterContext parameterContext, org.junit.jupiter.api.extension.ExtensionContext extensionContext)
ProcessEngineExtension
useProcessEngine(ProcessEngine engine)
-
-
-
Field Detail
-
LOG
protected static final org.slf4j.Logger LOG
-
processEngine
protected ProcessEngine processEngine
-
processEngineConfiguration
protected ProcessEngineConfigurationImpl processEngineConfiguration
-
repositoryService
protected RepositoryService repositoryService
-
runtimeService
protected RuntimeService runtimeService
-
taskService
protected TaskService taskService
-
historyService
protected HistoryService historyService
-
identityService
protected IdentityService identityService
-
managementService
protected ManagementService managementService
-
formService
protected FormService formService
-
filterService
protected FilterService filterService
-
authorizationService
protected AuthorizationService authorizationService
-
caseService
protected CaseService caseService
-
externalTaskService
protected ExternalTaskService externalTaskService
-
decisionService
protected DecisionService decisionService
-
configurationResource
protected java.lang.String configurationResource
-
deploymentId
protected java.lang.String deploymentId
-
ensureCleanAfterTest
protected boolean ensureCleanAfterTest
-
additionalDeployments
protected java.util.List<java.lang.String> additionalDeployments
-
-
Method Detail
-
initializeProcessEngine
protected void initializeProcessEngine()
-
initializeServices
protected void initializeServices()
-
clearServiceReferences
protected void clearServiceReferences()
-
supportsParameter
public boolean supportsParameter(org.junit.jupiter.api.extension.ParameterContext parameterContext, org.junit.jupiter.api.extension.ExtensionContext extensionContext) throws org.junit.jupiter.api.extension.ParameterResolutionException
- Specified by:
supportsParameter
in interfaceorg.junit.jupiter.api.extension.ParameterResolver
- Throws:
org.junit.jupiter.api.extension.ParameterResolutionException
-
resolveParameter
public java.lang.Object resolveParameter(org.junit.jupiter.api.extension.ParameterContext parameterContext, org.junit.jupiter.api.extension.ExtensionContext extensionContext) throws org.junit.jupiter.api.extension.ParameterResolutionException
- Specified by:
resolveParameter
in interfaceorg.junit.jupiter.api.extension.ParameterResolver
- Throws:
org.junit.jupiter.api.extension.ParameterResolutionException
-
beforeTestExecution
public void beforeTestExecution(org.junit.jupiter.api.extension.ExtensionContext context)
- Specified by:
beforeTestExecution
in interfaceorg.junit.jupiter.api.extension.BeforeTestExecutionCallback
-
afterTestExecution
public void afterTestExecution(org.junit.jupiter.api.extension.ExtensionContext context)
- Specified by:
afterTestExecution
in interfaceorg.junit.jupiter.api.extension.AfterTestExecutionCallback
-
afterAll
public void afterAll(org.junit.jupiter.api.extension.ExtensionContext context) throws java.lang.Exception
- Specified by:
afterAll
in interfaceorg.junit.jupiter.api.extension.AfterAllCallback
- Throws:
java.lang.Exception
-
postProcessTestInstance
public void postProcessTestInstance(java.lang.Object testInstance, org.junit.jupiter.api.extension.ExtensionContext context)
- Specified by:
postProcessTestInstance
in interfaceorg.junit.jupiter.api.extension.TestInstancePostProcessor
-
builder
public static ProcessEngineExtension builder()
-
configurationResource
public ProcessEngineExtension configurationResource(java.lang.String configurationResource)
-
useProcessEngine
public ProcessEngineExtension useProcessEngine(ProcessEngine engine)
-
ensureCleanAfterTest
public ProcessEngineExtension ensureCleanAfterTest(boolean ensureCleanAfterTest)
-
manageDeployment
public ProcessEngineExtension manageDeployment(Deployment deployment)
-
build
public ProcessEngineExtension build()
-
illegalStateException
protected java.util.function.Supplier<java.lang.IllegalStateException> illegalStateException(java.lang.String msg)
-
inject
protected void inject(java.lang.Object instance, java.lang.reflect.Field field)
-
setCurrentTime
public void setCurrentTime(java.util.Date currentTime)
-
getProcessEngine
public ProcessEngine getProcessEngine()
-
setProcessEngine
public void setProcessEngine(ProcessEngine processEngine)
-
getConfigurationResource
public java.lang.String getConfigurationResource()
-
getProcessEngineConfiguration
public ProcessEngineConfigurationImpl getProcessEngineConfiguration()
-
getRepositoryService
public RepositoryService getRepositoryService()
Description copied from interface:ProcessEngineServices
Returns the process engine'sRepositoryService
.- Specified by:
getRepositoryService
in interfaceProcessEngineServices
- Returns:
- the
RepositoryService
object.
-
setRepositoryService
public void setRepositoryService(RepositoryService repositoryService)
-
getRuntimeService
public RuntimeService getRuntimeService()
Description copied from interface:ProcessEngineServices
Returns the process engine'sRuntimeService
.- Specified by:
getRuntimeService
in interfaceProcessEngineServices
- Returns:
- the
RuntimeService
object.
-
setRuntimeService
public void setRuntimeService(RuntimeService runtimeService)
-
getTaskService
public TaskService getTaskService()
Description copied from interface:ProcessEngineServices
Returns the process engine'sTaskService
.- Specified by:
getTaskService
in interfaceProcessEngineServices
- Returns:
- the
TaskService
object.
-
setTaskService
public void setTaskService(TaskService taskService)
-
getHistoryService
public HistoryService getHistoryService()
Description copied from interface:ProcessEngineServices
Returns the process engine'sHistoryService
.- Specified by:
getHistoryService
in interfaceProcessEngineServices
- Returns:
- the
HistoryService
object.
-
setHistoryService
public void setHistoryService(HistoryService historyService)
-
getIdentityService
public IdentityService getIdentityService()
Description copied from interface:ProcessEngineServices
Returns the process engine'sIdentityService
.- Specified by:
getIdentityService
in interfaceProcessEngineServices
- Returns:
- the
IdentityService
object.
-
setIdentityService
public void setIdentityService(IdentityService identityService)
-
getManagementService
public ManagementService getManagementService()
Description copied from interface:ProcessEngineServices
Returns the process engine'sManagementService
.- Specified by:
getManagementService
in interfaceProcessEngineServices
- Returns:
- the
ManagementService
object.
-
setManagementService
public void setManagementService(ManagementService managementService)
-
getFormService
public FormService getFormService()
Description copied from interface:ProcessEngineServices
Returns the process engine'sFormService
.- Specified by:
getFormService
in interfaceProcessEngineServices
- Returns:
- the
FormService
object.
-
setFormService
public void setFormService(FormService formService)
-
getFilterService
public FilterService getFilterService()
Description copied from interface:ProcessEngineServices
Returns the engine'sFilterService
.- Specified by:
getFilterService
in interfaceProcessEngineServices
- Returns:
- the
FilterService
object.
-
setFilterService
public void setFilterService(FilterService filterService)
-
getAuthorizationService
public AuthorizationService getAuthorizationService()
Description copied from interface:ProcessEngineServices
Returns the process engine'sAuthorizationService
.- Specified by:
getAuthorizationService
in interfaceProcessEngineServices
- Returns:
- the
AuthorizationService
object.
-
setAuthorizationService
public void setAuthorizationService(AuthorizationService authorizationService)
-
getCaseService
public CaseService getCaseService()
Description copied from interface:ProcessEngineServices
Returns the engine'sCaseService
.- Specified by:
getCaseService
in interfaceProcessEngineServices
- Returns:
- the
CaseService
object.
-
setCaseService
public void setCaseService(CaseService caseService)
-
getExternalTaskService
public ExternalTaskService getExternalTaskService()
Description copied from interface:ProcessEngineServices
Returns the engine'sExternalTaskService
.- Specified by:
getExternalTaskService
in interfaceProcessEngineServices
- Returns:
- the
ExternalTaskService
object.
-
setExternalTaskService
public void setExternalTaskService(ExternalTaskService externalTaskService)
-
getDecisionService
public DecisionService getDecisionService()
Description copied from interface:ProcessEngineServices
Returns the engine'sDecisionService
.- Specified by:
getDecisionService
in interfaceProcessEngineServices
- Returns:
- the
DecisionService
object.
-
setDecisionService
public void setDecisionService(DecisionService decisionService)
-
setProcessEngineConfiguration
public void setProcessEngineConfiguration(ProcessEngineConfigurationImpl processEngineConfiguration)
-
setConfigurationResource
public void setConfigurationResource(java.lang.String configurationResource)
-
getDeploymentId
public java.lang.String getDeploymentId()
-
isEnsureCleanAfterTest
public boolean isEnsureCleanAfterTest()
-
setEnsureCleanAfterTest
public void setEnsureCleanAfterTest(boolean ensureCleanAfterTest)
-
-