Package org.camunda.community.bpmndt.api
Class TestCaseExecutor
java.lang.Object
org.camunda.community.bpmndt.api.TestCaseExecutor
Fluent API to prepare and start the actual test case execution.
-
Constructor Summary
ConstructorsConstructorDescriptionTestCaseExecutor(TestCaseInstance instance, Consumer<org.camunda.bpm.engine.runtime.ProcessInstance> executor) -
Method Summary
Modifier and TypeMethodDescriptioncustomize(Consumer<TestCaseExecutor> customizer) Customizes the executor, using the givenConsumerfunction.org.camunda.bpm.engine.runtime.ProcessInstanceexecute()Create a newProcessInstance, executes the actual test case and verifies the state after.org.camunda.bpm.engine.runtime.ProcessInstanceExecutes the actual test case and verifies the state after, using theProcessInstance, identified by the given ID.voidexecute(org.camunda.bpm.engine.runtime.ProcessInstance pi) Executes the actual test case and verifies the state after, using the givenProcessInstance.protected voidmigrate(org.camunda.bpm.engine.runtime.ProcessInstance pi) protected org.camunda.bpm.engine.ProcessEngineExceptionunwrapAssertionError(org.camunda.bpm.engine.ProcessEngineException e) Unwraps and throws a possibleAssertionErrorin case of a failed assertion within aCallActivityHandler's verifier.Verifies that state after the test case execution has finished.Registers a bean for the given key.
Please note: If Spring is enabled, the beans will be provided via Spring's application context (e.g.withBusinessKey(String businessKey) Sets the business key of the process instance that will be created.withVariable(String name, Object value) Sets a variable on the process instance that will be created.withVariables(Map<String, Object> variables) Sets variables on the process instance that will be created.withVariableTyped(String name, org.camunda.bpm.engine.variable.value.TypedValue value) Sets a typed variable on the process instance that will be started.
-
Constructor Details
-
TestCaseExecutor
public TestCaseExecutor(TestCaseInstance instance, Consumer<org.camunda.bpm.engine.runtime.ProcessInstance> executor)
-
-
Method Details
-
customize
Customizes the executor, using the givenConsumerfunction. This method can be used to apply a common customization needed for different test cases.tc.createExecutor().customize(this::prepareVariables).execute();
- Parameters:
customizer- A function that accepts aTestCaseExecutor.- Returns:
- The executor.
-
execute
public org.camunda.bpm.engine.runtime.ProcessInstance execute()Create a newProcessInstance, executes the actual test case and verifies the state after.- Returns:
- The newly created process instance.
-
execute
public void execute(org.camunda.bpm.engine.runtime.ProcessInstance pi) Executes the actual test case and verifies the state after, using the givenProcessInstance.- Parameters:
pi- A process instance, used to execute the test case.
-
execute
Executes the actual test case and verifies the state after, using theProcessInstance, identified by the given ID.- Parameters:
processInstanceId- The ID of an existing process instance.- Returns:
- The identified process instance.
-
migrate
protected void migrate(org.camunda.bpm.engine.runtime.ProcessInstance pi) -
unwrapAssertionError
protected org.camunda.bpm.engine.ProcessEngineException unwrapAssertionError(org.camunda.bpm.engine.ProcessEngineException e) Unwraps and throws a possibleAssertionErrorin case of a failed assertion within aCallActivityHandler's verifier. If not unwrapped, a test will be marked as an error, instead of a failure!- Parameters:
e- An exception that has been caught during process instance execution.- Returns:
- The original exception, if the cause of the given exception is
nullor not an assertion error.
-
verify
public TestCaseExecutor verify(Consumer<org.camunda.bpm.engine.test.assertions.bpmn.ProcessInstanceAssert> verifier) Verifies that state after the test case execution has finished.- Parameters:
verifier- Verifier that accepts anProcessInstanceAssertinstance.- Returns:
- The executor.
-
withBean
Registers a bean for the given key.
Please note: If Spring is enabled, the beans will be provided via Spring's application context (e.g. by providing a specific test configuration).- Parameters:
key- The key, under which the bean is registered.value- The value.- Returns:
- The executor.
- See Also:
-
withBusinessKey
Sets the business key of the process instance that will be created.- Parameters:
businessKey- A specific business key.- Returns:
- The executor.
-
withVariable
Sets a variable on the process instance that will be created.- Parameters:
name- The name of the variable.value- The variable's value.- Returns:
- The executor.
-
withVariables
Sets variables on the process instance that will be created.- Parameters:
variables- A map of variables to set.- Returns:
- The executor.
-
withVariableTyped
public TestCaseExecutor withVariableTyped(String name, org.camunda.bpm.engine.variable.value.TypedValue value) Sets a typed variable on the process instance that will be started.- Parameters:
name- The name of the variable.value- The variable's typed value.- Returns:
- The executor.
-