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 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 List<String>
additionalDeployments
protected AuthorizationService
authorizationService
protected CaseService
caseService
protected String
configurationResource
protected DecisionService
decisionService
protected 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
-
-
-
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 String configurationResource
-
deploymentId
protected String deploymentId
-
ensureCleanAfterTest
protected boolean ensureCleanAfterTest
-
-
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 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 Exception
- Specified by:
afterAll
in interfaceorg.junit.jupiter.api.extension.AfterAllCallback
- Throws:
Exception
-
postProcessTestInstance
public void postProcessTestInstance(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(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 Supplier<IllegalStateException> illegalStateException(String msg)
-
setCurrentTime
public void setCurrentTime(Date currentTime)
-
getProcessEngine
public ProcessEngine getProcessEngine()
-
setProcessEngine
public void setProcessEngine(ProcessEngine processEngine)
-
getConfigurationResource
public 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(String configurationResource)
-
getDeploymentId
public String getDeploymentId()
-
isEnsureCleanAfterTest
public boolean isEnsureCleanAfterTest()
-
setEnsureCleanAfterTest
public void setEnsureCleanAfterTest(boolean ensureCleanAfterTest)
-
-