use of io.camunda.zeebe.protocol.record.Record in project zeebe by zeebe-io.
the class ParallelGatewayTest method shouldMergeAndSplitInOneGateway.
@Test
public void shouldMergeAndSplitInOneGateway() {
// given
final BpmnModelInstance process = Bpmn.createExecutableProcess(PROCESS_ID).startEvent("start").parallelGateway("fork").parallelGateway("join-fork").moveToNode("fork").connectTo("join-fork").serviceTask("task1", b -> b.zeebeJobType("type1")).moveToLastGateway().serviceTask("task2", b -> b.zeebeJobType("type2")).done();
engine.deployment().withXmlResource(process).deploy();
// when
engine.processInstance().ofBpmnProcessId(PROCESS_ID).create();
// then
final List<Record<ProcessInstanceRecordValue>> elementInstances = RecordingExporter.processInstanceRecords().filter(r -> r.getIntent() == ProcessInstanceIntent.ELEMENT_ACTIVATED && r.getValue().getBpmnElementType() == BpmnElementType.SERVICE_TASK).limit(2).collect(Collectors.toList());
assertThat(elementInstances).extracting(e -> e.getValue().getElementId()).contains("task1", "task2");
}
use of io.camunda.zeebe.protocol.record.Record in project zeebe by zeebe-io.
the class MultiInstanceActivityTest method shouldTriggerNonInterruptingBoundaryEvent.
@Test
public void shouldTriggerNonInterruptingBoundaryEvent() {
// given
final ServiceTask task = process(miBuilder).getModelElementById(ELEMENT_ID);
final var process = task.builder().boundaryEvent("boundary-event", b -> b.cancelActivity(false).message(MESSAGE_BUILDER)).sequenceFlowId("to-notified").endEvent("notified").done();
ENGINE.deployment().withXmlResource(process).deploy();
final long processInstanceKey = ENGINE.processInstance().ofBpmnProcessId(PROCESS_ID).withVariables(Map.of(INPUT_COLLECTION_EXPRESSION, INPUT_COLLECTION, MESSAGE_CORRELATION_KEY_VARIABLE, MESSAGE_CORRELATION_KEY)).create();
completeJobs(processInstanceKey, INPUT_COLLECTION.size() - 1);
// make sure message subscription is opened, before publishing
RecordingExporter.messageSubscriptionRecords(MessageSubscriptionIntent.CREATED).withProcessInstanceKey(processInstanceKey).await();
// when
ENGINE.message().withName(MESSAGE_NAME).withCorrelationKey(MESSAGE_CORRELATION_KEY).withTimeToLive(// must be 0 because engine is re-used in tests
0).publish();
// then
assertThat(RecordingExporter.processInstanceRecords().withProcessInstanceKey(processInstanceKey).limit(r -> r.getValue().getBpmnElementType() == BpmnElementType.END_EVENT)).extracting(r -> tuple(r.getValue().getElementId(), r.getValue().getBpmnElementType(), r.getIntent())).containsSubsequence(tuple("to-notified", BpmnElementType.SEQUENCE_FLOW, ProcessInstanceIntent.SEQUENCE_FLOW_TAKEN), tuple("notified", BpmnElementType.END_EVENT, ProcessInstanceIntent.ACTIVATE_ELEMENT));
// and
completeJobs(processInstanceKey, 1);
assertThat(RecordingExporter.messageSubscriptionRecords().withProcessInstanceKey(processInstanceKey).limit(7)).extracting(Record::getIntent).containsExactly(MessageSubscriptionIntent.CREATE, MessageSubscriptionIntent.CREATED, MessageSubscriptionIntent.CORRELATING, MessageSubscriptionIntent.CORRELATE, MessageSubscriptionIntent.CORRELATED, MessageSubscriptionIntent.DELETE, MessageSubscriptionIntent.DELETED);
assertThat(RecordingExporter.processInstanceRecords().withProcessInstanceKey(processInstanceKey).limitToProcessInstanceCompleted()).extracting(r -> tuple(r.getValue().getElementId(), r.getValue().getBpmnElementType(), r.getIntent())).containsSubsequence(tuple("notified", BpmnElementType.END_EVENT, ProcessInstanceIntent.ELEMENT_COMPLETED), tuple(ELEMENT_ID, BpmnElementType.SERVICE_TASK, ProcessInstanceIntent.ELEMENT_COMPLETED), tuple(ELEMENT_ID, BpmnElementType.MULTI_INSTANCE_BODY, ProcessInstanceIntent.ELEMENT_COMPLETED), tuple(PROCESS_ID, BpmnElementType.PROCESS, ProcessInstanceIntent.ELEMENT_COMPLETED));
}
use of io.camunda.zeebe.protocol.record.Record in project zeebe by zeebe-io.
the class MultiInstanceActivityTest method shouldApplyOutputMapping.
@Test
public void shouldApplyOutputMapping() {
// given
final ServiceTask task = process(miBuilder).getModelElementById(ELEMENT_ID);
final var process = task.builder().zeebeOutputExpression("loopCounter", // overrides the variable
OUTPUT_ELEMENT_EXPRESSION).zeebeOutputExpression("loopCounter", // propagates to root scope
"global").done();
ENGINE.deployment().withXmlResource(process).deploy();
// when
final long processInstanceKey = ENGINE.processInstance().ofBpmnProcessId(PROCESS_ID).withVariable(INPUT_COLLECTION_EXPRESSION, INPUT_COLLECTION).create();
completeJobs(processInstanceKey, INPUT_COLLECTION.size());
// then
assertThat(RecordingExporter.variableRecords().withScopeKey(processInstanceKey).withName(OUTPUT_COLLECTION_VARIABLE).getFirst().getValue()).hasValue("[1,2,3]");
assertThat(RecordingExporter.records().limitToProcessInstance(processInstanceKey).variableRecords().withProcessInstanceKey(processInstanceKey).withName("global")).extracting(Record::getValue).extracting(v -> tuple(v.getScopeKey(), v.getValue())).containsExactly(tuple(processInstanceKey, "1"), tuple(processInstanceKey, "2"), tuple(processInstanceKey, "3"));
}
use of io.camunda.zeebe.protocol.record.Record in project zeebe by zeebe-io.
the class MultiInstanceSubProcessTest method shouldCreateTimerForEachSubProcess.
@Test
public void shouldCreateTimerForEachSubProcess() {
// given
final BpmnModelInstance process = process(b -> b.intermediateCatchEvent("timer").timerWithDuration("PT1S"));
ENGINE.deployment().withXmlResource(process).deploy();
final List<String> inputCollection = Arrays.asList("a", "b", "c");
final long processInstanceKey = ENGINE.processInstance().ofBpmnProcessId(PROCESS_ID).withVariable(INPUT_COLLECTION, inputCollection).create();
// then
assertThat(RecordingExporter.timerRecords(TimerIntent.CREATED).withProcessInstanceKey(processInstanceKey).limit(3)).hasSize(3).extracting(r -> r.getValue().getTargetElementId()).containsOnly("timer");
// and
ENGINE.getClock().addTime(Duration.ofSeconds(1));
// then
assertThat(RecordingExporter.processInstanceRecords(ProcessInstanceIntent.ELEMENT_COMPLETED).filterRootScope().limitToProcessInstanceCompleted()).extracting(Record::getIntent).containsExactly(ProcessInstanceIntent.ELEMENT_COMPLETED);
}
use of io.camunda.zeebe.protocol.record.Record in project zeebe by zeebe-io.
the class CreateDeploymentTest method shouldRejectDeploymentWithDuplicateResources.
@Test
public void shouldRejectDeploymentWithDuplicateResources() {
// given
final BpmnModelInstance definition1 = Bpmn.createExecutableProcess("process1").startEvent().done();
final BpmnModelInstance definition2 = Bpmn.createExecutableProcess("process2").startEvent().done();
final BpmnModelInstance definition3 = Bpmn.createExecutableProcess("process2").startEvent().serviceTask("task", (t) -> t.zeebeJobType("j").zeebeTaskHeader("k", "v")).done();
// when
final Record<DeploymentRecordValue> deploymentRejection = ENGINE.deployment().withXmlResource("p1.bpmn", definition1).withXmlResource("p2.bpmn", definition2).withXmlResource("p3.bpmn", definition3).expectRejection().deploy();
// then
Assertions.assertThat(deploymentRejection).hasRejectionType(RejectionType.INVALID_ARGUMENT).hasRejectionReason("Expected to deploy new resources, but encountered the following errors:\n" + "Duplicated process id in resources 'p2.bpmn' and 'p3.bpmn'");
}
Aggregations