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());
}
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);
}
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"));
}
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"));
}
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"));
}
Aggregations