public WorkflowInstanceSubscriptionRecordStream withElementInstanceKey( final long elementInstanceKey) { return valueFilter(v -> v.getElementInstanceKey() == elementInstanceKey); }
public WorkflowInstanceSubscriptionRecordStream withMessageName(final String messageName) { return valueFilter(v -> messageName.equals(v.getMessageName())); } }
public WorkflowInstanceSubscriptionRecordStream withWorkflowInstanceKey( final long workflowInstanceKey) { return valueFilter(v -> v.getWorkflowInstanceKey() == workflowInstanceKey); }
@Test public void shouldOpenWorkflowInstanceSubscriptions() { // given testClient.deploy(WORKFLOW_WITH_MESSAGES); // when testClient.createWorkflowInstance(PROCESS_ID, asMsgPack("key", "123")); // then final Record<WorkflowInstanceRecordValue> gatewayEvent = RecordingExporter.workflowInstanceRecords(WorkflowInstanceIntent.GATEWAY_ACTIVATED) .getFirst(); final List<Record<WorkflowInstanceSubscriptionRecordValue>> subscriptionEvents = RecordingExporter.workflowInstanceSubscriptionRecords( WorkflowInstanceSubscriptionIntent.OPENED) .limit(2) .asList(); assertThat(subscriptionEvents) .hasSize(2) .extracting(r -> tuple(r.getValue().getMessageName(), r.getValue().getElementInstanceKey())) .contains(tuple("msg-1", gatewayEvent.getKey()), tuple("msg-2", gatewayEvent.getKey())); }
public static void assertWorkflowSubscription( long workflowInstanceKey, Record catchEventEntered, Record<WorkflowInstanceSubscriptionRecordValue> subscription) { Assertions.assertThat(subscription.getValue()) .hasWorkflowInstanceKey(workflowInstanceKey) .hasElementInstanceKey(catchEventEntered.getKey()) .hasMessageName("order canceled"); assertThat(subscription.getValue().getPayload()).isEqualTo("{}"); }
@Test public void shouldOpenWorkflowInstanceSubscriptions() { // given testClient.deploy(WORKFLOW_WITH_MESSAGES); // when testClient.createWorkflowInstance(PROCESS_ID, asMsgPack("key", "123")); // then final Record<WorkflowInstanceRecordValue> gatewayEvent = RecordingExporter.workflowInstanceRecords(WorkflowInstanceIntent.ELEMENT_ACTIVATED) .withElementType(BpmnElementType.EVENT_BASED_GATEWAY) .getFirst(); final List<Record<WorkflowInstanceSubscriptionRecordValue>> subscriptionEvents = RecordingExporter.workflowInstanceSubscriptionRecords( WorkflowInstanceSubscriptionIntent.OPENED) .limit(2) .asList(); assertThat(subscriptionEvents) .hasSize(2) .extracting(r -> tuple(r.getValue().getMessageName(), r.getValue().getElementInstanceKey())) .contains(tuple("msg-1", gatewayEvent.getKey()), tuple("msg-2", gatewayEvent.getKey())); }
public static void assertWorkflowSubscription( long workflowInstanceKey, String payload, Record catchEventEntered, Record<WorkflowInstanceSubscriptionRecordValue> subscription) { Assertions.assertThat(subscription.getValue()) .hasWorkflowInstanceKey(workflowInstanceKey) .hasElementInstanceKey(catchEventEntered.getKey()) .hasMessageName("order canceled"); assertThat(subscription.getValue().getPayload()).isEqualTo(payload); } }
public WorkflowInstanceSubscriptionRecordStream withMessageName(final String messageName) { return valueFilter(v -> messageName.equals(v.getMessageName())); } }
public WorkflowInstanceSubscriptionRecordStream withElementInstanceKey( final long elementInstanceKey) { return valueFilter(v -> v.getElementInstanceKey() == elementInstanceKey); }
public WorkflowInstanceSubscriptionRecordStream withWorkflowInstanceKey( final long workflowInstanceKey) { return valueFilter(v -> v.getWorkflowInstanceKey() == workflowInstanceKey); }
public static void assertWorkflowSubscription( long workflowInstanceKey, Record catchEventEntered, Record<WorkflowInstanceSubscriptionRecordValue> subscription) { Assertions.assertThat(subscription.getValue()) .hasWorkflowInstanceKey(workflowInstanceKey) .hasElementInstanceKey(catchEventEntered.getKey()) .hasMessageName("order canceled"); assertThat(subscription.getValue().getPayload()).isEqualTo("{}"); }
/** * Verifies that the actual WorkflowInstanceSubscriptionRecordValue's messageName is equal to the given one. * @param messageName the given messageName to compare the actual WorkflowInstanceSubscriptionRecordValue's messageName to. * @return this assertion object. * @throws AssertionError - if the actual WorkflowInstanceSubscriptionRecordValue's messageName is not equal to the given one. */ public S hasMessageName(String messageName) { // check that actual WorkflowInstanceSubscriptionRecordValue we want to make assertions on is not null. isNotNull(); // overrides the default error message with a more explicit one String assertjErrorMessage = "\nExpecting messageName of:\n <%s>\nto be:\n <%s>\nbut was:\n <%s>"; // null safe check String actualMessageName = actual.getMessageName(); if (!Objects.areEqual(actualMessageName, messageName)) { failWithMessage(assertjErrorMessage, actual, messageName, actualMessageName); } // return the current assertion for method chaining return myself; }
/** * Verifies that the actual WorkflowInstanceSubscriptionRecordValue's elementInstanceKey is equal to the given one. * @param elementInstanceKey the given elementInstanceKey to compare the actual WorkflowInstanceSubscriptionRecordValue's elementInstanceKey to. * @return this assertion object. * @throws AssertionError - if the actual WorkflowInstanceSubscriptionRecordValue's elementInstanceKey is not equal to the given one. */ public S hasElementInstanceKey(long elementInstanceKey) { // check that actual WorkflowInstanceSubscriptionRecordValue 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; }
/** * Verifies that the actual WorkflowInstanceSubscriptionRecordValue's workflowInstanceKey is equal to the given one. * @param workflowInstanceKey the given workflowInstanceKey to compare the actual WorkflowInstanceSubscriptionRecordValue's workflowInstanceKey to. * @return this assertion object. * @throws AssertionError - if the actual WorkflowInstanceSubscriptionRecordValue's workflowInstanceKey is not equal to the given one. */ public S hasWorkflowInstanceKey(long workflowInstanceKey) { // check that actual WorkflowInstanceSubscriptionRecordValue we want to make assertions on is not null. isNotNull(); // overrides the default error message with a more explicit one String assertjErrorMessage = "\nExpecting workflowInstanceKey of:\n <%s>\nto be:\n <%s>\nbut was:\n <%s>"; // check long actualWorkflowInstanceKey = actual.getWorkflowInstanceKey(); if (actualWorkflowInstanceKey != workflowInstanceKey) { failWithMessage(assertjErrorMessage, actual, workflowInstanceKey, actualWorkflowInstanceKey); } // return the current assertion for method chaining return myself; }
public static void assertWorkflowSubscription( long workflowInstanceKey, String payload, Record catchEventEntered, Record<WorkflowInstanceSubscriptionRecordValue> subscription) { Assertions.assertThat(subscription.getValue()) .hasWorkflowInstanceKey(workflowInstanceKey) .hasElementInstanceKey(catchEventEntered.getKey()) .hasMessageName("order canceled"); assertThat(subscription.getValue().getPayload()).isEqualTo(payload); } }
@Test public void shouldCloseWorkflowInstanceSubscription() { // given testClient.deploy(WORKFLOW_WITH_MESSAGES); testClient.createWorkflowInstance(PROCESS_ID, asMsgPack("key", "123")); assertThat( RecordingExporter.workflowInstanceSubscriptionRecords( WorkflowInstanceSubscriptionIntent.OPENED) .limit(2) .exists()) .isTrue(); // when testClient.publishMessage("msg-1", "123"); // then assertThat( RecordingExporter.workflowInstanceSubscriptionRecords( WorkflowInstanceSubscriptionIntent.CLOSED) .limit(1)) .extracting(r -> r.getValue().getMessageName()) .hasSize(1) .contains("msg-2"); }
WorkflowInstanceSubscriptionIntent.CORRELATE) .limit(2) .map(r -> r.getValue().getMessageName()) .collect(Collectors.toList());
WorkflowInstanceSubscriptionIntent.CORRELATE) .limit(2) .map(r -> r.getValue().getMessageName()) .collect(Collectors.toList());
@Test public void shouldCloseWorkflowInstanceSubscription() { // given testClient.deploy(WORKFLOW_WITH_MESSAGES); testClient.createWorkflowInstance(PROCESS_ID, asMsgPack("key", "123")); assertThat( RecordingExporter.workflowInstanceSubscriptionRecords( WorkflowInstanceSubscriptionIntent.OPENED) .limit(2) .exists()); // when testClient.publishMessage("msg-1", "123"); // then assertThat( RecordingExporter.workflowInstanceSubscriptionRecords( WorkflowInstanceSubscriptionIntent.CLOSED) .limit(1)) .extracting(r -> r.getValue().getMessageName()) .hasSize(1) .contains("msg-2"); }
@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"); }