Class ProcessEngineExtension
- java.lang.Object
-
- org.camunda.bpm.engine.test.junit5.ProcessEngineExtension
-
- All Implemented Interfaces:
org.camunda.bpm.engine.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, org.camunda.bpm.engine.ProcessEngineServices
Junit 5 Extension to create and inject aProcessEngineinto the test class.If you provide a
camunda.cfg.xmlfile 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.xmlfile that is used in the test programmatically, you can register the extension directly and use the builder pattern to configure it.
Usage with configuration:@RegisterExtensionProcessEngineExtension extension = ProcessEngineExtension.builder() .configurationResource("myConfigurationFile.xml") .build();}You can declare a deployment with the
Deploymentannotation. This base class will make sure that this deployment gets deployed before the setUp andcascade deletedafter 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
RequiredHistoryLevelannotation. 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>additionalDeploymentsprotected org.camunda.bpm.engine.AuthorizationServiceauthorizationServiceprotected org.camunda.bpm.engine.CaseServicecaseServiceprotected StringconfigurationResourceprotected org.camunda.bpm.engine.DecisionServicedecisionServiceprotected StringdeploymentIdprotected booleanensureCleanAfterTestprotected org.camunda.bpm.engine.ExternalTaskServiceexternalTaskServiceprotected org.camunda.bpm.engine.FilterServicefilterServiceprotected org.camunda.bpm.engine.FormServiceformServiceprotected org.camunda.bpm.engine.HistoryServicehistoryServiceprotected org.camunda.bpm.engine.IdentityServiceidentityServiceprotected static org.slf4j.LoggerLOGprotected org.camunda.bpm.engine.ManagementServicemanagementServiceprotected org.camunda.bpm.engine.ProcessEngineprocessEngineprotected org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImplprocessEngineConfigurationprotected org.camunda.bpm.engine.RepositoryServicerepositoryServiceprotected org.camunda.bpm.engine.RuntimeServiceruntimeServiceprotected org.camunda.bpm.engine.TaskServicetaskService
-
Constructor Summary
Constructors Constructor Description ProcessEngineExtension()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidafterAll(org.junit.jupiter.api.extension.ExtensionContext context)voidafterTestExecution(org.junit.jupiter.api.extension.ExtensionContext context)voidbeforeTestExecution(org.junit.jupiter.api.extension.ExtensionContext context)ProcessEngineExtensionbuild()static ProcessEngineExtensionbuilder()protected voidclearServiceReferences()ProcessEngineExtensionconfigurationResource(String configurationResource)ProcessEngineExtensionensureCleanAfterTest(boolean ensureCleanAfterTest)org.camunda.bpm.engine.AuthorizationServicegetAuthorizationService()org.camunda.bpm.engine.CaseServicegetCaseService()StringgetConfigurationResource()org.camunda.bpm.engine.DecisionServicegetDecisionService()StringgetDeploymentId()org.camunda.bpm.engine.ExternalTaskServicegetExternalTaskService()org.camunda.bpm.engine.FilterServicegetFilterService()org.camunda.bpm.engine.FormServicegetFormService()org.camunda.bpm.engine.HistoryServicegetHistoryService()org.camunda.bpm.engine.IdentityServicegetIdentityService()org.camunda.bpm.engine.ManagementServicegetManagementService()org.camunda.bpm.engine.ProcessEnginegetProcessEngine()org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImplgetProcessEngineConfiguration()org.camunda.bpm.engine.RepositoryServicegetRepositoryService()org.camunda.bpm.engine.RuntimeServicegetRuntimeService()org.camunda.bpm.engine.TaskServicegetTaskService()protected Supplier<IllegalStateException>illegalStateException(String msg)protected voidinitializeProcessEngine()protected voidinitializeServices()protected voidinject(Object instance, Field field)booleanisEnsureCleanAfterTest()ProcessEngineExtensionmanageDeployment(org.camunda.bpm.engine.repository.Deployment deployment)voidpostProcessTestInstance(Object testInstance, org.junit.jupiter.api.extension.ExtensionContext context)ObjectresolveParameter(org.junit.jupiter.api.extension.ParameterContext parameterContext, org.junit.jupiter.api.extension.ExtensionContext extensionContext)voidsetAuthorizationService(org.camunda.bpm.engine.AuthorizationService authorizationService)voidsetCaseService(org.camunda.bpm.engine.CaseService caseService)voidsetConfigurationResource(String configurationResource)voidsetCurrentTime(Date currentTime)voidsetDecisionService(org.camunda.bpm.engine.DecisionService decisionService)voidsetEnsureCleanAfterTest(boolean ensureCleanAfterTest)voidsetExternalTaskService(org.camunda.bpm.engine.ExternalTaskService externalTaskService)voidsetFilterService(org.camunda.bpm.engine.FilterService filterService)voidsetFormService(org.camunda.bpm.engine.FormService formService)voidsetHistoryService(org.camunda.bpm.engine.HistoryService historyService)voidsetIdentityService(org.camunda.bpm.engine.IdentityService identityService)voidsetManagementService(org.camunda.bpm.engine.ManagementService managementService)voidsetProcessEngine(org.camunda.bpm.engine.ProcessEngine processEngine)voidsetProcessEngineConfiguration(org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl processEngineConfiguration)voidsetRepositoryService(org.camunda.bpm.engine.RepositoryService repositoryService)voidsetRuntimeService(org.camunda.bpm.engine.RuntimeService runtimeService)voidsetTaskService(org.camunda.bpm.engine.TaskService taskService)booleansupportsParameter(org.junit.jupiter.api.extension.ParameterContext parameterContext, org.junit.jupiter.api.extension.ExtensionContext extensionContext)ProcessEngineExtensionuseProcessEngine(org.camunda.bpm.engine.ProcessEngine engine)
-
-
-
Field Detail
-
LOG
protected static final org.slf4j.Logger LOG
-
processEngine
protected org.camunda.bpm.engine.ProcessEngine processEngine
-
processEngineConfiguration
protected org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl processEngineConfiguration
-
repositoryService
protected org.camunda.bpm.engine.RepositoryService repositoryService
-
runtimeService
protected org.camunda.bpm.engine.RuntimeService runtimeService
-
taskService
protected org.camunda.bpm.engine.TaskService taskService
-
historyService
protected org.camunda.bpm.engine.HistoryService historyService
-
identityService
protected org.camunda.bpm.engine.IdentityService identityService
-
managementService
protected org.camunda.bpm.engine.ManagementService managementService
-
formService
protected org.camunda.bpm.engine.FormService formService
-
filterService
protected org.camunda.bpm.engine.FilterService filterService
-
authorizationService
protected org.camunda.bpm.engine.AuthorizationService authorizationService
-
caseService
protected org.camunda.bpm.engine.CaseService caseService
-
externalTaskService
protected org.camunda.bpm.engine.ExternalTaskService externalTaskService
-
decisionService
protected org.camunda.bpm.engine.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:
supportsParameterin 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:
resolveParameterin 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:
beforeTestExecutionin interfaceorg.junit.jupiter.api.extension.BeforeTestExecutionCallback
-
afterTestExecution
public void afterTestExecution(org.junit.jupiter.api.extension.ExtensionContext context)
- Specified by:
afterTestExecutionin interfaceorg.junit.jupiter.api.extension.AfterTestExecutionCallback
-
afterAll
public void afterAll(org.junit.jupiter.api.extension.ExtensionContext context) throws Exception- Specified by:
afterAllin interfaceorg.junit.jupiter.api.extension.AfterAllCallback- Throws:
Exception
-
postProcessTestInstance
public void postProcessTestInstance(Object testInstance, org.junit.jupiter.api.extension.ExtensionContext context)
- Specified by:
postProcessTestInstancein interfaceorg.junit.jupiter.api.extension.TestInstancePostProcessor
-
builder
public static ProcessEngineExtension builder()
-
configurationResource
public ProcessEngineExtension configurationResource(String configurationResource)
-
useProcessEngine
public ProcessEngineExtension useProcessEngine(org.camunda.bpm.engine.ProcessEngine engine)
-
ensureCleanAfterTest
public ProcessEngineExtension ensureCleanAfterTest(boolean ensureCleanAfterTest)
-
manageDeployment
public ProcessEngineExtension manageDeployment(org.camunda.bpm.engine.repository.Deployment deployment)
-
build
public ProcessEngineExtension build()
-
illegalStateException
protected Supplier<IllegalStateException> illegalStateException(String msg)
-
setCurrentTime
public void setCurrentTime(Date currentTime)
-
getProcessEngine
public org.camunda.bpm.engine.ProcessEngine getProcessEngine()
-
setProcessEngine
public void setProcessEngine(org.camunda.bpm.engine.ProcessEngine processEngine)
-
getConfigurationResource
public String getConfigurationResource()
-
getProcessEngineConfiguration
public org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl getProcessEngineConfiguration()
-
getRepositoryService
public org.camunda.bpm.engine.RepositoryService getRepositoryService()
- Specified by:
getRepositoryServicein interfaceorg.camunda.bpm.engine.ProcessEngineServices
-
setRepositoryService
public void setRepositoryService(org.camunda.bpm.engine.RepositoryService repositoryService)
-
getRuntimeService
public org.camunda.bpm.engine.RuntimeService getRuntimeService()
- Specified by:
getRuntimeServicein interfaceorg.camunda.bpm.engine.ProcessEngineServices
-
setRuntimeService
public void setRuntimeService(org.camunda.bpm.engine.RuntimeService runtimeService)
-
getTaskService
public org.camunda.bpm.engine.TaskService getTaskService()
- Specified by:
getTaskServicein interfaceorg.camunda.bpm.engine.ProcessEngineServices
-
setTaskService
public void setTaskService(org.camunda.bpm.engine.TaskService taskService)
-
getHistoryService
public org.camunda.bpm.engine.HistoryService getHistoryService()
- Specified by:
getHistoryServicein interfaceorg.camunda.bpm.engine.ProcessEngineServices
-
setHistoryService
public void setHistoryService(org.camunda.bpm.engine.HistoryService historyService)
-
getIdentityService
public org.camunda.bpm.engine.IdentityService getIdentityService()
- Specified by:
getIdentityServicein interfaceorg.camunda.bpm.engine.ProcessEngineServices
-
setIdentityService
public void setIdentityService(org.camunda.bpm.engine.IdentityService identityService)
-
getManagementService
public org.camunda.bpm.engine.ManagementService getManagementService()
- Specified by:
getManagementServicein interfaceorg.camunda.bpm.engine.ProcessEngineServices
-
setManagementService
public void setManagementService(org.camunda.bpm.engine.ManagementService managementService)
-
getFormService
public org.camunda.bpm.engine.FormService getFormService()
- Specified by:
getFormServicein interfaceorg.camunda.bpm.engine.ProcessEngineServices
-
setFormService
public void setFormService(org.camunda.bpm.engine.FormService formService)
-
getFilterService
public org.camunda.bpm.engine.FilterService getFilterService()
- Specified by:
getFilterServicein interfaceorg.camunda.bpm.engine.ProcessEngineServices
-
setFilterService
public void setFilterService(org.camunda.bpm.engine.FilterService filterService)
-
getAuthorizationService
public org.camunda.bpm.engine.AuthorizationService getAuthorizationService()
- Specified by:
getAuthorizationServicein interfaceorg.camunda.bpm.engine.ProcessEngineServices
-
setAuthorizationService
public void setAuthorizationService(org.camunda.bpm.engine.AuthorizationService authorizationService)
-
getCaseService
public org.camunda.bpm.engine.CaseService getCaseService()
- Specified by:
getCaseServicein interfaceorg.camunda.bpm.engine.ProcessEngineServices
-
setCaseService
public void setCaseService(org.camunda.bpm.engine.CaseService caseService)
-
getExternalTaskService
public org.camunda.bpm.engine.ExternalTaskService getExternalTaskService()
- Specified by:
getExternalTaskServicein interfaceorg.camunda.bpm.engine.ProcessEngineServices
-
setExternalTaskService
public void setExternalTaskService(org.camunda.bpm.engine.ExternalTaskService externalTaskService)
-
getDecisionService
public org.camunda.bpm.engine.DecisionService getDecisionService()
- Specified by:
getDecisionServicein interfaceorg.camunda.bpm.engine.ProcessEngineServices
-
setDecisionService
public void setDecisionService(org.camunda.bpm.engine.DecisionService decisionService)
-
setProcessEngineConfiguration
public void setProcessEngineConfiguration(org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl processEngineConfiguration)
-
setConfigurationResource
public void setConfigurationResource(String configurationResource)
-
getDeploymentId
public String getDeploymentId()
-
isEnsureCleanAfterTest
public boolean isEnsureCleanAfterTest()
-
setEnsureCleanAfterTest
public void setEnsureCleanAfterTest(boolean ensureCleanAfterTest)
-
-