use of io.camunda.zeebe.protocol.record.Record in project zeebe by camunda.
the class NonInterruptingEventSubprocessTest method shouldTriggerEventSubprocessTwiceWithOwnLocalScopeVariable.
@Test
public void shouldTriggerEventSubprocessTwiceWithOwnLocalScopeVariable() {
// given
final BpmnModelInstance model = eventSubprocModelWithLocalScopeVariable(builder);
final long processInstanceKey = createInstanceAndTriggerEvent(model);
RecordingExporter.processInstanceRecords(ProcessInstanceIntent.ELEMENT_ACTIVATED).withElementId("event_sub_start").withElementType(BpmnElementType.START_EVENT).withProcessInstanceKey(processInstanceKey).await();
// when
triggerEventSubprocess.accept(processInstanceKey);
// then
final List<Record<ProcessInstanceRecordValue>> eventSubProcessActivatedList = RecordingExporter.processInstanceRecords(ProcessInstanceIntent.ELEMENT_ACTIVATED).withElementId("event_sub_proc").withElementType(BpmnElementType.EVENT_SUB_PROCESS).withProcessInstanceKey(processInstanceKey).limit(2).collect(Collectors.toList());
RecordingExporter.variableRecords().withProcessInstanceKey(processInstanceKey).withName("localScope").withScopeKey(eventSubProcessActivatedList.get(0).getKey()).await();
RecordingExporter.variableRecords().withProcessInstanceKey(processInstanceKey).withName("localScope").withScopeKey(eventSubProcessActivatedList.get(1).getKey()).await();
}
use of io.camunda.zeebe.protocol.record.Record in project zeebe by camunda.
the class CreateDeploymentMultiplePartitionsTest method assertDeploymentEventResources.
private void assertDeploymentEventResources(final int expectedPartition, final DeploymentIntent deploymentIntent, final long expectedKey, final Consumer<Record<DeploymentRecordValue>> deploymentAssert) {
final Record deploymentCreatedEvent = RecordingExporter.deploymentRecords().withPartitionId(expectedPartition).withIntent(deploymentIntent).withRecordKey(expectedKey).getFirst();
assertThat(deploymentCreatedEvent.getKey()).isEqualTo(expectedKey);
assertThat(deploymentCreatedEvent.getPartitionId()).isEqualTo(expectedPartition);
deploymentAssert.accept(deploymentCreatedEvent);
}
use of io.camunda.zeebe.protocol.record.Record in project zeebe by camunda.
the class CreateDeploymentMultiplePartitionsTest method shouldCreateDeploymentOnAllPartitions.
@Test
public void shouldCreateDeploymentOnAllPartitions() {
// when
final BpmnModelInstance modelInstance = Bpmn.createExecutableProcess("shouldCreateDeploymentOnAllPartitions").startEvent().endEvent().done();
final BpmnModelInstance secondNoopModel = Bpmn.createExecutableProcess("shouldCreateDeploymentOnAllPartitionsSecondNoopDeployment").startEvent().endEvent().done();
final Record<DeploymentRecordValue> deployment = ENGINE.deployment().withXmlResource("process.bpmn", modelInstance).deploy();
final Record<DeploymentRecordValue> secondDeployment = ENGINE.deployment().withXmlResource("secondNoopModel.bpmn", secondNoopModel).deploy();
// then
assertThat(deployment.getKey()).isNotNegative();
assertThat(deployment.getPartitionId()).isEqualTo(PARTITION_ID);
assertThat(deployment.getRecordType()).isEqualTo(RecordType.EVENT);
assertThat(deployment.getIntent()).isEqualTo(DeploymentIntent.CREATED);
final var deploymentRecords = RecordingExporter.records().limit(r -> r.getIntent() == DeploymentIntent.FULLY_DISTRIBUTED && r.getKey() == secondDeployment.getKey()).withRecordKey(deployment.getKey()).collect(Collectors.toList());
final var listOfFullyDistributed = deploymentRecords.stream().filter(r -> r.getIntent() == DeploymentIntent.FULLY_DISTRIBUTED).collect(Collectors.toList());
assertThat(listOfFullyDistributed).hasSize(1);
final var fullyDistributedDeployment = listOfFullyDistributed.get(0);
assertThat(fullyDistributedDeployment.getKey()).isNotNegative();
assertThat(fullyDistributedDeployment.getPartitionId()).isEqualTo(PARTITION_ID);
assertThat(fullyDistributedDeployment.getRecordType()).isEqualTo(RecordType.EVENT);
assertThat(fullyDistributedDeployment.getIntent()).isEqualTo(DeploymentIntent.FULLY_DISTRIBUTED);
assertThat(deploymentRecords.stream().filter(r -> r.getIntent() == DeploymentIntent.DISTRIBUTE).count()).isEqualTo(PARTITION_COUNT - 1);
assertThat(deploymentRecords.stream().filter(r -> r.getIntent() == DeploymentDistributionIntent.DISTRIBUTING).count()).isEqualTo(PARTITION_COUNT - 1);
assertThat(deploymentRecords.stream().filter(r -> r.getIntent() == DeploymentDistributionIntent.COMPLETE).count()).isEqualTo(PARTITION_COUNT - 1);
// todo(zell): https://github.com/zeebe-io/zeebe/issues/6314 fully distributed contains
// currently no longer any resources
//
// assertDeploymentEventResources(
// DEPLOYMENT_PARTITION,
// DeploymentIntent.CREATED,
// deployment.getKey(),
// (createdDeployment) ->
// assertDeploymentRecord(fullyDistributedDeployment, createdDeployment));
ENGINE.getPartitionIds().forEach(partitionId -> {
if (DEPLOYMENT_PARTITION == partitionId) {
return;
}
assertDeploymentEventResources(partitionId, DeploymentIntent.DISTRIBUTED, deployment.getKey(), (createdDeployment) -> assertDeploymentRecord(deployment, createdDeployment));
});
}
use of io.camunda.zeebe.protocol.record.Record in project zeebe by camunda.
the class BoundaryEventTest method shouldApplyOutputMappingOnTriggering.
@Test
public void shouldApplyOutputMappingOnTriggering() {
// given
final BpmnModelInstance process = Bpmn.createExecutableProcess(PROCESS_ID).startEvent().serviceTask("task", b -> b.zeebeJobType("type")).boundaryEvent("event").message(m -> m.name("message").zeebeCorrelationKeyExpression("key")).zeebeOutputExpression("foo", "bar").endEvent("endTimer").moveToActivity("task").endEvent().done();
ENGINE.deployment().withXmlResource(process).deploy();
final long processInstanceKey = ENGINE.processInstance().ofBpmnProcessId(PROCESS_ID).withVariable("key", "123").create();
// when
ENGINE.message().withName("message").withCorrelationKey("123").withVariables(asMsgPack("foo", 3)).publish();
// then
final Record<VariableRecordValue> variableEvent = RecordingExporter.variableRecords().withProcessInstanceKey(processInstanceKey).withName("bar").getFirst();
Assertions.assertThat(variableEvent.getValue()).hasValue("3");
}
use of io.camunda.zeebe.protocol.record.Record in project zeebe by camunda.
the class BoundaryEventTest method shouldTerminateSubProcessBeforeTriggeringBoundaryEvent.
@Test
public void shouldTerminateSubProcessBeforeTriggeringBoundaryEvent() {
// given
final BpmnModelInstance process = Bpmn.createExecutableProcess(PROCESS_ID).startEvent().subProcess("sub").embeddedSubProcess().startEvent().serviceTask("task", t -> t.zeebeJobType("type")).endEvent().subProcessDone().boundaryEvent("timer").cancelActivity(true).timerWithDuration("PT1S").endEvent("endTimer").moveToActivity("sub").endEvent().done();
ENGINE.deployment().withXmlResource(process).deploy();
ENGINE.processInstance().ofBpmnProcessId(PROCESS_ID).create();
// when
RecordingExporter.jobRecords().withIntent(JobIntent.CREATED).getFirst();
ENGINE.increaseTime(Duration.ofMinutes(1));
final List<Record<RecordValue>> records = RecordingExporter.records().limit(r -> r.getValue() instanceof ProcessInstanceRecord && ((ProcessInstanceRecord) r.getValue()).getElementId().equals("timer") && r.getIntent() == ProcessInstanceIntent.ELEMENT_COMPLETED).asList();
assertThat(records).extracting(Record::getValueType, Record::getIntent).endsWith(tuple(ValueType.TIMER, TimerIntent.TRIGGERED), tuple(ValueType.PROCESS_EVENT, ProcessEventIntent.TRIGGERING), tuple(ValueType.PROCESS_INSTANCE, ProcessInstanceIntent.TERMINATE_ELEMENT), tuple(ValueType.PROCESS_INSTANCE, ProcessInstanceIntent.ELEMENT_TERMINATING), tuple(ValueType.PROCESS_INSTANCE, ProcessInstanceIntent.TERMINATE_ELEMENT), tuple(ValueType.PROCESS_INSTANCE, ProcessInstanceIntent.ELEMENT_TERMINATING), tuple(ValueType.JOB, JobIntent.CANCEL), tuple(ValueType.PROCESS_INSTANCE, ProcessInstanceIntent.ELEMENT_TERMINATED), tuple(ValueType.PROCESS_INSTANCE, ProcessInstanceIntent.ELEMENT_TERMINATED), tuple(ValueType.PROCESS_EVENT, ProcessEventIntent.TRIGGERED), tuple(ValueType.PROCESS_INSTANCE, ProcessInstanceIntent.ELEMENT_ACTIVATING), tuple(ValueType.PROCESS_INSTANCE, ProcessInstanceIntent.ELEMENT_ACTIVATED), tuple(ValueType.PROCESS_INSTANCE, ProcessInstanceIntent.COMPLETE_ELEMENT), tuple(ValueType.JOB, JobIntent.CANCELED), tuple(ValueType.PROCESS_INSTANCE, ProcessInstanceIntent.ELEMENT_COMPLETING), tuple(ValueType.PROCESS_INSTANCE, ProcessInstanceIntent.ELEMENT_COMPLETED));
}
Aggregations