Search in sources :

Example 21 with BpmnModelInstance

use of io.camunda.zeebe.model.bpmn.BpmnModelInstance in project zeebe by camunda.

the class TimerCatchEventTest method shouldCreateTimer.

@Test
public void shouldCreateTimer() {
    // given
    final BpmnModelInstance process = Bpmn.createExecutableProcess("shouldCreateTimer").startEvent().intermediateCatchEvent("timer", c -> c.timerWithDuration("PT10S")).endEvent().done();
    ENGINE.deployment().withXmlResource(process).deploy();
    final long processInstanceKey = ENGINE.processInstance().ofBpmnProcessId("shouldCreateTimer").create();
    // when
    final Record<ProcessInstanceRecordValue> activatedEvent = RecordingExporter.processInstanceRecords(ProcessInstanceIntent.ELEMENT_ACTIVATED).withProcessInstanceKey(processInstanceKey).withElementId("timer").getFirst();
    // then
    final Record<TimerRecordValue> createdEvent = RecordingExporter.timerRecords(TimerIntent.CREATED).withProcessInstanceKey(processInstanceKey).getFirst();
    Assertions.assertThat(createdEvent.getValue()).hasElementInstanceKey(activatedEvent.getKey()).hasProcessInstanceKey(processInstanceKey);
    assertThat(createdEvent.getValue().getDueDate()).isBetween(ENGINE.getClock().getCurrentTimeInMillis(), createdEvent.getTimestamp() + Duration.ofSeconds(10).toMillis());
}
Also used : ProcessInstanceRecordValue(io.camunda.zeebe.protocol.record.value.ProcessInstanceRecordValue) BpmnModelInstance(io.camunda.zeebe.model.bpmn.BpmnModelInstance) TimerRecordValue(io.camunda.zeebe.protocol.record.value.TimerRecordValue) Test(org.junit.Test)

Example 22 with BpmnModelInstance

use of io.camunda.zeebe.model.bpmn.BpmnModelInstance in project zeebe by camunda.

the class TimerStartEventTest method shouldTriggerIfTimeDatePassedOnDeployment.

@Test
public void shouldTriggerIfTimeDatePassedOnDeployment() {
    // given
    final Instant triggerTime = Instant.now().plusMillis(2000);
    final BpmnModelInstance model = Bpmn.createExecutableProcess("process").startEvent("start_2").timerWithDate(triggerTime.toString()).endEvent("end_2").done();
    final var deployedProcess = engine.deployment().withXmlResource(model).deploy().getValue().getProcessesMetadata().get(0);
    // when
    engine.increaseTime(Duration.ofMillis(2000L));
    // then
    final TimerRecordValue timerRecord = RecordingExporter.timerRecords(TimerIntent.TRIGGERED).withProcessDefinitionKey(deployedProcess.getProcessDefinitionKey()).getFirst().getValue();
    Assertions.assertThat(timerRecord).hasDueDate(triggerTime.toEpochMilli()).hasTargetElementId("start_2").hasElementInstanceKey(TimerInstance.NO_ELEMENT_INSTANCE);
}
Also used : Instant(java.time.Instant) BpmnModelInstance(io.camunda.zeebe.model.bpmn.BpmnModelInstance) TimerRecordValue(io.camunda.zeebe.protocol.record.value.TimerRecordValue) Test(org.junit.Test)

Example 23 with BpmnModelInstance

use of io.camunda.zeebe.model.bpmn.BpmnModelInstance in project zeebe by camunda.

the class BusinessRuleTaskValidationTest method emptyDecisionId.

@Test
void emptyDecisionId() {
    // when
    final BpmnModelInstance process = process(task -> task.zeebeCalledDecisionId("").zeebeResultVariable("result"));
    // then
    ProcessValidationUtil.assertThatProcessHasViolations(process, ExpectedValidationResult.expect(ZeebeCalledDecision.class, "Attribute 'decisionId' must be present and not empty"));
}
Also used : ZeebeCalledDecision(io.camunda.zeebe.model.bpmn.instance.zeebe.ZeebeCalledDecision) BpmnModelInstance(io.camunda.zeebe.model.bpmn.BpmnModelInstance) Test(org.junit.jupiter.api.Test)

Example 24 with BpmnModelInstance

use of io.camunda.zeebe.model.bpmn.BpmnModelInstance in project zeebe by camunda.

the class BusinessRuleTaskValidationTest method emptyDecisionIdExpression.

@Test
void emptyDecisionIdExpression() {
    // when
    final BpmnModelInstance process = process(task -> task.zeebeCalledDecisionIdExpression("").zeebeResultVariable("result"));
    // then
    ProcessValidationUtil.assertThatProcessHasViolations(process, ExpectedValidationResult.expect(ZeebeCalledDecision.class, "Attribute 'decisionId' must be present and not empty"));
}
Also used : ZeebeCalledDecision(io.camunda.zeebe.model.bpmn.instance.zeebe.ZeebeCalledDecision) BpmnModelInstance(io.camunda.zeebe.model.bpmn.BpmnModelInstance) Test(org.junit.jupiter.api.Test)

Example 25 with BpmnModelInstance

use of io.camunda.zeebe.model.bpmn.BpmnModelInstance in project zeebe by camunda.

the class BusinessRuleTaskValidationTest method emptyJobType.

@Test
void emptyJobType() {
    // when
    final BpmnModelInstance process = process(task -> task.zeebeJobType(""));
    // then
    ProcessValidationUtil.assertThatProcessHasViolations(process, expect(ZeebeTaskDefinition.class, "Attribute 'type' must be present and not empty"));
}
Also used : BpmnModelInstance(io.camunda.zeebe.model.bpmn.BpmnModelInstance) ZeebeTaskDefinition(io.camunda.zeebe.model.bpmn.instance.zeebe.ZeebeTaskDefinition) Test(org.junit.jupiter.api.Test)

Aggregations

BpmnModelInstance (io.camunda.zeebe.model.bpmn.BpmnModelInstance)442 Test (org.junit.Test)336 Bpmn (io.camunda.zeebe.model.bpmn.Bpmn)204 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)184 RecordingExporter (io.camunda.zeebe.test.util.record.RecordingExporter)166 Rule (org.junit.Rule)163 EngineRule (io.camunda.zeebe.engine.util.EngineRule)157 Record (io.camunda.zeebe.protocol.record.Record)142 ProcessInstanceIntent (io.camunda.zeebe.protocol.record.intent.ProcessInstanceIntent)139 BpmnElementType (io.camunda.zeebe.protocol.record.value.BpmnElementType)136 List (java.util.List)126 ClassRule (org.junit.ClassRule)124 ProcessInstanceRecordValue (io.camunda.zeebe.protocol.record.value.ProcessInstanceRecordValue)121 Assertions.tuple (org.assertj.core.api.Assertions.tuple)121 Map (java.util.Map)99 JobIntent (io.camunda.zeebe.protocol.record.intent.JobIntent)97 Duration (java.time.Duration)96 Collectors (java.util.stream.Collectors)90 ProcessBuilder (io.camunda.zeebe.model.bpmn.builder.ProcessBuilder)79 MessageSubscriptionIntent (io.camunda.zeebe.protocol.record.intent.MessageSubscriptionIntent)78