Skip to content

Commit

Permalink
Adding test for for throwing an error on execution
Browse files Browse the repository at this point in the history
  • Loading branch information
David Ellermann committed Aug 23, 2023
1 parent b2e62d1 commit 2c3ee76
Showing 1 changed file with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,36 @@ public void register_subprocess_mock_throwEscalation() {
isEnded(processInstance);
assertEquals(escalationEndId, ((ProcessInstanceWithVariablesImpl) processInstance).getExecutionEntity().getActivityId());
}

@Test
public void register_subprocess_mock_throwError() {
String errorCode = "SOME_ERROR";
String subprocessId = "call_subprocess";
String errorEndId = "ErrorEnd";

BpmnModelInstance processWithSubProcess = Bpmn.createExecutableProcess(PROCESS_ID)
.startEvent("start")
.callActivity(subprocessId)
.calledElement(SUB_PROCESS_ID)
.boundaryEvent()
.error(errorCode)
.endEvent(errorEndId)
.moveToActivity(subprocessId)
.userTask(TASK_USERTASK)
.endEvent("end")
.done();

camunda.manageDeployment(new DeployProcess(camunda).apply(PROCESS_ID, processWithSubProcess));

camunda.manageDeployment(registerCallActivityMock(SUB_PROCESS_ID)
.onExecutionThrowError(errorCode)
.deploy(camunda));

ProcessInstance processInstance = startProcess(PROCESS_ID);

isEnded(processInstance);
assertEquals(errorEndId, ((ProcessInstanceWithVariablesImpl) processInstance).getExecutionEntity().getActivityId());
}

private void prepareProcessWithOneSubprocess() {
final BpmnModelInstance processWithSubProcess = Bpmn.createExecutableProcess(PROCESS_ID)
Expand Down

0 comments on commit 2c3ee76

Please sign in to comment.