public TimerRecordStream withDueDate(final long dueDate) { return valueFilter(v -> v.getDueDate() == dueDate); }
public TimerRecordStream withDueDate(final long dueDate) { return valueFilter(v -> v.getDueDate() == dueDate); }
/** * Verifies that the actual TimerRecordValue's dueDate is equal to the given one. * @param dueDate the given dueDate to compare the actual TimerRecordValue's dueDate to. * @return this assertion object. * @throws AssertionError - if the actual TimerRecordValue's dueDate is not equal to the given one. */ public S hasDueDate(long dueDate) { // check that actual TimerRecordValue we want to make assertions on is not null. isNotNull(); // overrides the default error message with a more explicit one String assertjErrorMessage = "\nExpecting dueDate of:\n <%s>\nto be:\n <%s>\nbut was:\n <%s>"; // check long actualDueDate = actual.getDueDate(); if (actualDueDate != dueDate) { failWithMessage(assertjErrorMessage, actual, dueDate, actualDueDate); } // return the current assertion for method chaining return myself; }
@Test public void shouldRecreateATimerWithCycle() { // given testClient.deploy(TWO_REPS_CYCLE_WORKFLOW); brokerRule.getClock().pinCurrentTime(); final long nowMs = brokerRule.getClock().getCurrentTimeInMillis(); testClient.createWorkflowInstance(PROCESS_ID); // when final Record<TimerRecordValue> timerCreatedRecord = RecordingExporter.timerRecords(TimerIntent.CREATED).getFirst(); brokerRule.getClock().addTime(Duration.ofSeconds(5)); final Record<TimerRecordValue> timerRescheduledRecord = RecordingExporter.timerRecords(TimerIntent.CREATED).limit(2).getLast(); // then assertThat(timerCreatedRecord).isNotEqualTo(timerRescheduledRecord); assertThat(timerCreatedRecord.getValue().getDueDate()).isEqualTo(nowMs + 1000); assertThat(timerRescheduledRecord.getValue().getDueDate()).isEqualTo(nowMs + 6000); }
@Test public void shouldRecreateATimerWithCycle() { // given testClient.deploy(TWO_REPS_CYCLE_WORKFLOW); brokerRule.getClock().pinCurrentTime(); final long nowMs = brokerRule.getClock().getCurrentTimeInMillis(); testClient.createWorkflowInstance(PROCESS_ID); // when final Record<TimerRecordValue> timerCreatedRecord = RecordingExporter.timerRecords(TimerIntent.CREATED).getFirst(); brokerRule.getClock().addTime(Duration.ofSeconds(5)); final Record<TimerRecordValue> timerRescheduledRecord = RecordingExporter.timerRecords(TimerIntent.CREATED).limit(2).getLast(); // then assertThat(timerCreatedRecord).isNotEqualTo(timerRescheduledRecord); assertThat(timerCreatedRecord.getValue().getDueDate()).isEqualTo(nowMs + 1000); assertThat(timerRescheduledRecord.getValue().getDueDate()).isEqualTo(nowMs + 6000); }
@Test public void shouldCreateTimerBasedOnBoundaryEvent() { // given testClient.deploy(BOUNDARY_EVENT_WORKFLOW); brokerRule.getClock().pinCurrentTime(); final long nowMs = brokerRule.getClock().getCurrentTimeInMillis(); testClient.createWorkflowInstance("process"); // when final Record<TimerRecordValue> timerCreatedRecord = RecordingExporter.timerRecords(TimerIntent.CREATED).getFirst(); final Record<WorkflowInstanceRecordValue> activityRecord = RecordingExporter.workflowInstanceRecords(WorkflowInstanceIntent.ELEMENT_ACTIVATED) .withElementId("task") .getFirst(); // then assertThat(timerCreatedRecord.getValue().getDueDate()).isEqualTo(nowMs + 1000); assertThat(timerCreatedRecord.getValue().getElementInstanceKey()) .isEqualTo(activityRecord.getKey()); assertThat(timerCreatedRecord.getValue().getHandlerFlowNodeId()).isEqualTo("timer"); }
@Test public void shouldCreateTimerBasedOnBoundaryEvent() { // given testClient.deploy(BOUNDARY_EVENT_WORKFLOW); brokerRule.getClock().pinCurrentTime(); final long nowMs = brokerRule.getClock().getCurrentTimeInMillis(); testClient.createWorkflowInstance("process"); // when final Record<TimerRecordValue> timerCreatedRecord = RecordingExporter.timerRecords(TimerIntent.CREATED).getFirst(); final Record<WorkflowInstanceRecordValue> activityRecord = RecordingExporter.workflowInstanceRecords(WorkflowInstanceIntent.ELEMENT_ACTIVATED) .withElementId("task") .getFirst(); // then assertThat(timerCreatedRecord.getValue().getDueDate()).isEqualTo(nowMs + 1000); assertThat(timerCreatedRecord.getValue().getElementInstanceKey()) .isEqualTo(activityRecord.getKey()); assertThat(timerCreatedRecord.getValue().getHandlerFlowNodeId()).isEqualTo("timer"); }
@Test public void shouldCancelTimer() { // given final BpmnModelInstance workflow = Bpmn.createExecutableProcess(PROCESS_ID) .startEvent() .parallelGateway() .intermediateCatchEvent("timer1", c -> c.timerWithDuration("PT10S")) .endEvent() .done(); testClient.deploy(workflow); final long workflowInstanceKey = testClient.createWorkflowInstance(PROCESS_ID); // when final Record<TimerRecordValue> createdEvent = RecordingExporter.timerRecords(TimerIntent.CREATED).getFirst(); testClient.cancelWorkflowInstance(workflowInstanceKey); // then final Record<TimerRecordValue> canceledEvent = RecordingExporter.timerRecords(TimerIntent.CANCELED).getFirst(); assertThat(canceledEvent.getKey()).isEqualTo(createdEvent.getKey()); assertThat(canceledEvent.getValue()).isEqualTo(createdEvent.getValue()); assertThat(canceledEvent.getValue().getDueDate()) .isGreaterThan(brokerRule.getClock().getCurrentTimeInMillis()); }
@Test public void shouldCancelTimer() { // given final BpmnModelInstance workflow = Bpmn.createExecutableProcess(PROCESS_ID) .startEvent() .parallelGateway() .intermediateCatchEvent("timer1", c -> c.timerWithDuration("PT10S")) .endEvent() .done(); testClient.deploy(workflow); final long workflowInstanceKey = testClient.createWorkflowInstance(PROCESS_ID); // when final Record<TimerRecordValue> createdEvent = RecordingExporter.timerRecords(TimerIntent.CREATED).getFirst(); testClient.cancelWorkflowInstance(workflowInstanceKey); // then final Record<TimerRecordValue> canceledEvent = RecordingExporter.timerRecords(TimerIntent.CANCELED).getFirst(); assertThat(canceledEvent.getKey()).isEqualTo(createdEvent.getKey()); assertThat(canceledEvent.getValue()).isEqualTo(createdEvent.getValue()); assertThat(canceledEvent.getValue().getDueDate()) .isGreaterThan(brokerRule.getClock().getCurrentTimeInMillis()); }
.getFirst(); assertThat(triggeredTimer1.getValue().getDueDate()) .isLessThan(triggeredTimer2.getValue().getDueDate());
.getFirst(); assertThat(triggeredTimer1.getValue().getDueDate()) .isLessThan(triggeredTimer2.getValue().getDueDate());
@Test public void shouldCreateTimer() { // given final BpmnModelInstance workflow = Bpmn.createExecutableProcess(PROCESS_ID) .startEvent() .intermediateCatchEvent("timer", c -> c.timerWithDuration("PT10S")) .endEvent() .done(); testClient.deploy(workflow); testClient.createWorkflowInstance(PROCESS_ID); // when final Record<WorkflowInstanceRecordValue> activatedEvent = RecordingExporter.workflowInstanceRecords(WorkflowInstanceIntent.ELEMENT_ACTIVATED) .withElementId("timer") .getFirst(); // then final Record<TimerRecordValue> createdEvent = RecordingExporter.timerRecords(TimerIntent.CREATED).getFirst(); Assertions.assertThat(createdEvent.getValue()).hasElementInstanceKey(activatedEvent.getKey()); assertThat(createdEvent.getValue().getDueDate()) .isGreaterThan(brokerRule.getClock().getCurrentTimeInMillis()); }
@Test public void shouldCreateTimer() { // given final BpmnModelInstance workflow = Bpmn.createExecutableProcess(PROCESS_ID) .startEvent() .intermediateCatchEvent("timer", c -> c.timerWithDuration("PT10S")) .endEvent() .done(); testClient.deploy(workflow); testClient.createWorkflowInstance(PROCESS_ID); // when final Record<WorkflowInstanceRecordValue> activatedEvent = RecordingExporter.workflowInstanceRecords(WorkflowInstanceIntent.EVENT_ACTIVATED) .withElementId("timer") .getFirst(); // then final Record<TimerRecordValue> createdEvent = RecordingExporter.timerRecords(TimerIntent.CREATED).getFirst(); Assertions.assertThat(createdEvent.getValue()).hasElementInstanceKey(activatedEvent.getKey()); assertThat(createdEvent.getValue().getDueDate()) .isGreaterThan(brokerRule.getClock().getCurrentTimeInMillis()); }