public TimerRecordStream withElementInstanceKey(final long elementInstanceKey) { return valueFilter(v -> v.getElementInstanceKey() == elementInstanceKey); }
public TimerRecordStream withElementInstanceKey(final long elementInstanceKey) { return valueFilter(v -> v.getElementInstanceKey() == elementInstanceKey); }
/** * Verifies that the actual TimerRecordValue's elementInstanceKey is equal to the given one. * @param elementInstanceKey the given elementInstanceKey to compare the actual TimerRecordValue's elementInstanceKey to. * @return this assertion object. * @throws AssertionError - if the actual TimerRecordValue's elementInstanceKey is not equal to the given one. */ public S hasElementInstanceKey(long elementInstanceKey) { // 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 elementInstanceKey of:\n <%s>\nto be:\n <%s>\nbut was:\n <%s>"; // check long actualElementInstanceKey = actual.getElementInstanceKey(); if (actualElementInstanceKey != elementInstanceKey) { failWithMessage(assertjErrorMessage, actual, elementInstanceKey, actualElementInstanceKey); } // return the current assertion for method chaining return myself; }
@Test public void shouldSubscribeToBoundaryEventTriggersOnReady() { // given testClient.deploy(WITH_BOUNDARY_EVENTS); testClient.createWorkflowInstance(PROCESS_ID); // when final Record<WorkflowInstanceRecordValue> readyRecord = testClient.receiveElementInState("task", WorkflowInstanceIntent.ELEMENT_READY); final Record<WorkflowInstanceRecordValue> activatedRecord = testClient.receiveElementInState("task", WorkflowInstanceIntent.ELEMENT_ACTIVATED); final List<Record<TimerRecordValue>> subscriptions = Arrays.asList( testClient.receiveTimerRecord("timer1", TimerIntent.CREATE), testClient.receiveTimerRecord("timer2", TimerIntent.CREATE)); // then assertThat(subscriptions).hasSize(2); for (final Record<TimerRecordValue> subscription : subscriptions) { assertThat(subscription.getPosition()) .isBetween(readyRecord.getPosition(), activatedRecord.getPosition()); assertThat(subscription.getValue().getElementInstanceKey()).isEqualTo(readyRecord.getKey()); } }
@Test public void shouldSubscribeToBoundaryEventTriggersOnReady() { // given testClient.deploy(WITH_BOUNDARY_EVENTS); testClient.createWorkflowInstance(PROCESS_ID); // when final Record<WorkflowInstanceRecordValue> readyRecord = testClient.receiveElementInState("task", WorkflowInstanceIntent.ELEMENT_ACTIVATING); final Record<WorkflowInstanceRecordValue> activatedRecord = testClient.receiveElementInState("task", WorkflowInstanceIntent.ELEMENT_ACTIVATED); final List<Record<TimerRecordValue>> subscriptions = Arrays.asList( testClient.receiveTimerRecord("timer1", TimerIntent.CREATE), testClient.receiveTimerRecord("timer2", TimerIntent.CREATE)); // then assertThat(subscriptions).hasSize(2); for (final Record<TimerRecordValue> subscription : subscriptions) { assertThat(subscription.getPosition()) .isBetween(readyRecord.getPosition(), activatedRecord.getPosition()); assertThat(subscription.getValue().getElementInstanceKey()).isEqualTo(readyRecord.getKey()); } }
@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 shouldCreateTimer() { // given testClient.deploy(WORKFLOW_WITH_TIMERS); // when testClient.createWorkflowInstance(PROCESS_ID); // then final Record<WorkflowInstanceRecordValue> gatewayEvent = RecordingExporter.workflowInstanceRecords(WorkflowInstanceIntent.GATEWAY_ACTIVATED) .getFirst(); final List<Record<TimerRecordValue>> timerEvents = RecordingExporter.timerRecords(TimerIntent.CREATED).limit(2).asList(); assertThat(timerEvents) .hasSize(2) .extracting( r -> tuple(r.getValue().getHandlerFlowNodeId(), r.getValue().getElementInstanceKey())) .contains(tuple("timer-1", gatewayEvent.getKey()), tuple("timer-2", gatewayEvent.getKey())); }
@Test public void shouldCreateTimer() { // given testClient.deploy(WORKFLOW_WITH_TIMERS); // when testClient.createWorkflowInstance(PROCESS_ID); // then final Record<WorkflowInstanceRecordValue> gatewayEvent = RecordingExporter.workflowInstanceRecords(WorkflowInstanceIntent.ELEMENT_ACTIVATED) .withElementType(BpmnElementType.EVENT_BASED_GATEWAY) .getFirst(); final List<Record<TimerRecordValue>> timerEvents = RecordingExporter.timerRecords(TimerIntent.CREATED).limit(2).asList(); assertThat(timerEvents) .hasSize(2) .extracting( r -> tuple(r.getValue().getHandlerFlowNodeId(), r.getValue().getElementInstanceKey())) .contains(tuple("timer-1", gatewayEvent.getKey()), tuple("timer-2", gatewayEvent.getKey())); }