public static WorkflowInstanceRecordStream workflowInstanceRecords( final WorkflowInstanceIntent intent) { return workflowInstanceRecords().withIntent(intent); }
public static WorkflowInstanceRecordStream workflowInstanceRecords( final WorkflowInstanceIntent intent) { return workflowInstanceRecords().withIntent(intent); }
public WorkflowInstanceRecordStream receiveWorkflowInstances() { return RecordingExporter.workflowInstanceRecords().withPartitionId(partitionId); }
public WorkflowInstanceRecordStream receiveWorkflowInstances() { return RecordingExporter.workflowInstanceRecords().withPartitionId(partitionId); }
public void printWorkflowInstanceEvents(final long key) { RecordingExporter.workflowInstanceRecords() .withWorkflowInstanceKey(key) .forEach( event -> { System.out.println("> " + event.toJson()); }); }
public void printWorkflowInstanceEvents(final long key) { RecordingExporter.workflowInstanceRecords() .withWorkflowInstanceKey(key) .forEach( event -> { System.out.println("> " + event.toJson()); }); }
/** * Blocks and wait until the workflow identified by the key has been completed. * * @param workflowInstanceKey ID of the workflow */ public void awaitWorkflowCompletion(long workflowInstanceKey) { TestUtil.waitUntil( () -> workflowInstanceRecords(WorkflowInstanceIntent.ELEMENT_COMPLETED) .filter(r -> r.getKey() == workflowInstanceKey) .exists()); }
/** * Blocks and wait until the workflow identified by the key has been completed. * * @param workflowInstanceKey ID of the workflow */ public void awaitWorkflowCompletion(long workflowInstanceKey) { TestUtil.waitUntil( () -> workflowInstanceRecords(WorkflowInstanceIntent.ELEMENT_COMPLETED) .filter(r -> r.getKey() == workflowInstanceKey) .exists()); }
public WorkflowInstanceAssert hasElementPayload( String elementId, String key, Object expectedValue) { final Optional<Record<WorkflowInstanceRecordValue>> record = RecordingExporter.workflowInstanceRecords() .withWorkflowInstanceKey(workflowInstanceKey) .withElementId(elementId) .filter(r -> ELEMENT_PASSED_INTENTS.contains(r.getMetadata().getIntent())) .findFirst(); if (record.isPresent()) { hasPayload(record.get(), key, expectedValue); } else { failWithMessage("Expected <%s> to contain payload but element was not passed", elementId); } return this; }
public WorkflowInstanceAssert hasPayload(String key, Object expectedValue) { final Optional<Record<WorkflowInstanceRecordValue>> record = RecordingExporter.workflowInstanceRecords() .withWorkflowInstanceKey(workflowInstanceKey) .withKey(workflowInstanceKey) .filter(intent(INSTANCE_ENDED_INTENTS)) .findFirst(); if (record.isPresent()) { hasPayload(record.get(), key, expectedValue); } else { failWithMessage("Expected workflow instance to contain payload but instance is not ended"); } return this; }
public WorkflowInstanceAssert hasPayload(String key, Object expectedValue) { final Optional<Record<WorkflowInstanceRecordValue>> record = RecordingExporter.workflowInstanceRecords() .withWorkflowInstanceKey(workflowInstanceKey) .withKey(workflowInstanceKey) .filter(intent(INSTANCE_ENDED_INTENTS)) .findFirst(); if (record.isPresent()) { hasPayload(record.get(), key, expectedValue); } else { failWithMessage("Expected workflow instance to contain payload but instance is not ended"); } return this; }
public static void assertWorkflowInstancePayload( WorkflowInstanceIntent instanceIntent, String expectedPayload) { final Record<WorkflowInstanceRecordValue> record = RecordingExporter.workflowInstanceRecords(instanceIntent).getFirst(); assertWorkflowInstancePayload(record, expectedPayload); }
public static void assertWorkflowInstancePayload( WorkflowInstanceIntent instanceIntent, String expectedPayload) { final Record<WorkflowInstanceRecordValue> record = RecordingExporter.workflowInstanceRecords(instanceIntent).getFirst(); assertWorkflowInstancePayload(record, expectedPayload); }
public WorkflowInstanceAssert isEnded() { final boolean isEnded = exists( RecordingExporter.workflowInstanceRecords() .withWorkflowInstanceKey(workflowInstanceKey) .withKey(workflowInstanceKey) .filter(intent(INSTANCE_ENDED_INTENTS))); if (!isEnded) { failWithMessage("Expected workflow instance to be <ended> but was <active>"); } return this; }
public WorkflowInstanceAssert isEnded() { final boolean isEnded = exists( RecordingExporter.workflowInstanceRecords() .withWorkflowInstanceKey(workflowInstanceKey) .withKey(workflowInstanceKey) .filter(intent(INSTANCE_ENDED_INTENTS))); if (!isEnded) { failWithMessage("Expected workflow instance to be <ended> but was <active>"); } return this; }
private void assertThatWorkflowInstanceCompletedAfter( String elementId, WorkflowInstanceIntent intent) { final Record<WorkflowInstanceRecordValue> lastEvent = RecordingExporter.workflowInstanceRecords(intent).withElementId(elementId).getFirst(); final Record<WorkflowInstanceRecordValue> completedEvent = RecordingExporter.workflowInstanceRecords(WorkflowInstanceIntent.ELEMENT_COMPLETED) .withElementId(PROCESS_ID) .getFirst(); assertThat(completedEvent.getPosition()).isGreaterThan(lastEvent.getPosition()); } }
private void assertThatWorkflowInstanceCompletedAfter( String elementId, WorkflowInstanceIntent intent) { final Record<WorkflowInstanceRecordValue> lastEvent = RecordingExporter.workflowInstanceRecords(intent).withElementId(elementId).getFirst(); final Record<WorkflowInstanceRecordValue> completedEvent = RecordingExporter.workflowInstanceRecords(WorkflowInstanceIntent.ELEMENT_COMPLETED) .withElementId(PROCESS_ID) .getFirst(); assertThat(completedEvent.getPosition()).isGreaterThan(lastEvent.getPosition()); } }
@Test public void shouldTriggerHandlerNodeWhenAttachedToActivity() { // given testClient.deploy(BOUNDARY_EVENT_WORKFLOW); testClient.createWorkflowInstance("process"); // when RecordingExporter.timerRecords(TimerIntent.CREATED).getFirst(); brokerRule.getClock().addTime(Duration.ofSeconds(10)); // then assertThat( RecordingExporter.workflowInstanceRecords(WorkflowInstanceIntent.EVENT_TRIGGERING) .withElementId("timer") .getFirst()) .isNotNull(); }
@Test public void shouldCorrelateCorrectBoundaryEvent() { // given testClient.deploy(BOUNDARY_EVENTS_WORKFLOW); testClient.createWorkflowInstance(PROCESS_ID, asMsgPack("key", "123")); // when awaitSubscriptionsOpened(3); testClient.publishMessage("msg1", "123", asMsgPack("foo", 1)); // then assertThat(RecordingExporter.workflowInstanceRecords().limitToWorkflowInstanceCompleted()) .filteredOn(r -> r.getMetadata().getIntent() == WorkflowInstanceIntent.EVENT_ACTIVATED) .extracting(Record::getValue) .extracting(WorkflowInstanceRecordValue::getElementId) .contains("msg1End") .doesNotContain("taskEnd", "msg2End"); }
@Test public void shouldNotTriggerBoundaryEventIfReceiveTaskTriggeredFirst() { // given testClient.deploy(BOUNDARY_EVENTS_WORKFLOW); testClient.createWorkflowInstance(PROCESS_ID, asMsgPack("key", "123")); // when awaitSubscriptionsOpened(3); testClient.publishMessage("taskMsg", "123", asMsgPack("foo", 1)); // then assertThat(RecordingExporter.workflowInstanceRecords().limitToWorkflowInstanceCompleted()) .filteredOn(r -> r.getMetadata().getIntent() == WorkflowInstanceIntent.EVENT_ACTIVATED) .extracting(Record::getValue) .extracting(WorkflowInstanceRecordValue::getElementId) .contains("taskEnd") .doesNotContain("msg1End", "msg2End"); }