Skip to content

Commit

Permalink
test: Verify ThrowError with variables
Browse files Browse the repository at this point in the history
Extend the test case for the ThrowError command to verify that given variables are set as local variables of the error catch event.
  • Loading branch information
saig0 committed Feb 8, 2024
1 parent ba98409 commit bc858f8
Showing 1 changed file with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -772,6 +772,7 @@ void shouldThrowErrorOnJob() {
.serviceTask("task", (task) -> task.zeebeJobType("jobType"))
.boundaryEvent("error")
.error("0xCAFE")
.zeebeOutputExpression("error_var", "error_var")
.endEvent()
.done(),
"simpleProcess.bpmn")
Expand Down Expand Up @@ -809,6 +810,7 @@ void shouldThrowErrorOnJob() {
.newThrowErrorCommand(job.getKey())
.errorCode("0xCAFE")
.errorMessage("What just happened.")
.variable("error_var", "Out of coffee")
.send()
.join();

Expand All @@ -831,6 +833,23 @@ void shouldThrowErrorOnJob() {
.findFirst();

assertThat(boundaryEvent).isNotEmpty();

final var errorVariable =
StreamSupport.stream(
RecordStream.of(zeebeEngine.getRecordStreamSource())
.variableRecords()
.spliterator(),
false)
.filter(r -> r.getValue().getName().equals("error_var"))
.findFirst();

assertThat(errorVariable)
.describedAs("Expect that the error variable is set")
.isPresent()
.hasValueSatisfying(
record ->
assertThat(record.getValue().getValue())
.isEqualTo("\"Out of coffee\""));
});
});
}
Expand Down

0 comments on commit bc858f8

Please sign in to comment.