Skip to content

Commit

Permalink
test(engine): verify catching of errors with number as errorCode
Browse files Browse the repository at this point in the history
Verifies that we can catch thrown errors if the errorCode defined on the boundary event is a Number instead of a String.

(cherry picked from commit 4ba5c9b)
  • Loading branch information
remcowesterhoud authored and github-actions[bot] committed Apr 11, 2023
1 parent 5e74059 commit e0e822c
Showing 1 changed file with 47 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public class ErrorEventTest {
private static final String PROCESS_ID = "wf";
private static final String JOB_TYPE = "test";
private static final String ERROR_CODE = "ERROR";
private static final String ERROR_CODE_NUMBER = "404";

private static final BpmnModelInstance SINGLE_BOUNDARY_EVENT =
process(
Expand Down Expand Up @@ -144,6 +145,52 @@ public void shouldCatchErrorEventsByErrorCode() {
.containsOnly("error-2");
}

@Test
public void shouldCatchErrorEventsByNumericErrorCode() {
// Regression for https://github.com/camunda/zeebe/issues/12326
// given
ENGINE
.deployment()
.withXmlResource(
process(
serviceTask ->
serviceTask.boundaryEvent("error", b -> b.error(ERROR_CODE_NUMBER).endEvent())))
.deploy();

final var processInstanceKey = ENGINE.processInstance().ofBpmnProcessId(PROCESS_ID).create();

// when
ENGINE
.job()
.ofInstance(processInstanceKey)
.withType(JOB_TYPE)
.withErrorCode(ERROR_CODE_NUMBER)
.throwError();

// then
assertThat(
RecordingExporter.processInstanceRecords()
.withProcessInstanceKey(processInstanceKey)
.limitToProcessInstanceCompleted())
.extracting(r -> r.getValue().getBpmnElementType(), Record::getIntent)
.containsSubsequence(
tuple(BpmnElementType.SERVICE_TASK, ProcessInstanceIntent.ELEMENT_TERMINATING),
tuple(BpmnElementType.SERVICE_TASK, ProcessInstanceIntent.ELEMENT_TERMINATED),
tuple(BpmnElementType.BOUNDARY_EVENT, ProcessInstanceIntent.ELEMENT_ACTIVATING),
tuple(BpmnElementType.BOUNDARY_EVENT, ProcessInstanceIntent.ELEMENT_ACTIVATED),
tuple(BpmnElementType.BOUNDARY_EVENT, ProcessInstanceIntent.COMPLETE_ELEMENT),
tuple(BpmnElementType.BOUNDARY_EVENT, ProcessInstanceIntent.ELEMENT_COMPLETING),
tuple(BpmnElementType.BOUNDARY_EVENT, ProcessInstanceIntent.ELEMENT_COMPLETED),
tuple(BpmnElementType.SEQUENCE_FLOW, ProcessInstanceIntent.SEQUENCE_FLOW_TAKEN),
tuple(BpmnElementType.END_EVENT, ProcessInstanceIntent.ELEMENT_ACTIVATING),
tuple(BpmnElementType.END_EVENT, ProcessInstanceIntent.ELEMENT_ACTIVATED),
tuple(BpmnElementType.END_EVENT, ProcessInstanceIntent.ELEMENT_COMPLETING),
tuple(BpmnElementType.END_EVENT, ProcessInstanceIntent.ELEMENT_COMPLETED),
tuple(BpmnElementType.PROCESS, ProcessInstanceIntent.COMPLETE_ELEMENT),
tuple(BpmnElementType.PROCESS, ProcessInstanceIntent.ELEMENT_COMPLETING),
tuple(BpmnElementType.PROCESS, ProcessInstanceIntent.ELEMENT_COMPLETED));
}

@Test
public void shouldCatchErrorEventsOnBoundaryEventWithoutErrorRef() {
// given
Expand Down

0 comments on commit e0e822c

Please sign in to comment.