public TimerRecordStream withHandlerNodeId(final String handlerNodeId) { return valueFilter(v -> v.getHandlerFlowNodeId().equals(handlerNodeId)); }
public TimerRecordStream withHandlerNodeId(final String handlerNodeId) { return valueFilter(v -> v.getHandlerFlowNodeId().equals(handlerNodeId)); }
/** * Verifies that the actual TimerRecordValue's handlerFlowNodeId is equal to the given one. * @param handlerFlowNodeId the given handlerFlowNodeId to compare the actual TimerRecordValue's handlerFlowNodeId to. * @return this assertion object. * @throws AssertionError - if the actual TimerRecordValue's handlerFlowNodeId is not equal to the given one. */ public S hasHandlerFlowNodeId(String handlerFlowNodeId) { // 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 handlerFlowNodeId of:\n <%s>\nto be:\n <%s>\nbut was:\n <%s>"; // null safe check String actualHandlerFlowNodeId = actual.getHandlerFlowNodeId(); if (!Objects.areEqual(actualHandlerFlowNodeId, handlerFlowNodeId)) { failWithMessage(assertjErrorMessage, actual, handlerFlowNodeId, actualHandlerFlowNodeId); } // return the current assertion for method chaining return myself; }
@Test public void shouldCancelTimer() { // given testClient.deploy(WORKFLOW_WITH_TIMERS); testClient.createWorkflowInstance(PROCESS_ID, asMsgPack("key", "123")); assertThat(RecordingExporter.timerRecords(TimerIntent.CREATED).limit(2).exists()).isTrue(); // when brokerRule.getClock().addTime(Duration.ofSeconds(1)); // then assertThat(RecordingExporter.timerRecords(TimerIntent.CANCELED).limit(1)) .extracting(r -> r.getValue().getHandlerFlowNodeId()) .hasSize(1) .contains("timer-2"); }
@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 testClient.deploy(WORKFLOW_WITH_TIMERS); testClient.createWorkflowInstance(PROCESS_ID, asMsgPack("key", "123")); assertThat(RecordingExporter.timerRecords(TimerIntent.CREATED).limit(2).exists()); // when brokerRule.getClock().addTime(Duration.ofSeconds(1)); // then assertThat(RecordingExporter.timerRecords(TimerIntent.CANCELED).limit(1)) .extracting(r -> r.getValue().getHandlerFlowNodeId()) .hasSize(1) .contains("timer-2"); }
RecordingExporter.timerRecords(TimerIntent.CREATE) .limit(2) .map(r -> r.getValue().getHandlerFlowNodeId()) .collect(Collectors.toList());
RecordingExporter.timerRecords(TimerIntent.CREATE) .limit(2) .map(r -> r.getValue().getHandlerFlowNodeId()) .collect(Collectors.toList());
@Test public void shouldCancelSubscriptionsWhenScopeIsTerminated() { // given testClient.deploy(WORKFLOW_WITH_TIMER_AND_MESSAGE); final long workflowInstanceKey = testClient.createWorkflowInstance(PROCESS_ID, asMsgPack("key", "123")); assertThat(RecordingExporter.timerRecords(TimerIntent.CREATED).limit(1).exists()).isTrue(); assertThat( RecordingExporter.workflowInstanceSubscriptionRecords( WorkflowInstanceSubscriptionIntent.OPENED) .limit(1) .exists()) .isTrue(); // when testClient.cancelWorkflowInstance(workflowInstanceKey); // then assertThat(RecordingExporter.timerRecords(TimerIntent.CANCELED).limit(1)) .extracting(r -> r.getValue().getHandlerFlowNodeId()) .hasSize(1) .contains("timer"); assertThat( RecordingExporter.workflowInstanceSubscriptionRecords( WorkflowInstanceSubscriptionIntent.CLOSED) .limit(1)) .extracting(r -> r.getValue().getMessageName()) .hasSize(1) .contains("msg"); }
@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 shouldCancelSubscriptionsWhenScopeIsTerminated() { // given testClient.deploy(WORKFLOW_WITH_TIMER_AND_MESSAGE); final long workflowInstanceKey = testClient.createWorkflowInstance(PROCESS_ID, asMsgPack("key", "123")); assertThat(RecordingExporter.timerRecords(TimerIntent.CREATED).limit(1).exists()); assertThat( RecordingExporter.workflowInstanceSubscriptionRecords( WorkflowInstanceSubscriptionIntent.OPENED) .limit(1) .exists()); // when testClient.cancelWorkflowInstance(workflowInstanceKey); // then assertThat(RecordingExporter.timerRecords(TimerIntent.CANCELED).limit(1)) .extracting(r -> r.getValue().getHandlerFlowNodeId()) .hasSize(1) .contains("timer"); assertThat( RecordingExporter.workflowInstanceSubscriptionRecords( WorkflowInstanceSubscriptionIntent.CLOSED) .limit(1)) .extracting(r -> r.getValue().getMessageName()) .hasSize(1) .contains("msg"); }
@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())); }