Skip to content

Commit

Permalink
test(engine): fix terminate tests
Browse files Browse the repository at this point in the history
Fixes existing tests to adhere to batch termination

BoundaryEventTest:
This test asserts over an exact sequence of record. The terminate batch command needs to be inserted in this sequence.

ProcessInstanceCommandRejectionTest:
Because of the batch command no seconds terminate command is written anymore.
We need another setup to write 2 terminate commands.
  • Loading branch information
remcowesterhoud committed Apr 28, 2023
1 parent 0f3f458 commit 12439f7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import io.camunda.zeebe.protocol.record.intent.IncidentIntent;
import io.camunda.zeebe.protocol.record.intent.JobIntent;
import io.camunda.zeebe.protocol.record.intent.ProcessEventIntent;
import io.camunda.zeebe.protocol.record.intent.ProcessInstanceBatchIntent;
import io.camunda.zeebe.protocol.record.intent.ProcessInstanceIntent;
import io.camunda.zeebe.protocol.record.intent.ProcessMessageSubscriptionIntent;
import io.camunda.zeebe.protocol.record.intent.TimerIntent;
Expand Down Expand Up @@ -256,6 +257,7 @@ public void shouldTerminateSubProcessBeforeTriggeringBoundaryEvent() {
tuple(ValueType.PROCESS_EVENT, ProcessEventIntent.TRIGGERING),
tuple(ValueType.PROCESS_INSTANCE, ProcessInstanceIntent.TERMINATE_ELEMENT),
tuple(ValueType.PROCESS_INSTANCE, ProcessInstanceIntent.ELEMENT_TERMINATING),
tuple(ValueType.PROCESS_INSTANCE_BATCH, ProcessInstanceBatchIntent.TERMINATE),
tuple(ValueType.PROCESS_INSTANCE, ProcessInstanceIntent.TERMINATE_ELEMENT),
tuple(ValueType.PROCESS_INSTANCE, ProcessInstanceIntent.ELEMENT_TERMINATING),
tuple(ValueType.JOB, JobIntent.CANCELED),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -584,9 +584,10 @@ public void shouldRejectTerminateIfElementIsTerminated() {
.endEvent()
.done());

final var timerCreated =
RecordingExporter.timerRecords(TimerIntent.CREATED)
final var serviceTaskActivated =
RecordingExporter.processInstanceRecords(ProcessInstanceIntent.ELEMENT_ACTIVATED)
.withProcessInstanceKey(processInstanceKey)
.withElementId("a")
.getFirst();

final var jobCreated =
Expand All @@ -596,7 +597,8 @@ public void shouldRejectTerminateIfElementIsTerminated() {

// when
engine.writeRecords(
cancelProcessInstanceCommand(processInstanceKey), triggerTimerCommand(timerCreated));
terminateElementCommand(serviceTaskActivated),
terminateElementCommand(serviceTaskActivated));

// then
final var rejectedCommand =
Expand Down Expand Up @@ -632,6 +634,12 @@ private RecordToWrite triggerTimerCommand(final Record<TimerRecordValue> timer)
return RecordToWrite.command().timer(TimerIntent.TRIGGER, timer.getValue()).key(timer.getKey());
}

private RecordToWrite terminateElementCommand(final Record<ProcessInstanceRecordValue> record) {
return RecordToWrite.command()
.processInstance(ProcessInstanceIntent.TERMINATE_ELEMENT, record.getValue())
.key(record.getKey());
}

private void assertThatCommandIsRejected(
final Record<ProcessInstanceRecordValue> command, final String rejectionReason) {

Expand Down

0 comments on commit 12439f7

Please sign in to comment.