use of io.camunda.zeebe.protocol.record.Record in project zeebe by camunda.
the class ExclusiveGatewayTest method shouldEndScopeIfGatewayHasNoOutgoingFlows.
@Test
public void shouldEndScopeIfGatewayHasNoOutgoingFlows() {
// given
final String processId = Strings.newRandomValidBpmnId();
final BpmnModelInstance processDefinition = Bpmn.createExecutableProcess(processId).startEvent().exclusiveGateway("xor").done();
ENGINE.deployment().withXmlResource(processDefinition).deploy();
// when
final long processInstanceKey = ENGINE.processInstance().ofBpmnProcessId(processId).withVariable("foo", 10).create();
// then
final List<Record<ProcessInstanceRecordValue>> completedEvents = RecordingExporter.processInstanceRecords().onlyEvents().withProcessInstanceKey(processInstanceKey).skipUntil(r -> r.getValue().getElementId().equals("xor")).limitToProcessInstanceCompleted().collect(Collectors.toList());
assertThat(completedEvents).extracting(r -> tuple(r.getValue().getBpmnElementType(), r.getIntent())).containsExactly(tuple(BpmnElementType.EXCLUSIVE_GATEWAY, ProcessInstanceIntent.ELEMENT_ACTIVATING), tuple(BpmnElementType.EXCLUSIVE_GATEWAY, ProcessInstanceIntent.ELEMENT_ACTIVATED), tuple(BpmnElementType.EXCLUSIVE_GATEWAY, ProcessInstanceIntent.ELEMENT_COMPLETING), tuple(BpmnElementType.EXCLUSIVE_GATEWAY, ProcessInstanceIntent.ELEMENT_COMPLETED), tuple(BpmnElementType.PROCESS, ProcessInstanceIntent.ELEMENT_COMPLETING), tuple(BpmnElementType.PROCESS, ProcessInstanceIntent.ELEMENT_COMPLETED));
}
use of io.camunda.zeebe.protocol.record.Record in project zeebe by camunda.
the class ExclusiveGatewayTest method shouldSplitOnExclusiveGateway.
@Test
public void shouldSplitOnExclusiveGateway() {
// given
final String processId = Strings.newRandomValidBpmnId();
final BpmnModelInstance processDefinition = Bpmn.createExecutableProcess(processId).startEvent().exclusiveGateway("xor").sequenceFlowId("s1").conditionExpression("foo < 5").endEvent("a").moveToLastGateway().sequenceFlowId("s2").conditionExpression("foo >= 5 and foo < 10").endEvent("b").moveToLastExclusiveGateway().defaultFlow().sequenceFlowId("s3").endEvent("c").done();
ENGINE.deployment().withXmlResource(processDefinition).deploy();
// when
final long processInstance1 = ENGINE.processInstance().ofBpmnProcessId(processId).withVariable("foo", 4).create();
final long processInstance2 = ENGINE.processInstance().ofBpmnProcessId(processId).withVariable("foo", 8).create();
final long processInstance3 = ENGINE.processInstance().ofBpmnProcessId(processId).withVariable("foo", 12).create();
final List<Long> processInstanceKeys = Arrays.asList(processInstance1, processInstance2, processInstance3);
// then
assertThat(RecordingExporter.processInstanceRecords(ProcessInstanceIntent.ELEMENT_COMPLETED).valueFilter(r -> processInstanceKeys.contains(r.getProcessInstanceKey())).withElementType(BpmnElementType.END_EVENT).limit(3)).extracting(Record::getValue).extracting(v -> tuple(v.getProcessInstanceKey(), v.getElementId())).contains(tuple(processInstance1, "a"), tuple(processInstance2, "b"), tuple(processInstance3, "c"));
}
use of io.camunda.zeebe.protocol.record.Record in project zeebe by camunda.
the class ParallelGatewayTest method shouldPassThroughParallelGateway.
@Test
public void shouldPassThroughParallelGateway() {
// given
final BpmnModelInstance process = Bpmn.createExecutableProcess(PROCESS_ID).startEvent("start").sequenceFlowId("flow1").parallelGateway("fork").sequenceFlowId("flow2").endEvent("end").done();
engine.deployment().withXmlResource(process).deploy();
// when
engine.processInstance().ofBpmnProcessId(PROCESS_ID).create();
// then
final List<Record<ProcessInstanceRecordValue>> processInstanceEvents = RecordingExporter.processInstanceRecords().limitToProcessInstanceCompleted().collect(Collectors.toList());
assertThat(processInstanceEvents).extracting(e -> e.getValue().getElementId(), Record::getIntent).containsSequence(tuple("fork", ProcessInstanceIntent.ELEMENT_ACTIVATING), tuple("fork", ProcessInstanceIntent.ELEMENT_ACTIVATED), tuple("fork", ProcessInstanceIntent.ELEMENT_COMPLETING), tuple("fork", ProcessInstanceIntent.ELEMENT_COMPLETED), tuple("flow2", ProcessInstanceIntent.SEQUENCE_FLOW_TAKEN), tuple("end", ProcessInstanceIntent.ACTIVATE_ELEMENT), tuple("end", ProcessInstanceIntent.ELEMENT_ACTIVATING), tuple("end", ProcessInstanceIntent.ELEMENT_ACTIVATED), tuple("end", ProcessInstanceIntent.ELEMENT_COMPLETING), tuple("end", ProcessInstanceIntent.ELEMENT_COMPLETED), tuple(PROCESS_ID, ProcessInstanceIntent.COMPLETE_ELEMENT), tuple(PROCESS_ID, ProcessInstanceIntent.ELEMENT_COMPLETING), tuple(PROCESS_ID, ProcessInstanceIntent.ELEMENT_COMPLETED));
}
use of io.camunda.zeebe.protocol.record.Record in project zeebe by camunda.
the class ParallelGatewayTest method shouldOnlyTriggerGatewayWhenAllBranchesAreActivated.
@Test
public void shouldOnlyTriggerGatewayWhenAllBranchesAreActivated() {
// given
final BpmnModelInstance process = Bpmn.createExecutableProcess(PROCESS_ID).startEvent().parallelGateway("fork").exclusiveGateway("exclusiveJoin").moveToLastGateway().connectTo("exclusiveJoin").sequenceFlowId("joinFlow1").parallelGateway("join").moveToNode("fork").serviceTask("waitState", b -> b.zeebeJobType("type")).sequenceFlowId("joinFlow2").connectTo("join").endEvent().done();
engine.deployment().withXmlResource(process).deploy();
final long processInstanceKey = engine.processInstance().ofBpmnProcessId(PROCESS_ID).create();
// waiting until we have signalled the first incoming sequence flow twice
// => this should not trigger the gateway yet
RecordingExporter.processInstanceRecords().limit(r -> "joinFlow1".equals(r.getValue().getElementId())).limit(2).skip(1).getFirst();
// when
// we complete the job
engine.job().ofInstance(processInstanceKey).withType("type").complete();
// then
final List<Record<ProcessInstanceRecordValue>> events = RecordingExporter.processInstanceRecords().limit(r -> "join".equals(r.getValue().getElementId()) && ProcessInstanceIntent.ELEMENT_COMPLETED == r.getIntent()).collect(Collectors.toList());
assertThat(events).extracting(e -> e.getValue().getElementId(), Record::getIntent).containsSubsequence(tuple("joinFlow1", ProcessInstanceIntent.SEQUENCE_FLOW_TAKEN), tuple("joinFlow1", ProcessInstanceIntent.SEQUENCE_FLOW_TAKEN), tuple("joinFlow2", ProcessInstanceIntent.SEQUENCE_FLOW_TAKEN), tuple("join", ProcessInstanceIntent.ELEMENT_ACTIVATING));
}
use of io.camunda.zeebe.protocol.record.Record in project zeebe by camunda.
the class ParallelGatewayTest method shouldCompleteScopeOnParallelGateway.
@Test
public void shouldCompleteScopeOnParallelGateway() {
// given
final BpmnModelInstance process = Bpmn.createExecutableProcess(PROCESS_ID).startEvent("start").sequenceFlowId("flow1").parallelGateway("fork").done();
engine.deployment().withXmlResource(process).deploy();
// when
engine.processInstance().ofBpmnProcessId(PROCESS_ID).create();
// then
final List<Record<ProcessInstanceRecordValue>> processInstanceEvents = RecordingExporter.processInstanceRecords().limitToProcessInstanceCompleted().collect(Collectors.toList());
assertThat(processInstanceEvents).extracting(e -> e.getValue().getElementId(), Record::getIntent).containsSequence(tuple("fork", ProcessInstanceIntent.ELEMENT_COMPLETED), tuple(PROCESS_ID, ProcessInstanceIntent.COMPLETE_ELEMENT));
}
Aggregations