@Test public void shouldOpenWorkflowInstanceSubscription() { final long workflowInstanceKey = testClient.createWorkflowInstance(PROCESS_ID, asMsgPack("orderId", "order-123")); final Record<WorkflowInstanceRecordValue> catchEventEntered = testClient.receiveElementInState("receive-message", enteredState); final Record<WorkflowInstanceSubscriptionRecordValue> workflowInstanceSubscription = testClient .receiveWorkflowInstanceSubscriptions() .withIntent(WorkflowInstanceSubscriptionIntent.OPENED) .getFirst(); assertThat(workflowInstanceSubscription.getMetadata().getValueType()) .isEqualTo(ValueType.WORKFLOW_INSTANCE_SUBSCRIPTION); assertThat(workflowInstanceSubscription.getMetadata().getRecordType()) .isEqualTo(RecordType.EVENT); assertWorkflowSubscription( workflowInstanceKey, catchEventEntered, workflowInstanceSubscription); }
@Test public void shouldOpenWorkflowInstanceSubscription() { final long workflowInstanceKey = testClient.createWorkflowInstance(PROCESS_ID, asMsgPack("orderId", "order-123")); final Record<WorkflowInstanceRecordValue> catchEventEntered = testClient.receiveElementInState("receive-message", enteredState); final Record<WorkflowInstanceSubscriptionRecordValue> workflowInstanceSubscription = testClient .receiveWorkflowInstanceSubscriptions() .withIntent(WorkflowInstanceSubscriptionIntent.OPENED) .getFirst(); assertThat(workflowInstanceSubscription.getMetadata().getValueType()) .isEqualTo(ValueType.WORKFLOW_INSTANCE_SUBSCRIPTION); assertThat(workflowInstanceSubscription.getMetadata().getRecordType()) .isEqualTo(RecordType.EVENT); assertWorkflowSubscription( workflowInstanceKey, catchEventEntered, workflowInstanceSubscription); }
@Test public void shouldCorrelateMessageAndContinue() { // given testClient.createWorkflowInstance(PROCESS_ID, asMsgPack("orderId", "order-123")); // when assertThat( testClient .receiveWorkflowInstanceSubscriptions() .withMessageName("order canceled") .withIntent(WorkflowInstanceSubscriptionIntent.OPENED) .limit(1) .getFirst()) .isNotNull(); testClient.publishMessage("order canceled", "order-123"); // then assertThat( RecordingExporter.workflowInstanceRecords(continueState) .withElementId(continuedElementId) .exists()) .isTrue(); assertThat( RecordingExporter.workflowInstanceRecords(WorkflowInstanceIntent.SEQUENCE_FLOW_TAKEN) .withElementId("to-end") .exists()) .isTrue(); } }
@Test public void shouldCorrelateMessageAndContinue() { // given testClient.createWorkflowInstance(PROCESS_ID, asMsgPack("orderId", "order-123")); // when assertThat( testClient .receiveWorkflowInstanceSubscriptions() .withMessageName("order canceled") .withIntent(WorkflowInstanceSubscriptionIntent.OPENED) .limit(1) .getFirst()) .isNotNull(); testClient.publishMessage("order canceled", "order-123"); // then assertThat( RecordingExporter.workflowInstanceRecords(continueState) .withElementId(continuedElementId) .exists()) .isTrue(); assertThat( RecordingExporter.workflowInstanceRecords(WorkflowInstanceIntent.SEQUENCE_FLOW_TAKEN) .withElementId("to-end") .exists()) .isTrue(); } }
@Test public void shouldCorrelateWorkflowInstanceSubscription() { // given final long workflowInstanceKey = testClient.createWorkflowInstance(PROCESS_ID, asMsgPack("orderId", "order-123")); final Record<WorkflowInstanceRecordValue> catchEventEntered = testClient.receiveElementInState("receive-message", enteredState); // when final DirectBuffer messagePayload = asMsgPack("foo", "bar"); testClient.publishMessage("order canceled", "order-123", messagePayload); // then final Record<WorkflowInstanceSubscriptionRecordValue> subscription = testClient .receiveWorkflowInstanceSubscriptions() .withIntent(WorkflowInstanceSubscriptionIntent.CORRELATED) .getFirst(); assertThat(subscription.getMetadata().getValueType()) .isEqualTo(ValueType.WORKFLOW_INSTANCE_SUBSCRIPTION); assertThat(subscription.getMetadata().getRecordType()).isEqualTo(RecordType.EVENT); assertWorkflowSubscription( workflowInstanceKey, "{\"foo\":\"bar\"}", catchEventEntered, subscription); }
@Test public void shouldCorrelateWorkflowInstanceSubscription() { // given final long workflowInstanceKey = testClient.createWorkflowInstance(PROCESS_ID, asMsgPack("orderId", "order-123")); final Record<WorkflowInstanceRecordValue> catchEventEntered = testClient.receiveElementInState("receive-message", enteredState); // when final DirectBuffer messagePayload = asMsgPack("foo", "bar"); testClient.publishMessage("order canceled", "order-123", messagePayload); // then final Record<WorkflowInstanceSubscriptionRecordValue> subscription = testClient .receiveWorkflowInstanceSubscriptions() .withIntent(WorkflowInstanceSubscriptionIntent.CORRELATED) .getFirst(); assertThat(subscription.getMetadata().getValueType()) .isEqualTo(ValueType.WORKFLOW_INSTANCE_SUBSCRIPTION); assertThat(subscription.getMetadata().getRecordType()).isEqualTo(RecordType.EVENT); assertWorkflowSubscription( workflowInstanceKey, "{\"foo\":\"bar\"}", catchEventEntered, subscription); }
.withMessageName(messageNames.get(1)) .onlyCommandRejections() .getFirst() .getMetadata()) .hasRecordType(RecordType.COMMAND_REJECTION)
@Test public void shouldCloseWorkflowInstanceSubscription() { final long workflowInstanceKey = testClient.createWorkflowInstance(PROCESS_ID, asMsgPack("orderId", "order-123")); final Record<WorkflowInstanceRecordValue> catchEventEntered = testClient.receiveElementInState("receive-message", enteredState); testClient.cancelWorkflowInstance(workflowInstanceKey); final Record<WorkflowInstanceSubscriptionRecordValue> subscription = RecordingExporter.workflowInstanceSubscriptionRecords( WorkflowInstanceSubscriptionIntent.CLOSED) .getFirst(); assertThat(subscription.getMetadata().getRecordType()).isEqualTo(RecordType.EVENT); Assertions.assertThat(subscription.getValue()) .hasWorkflowInstanceKey(workflowInstanceKey) .hasElementInstanceKey(catchEventEntered.getKey()) .hasMessageName("order canceled"); }
@Test public void shouldCloseWorkflowInstanceSubscription() { final long workflowInstanceKey = testClient.createWorkflowInstance(PROCESS_ID, asMsgPack("orderId", "order-123")); final Record<WorkflowInstanceRecordValue> catchEventEntered = testClient.receiveElementInState("receive-message", enteredState); testClient.cancelWorkflowInstance(workflowInstanceKey); final Record<WorkflowInstanceSubscriptionRecordValue> subscription = RecordingExporter.workflowInstanceSubscriptionRecords( WorkflowInstanceSubscriptionIntent.CLOSED) .getFirst(); assertThat(subscription.getMetadata().getRecordType()).isEqualTo(RecordType.EVENT); Assertions.assertThat(subscription.getValue()) .hasWorkflowInstanceKey(workflowInstanceKey) .hasElementInstanceKey(catchEventEntered.getKey()) .hasMessageName("order canceled"); }
.withMessageName(messageNames.get(1)) .onlyCommandRejections() .getFirst() .getMetadata()) .hasRecordType(RecordType.COMMAND_REJECTION)
@Test public void shouldContinueWhenMessageIsCorrelated() { // given testClient.deploy(WORKFLOW_WITH_MESSAGES); testClient.createWorkflowInstance(PROCESS_ID, asMsgPack("key", "123")); final Record<WorkflowInstanceRecordValue> gatewayEvent = RecordingExporter.workflowInstanceRecords(WorkflowInstanceIntent.ELEMENT_ACTIVATED) .withElementType(BpmnElementType.EVENT_BASED_GATEWAY) .getFirst(); // when testClient.publishMessage("msg-1", "123"); // then final Record<WorkflowInstanceSubscriptionRecordValue> triggeredEvent = RecordingExporter.workflowInstanceSubscriptionRecords( WorkflowInstanceSubscriptionIntent.CORRELATED) .getFirst(); Assertions.assertThat(triggeredEvent.getValue()) .hasElementInstanceKey(gatewayEvent.getKey()) .hasMessageName("msg-1"); assertThat( RecordingExporter.workflowInstanceRecords(WorkflowInstanceIntent.SEQUENCE_FLOW_TAKEN) .withElementId("to-end1") .exists()) .isTrue(); assertThat( RecordingExporter.workflowInstanceRecords(WorkflowInstanceIntent.ELEMENT_COMPLETED) .withElementId(PROCESS_ID) .exists()) .isTrue(); }
@Test public void shouldContinueWhenMessageIsCorrelated() { // given testClient.deploy(WORKFLOW_WITH_MESSAGES); testClient.createWorkflowInstance(PROCESS_ID, asMsgPack("key", "123")); final Record<WorkflowInstanceRecordValue> gatewayEvent = RecordingExporter.workflowInstanceRecords(WorkflowInstanceIntent.GATEWAY_ACTIVATED) .getFirst(); // when testClient.publishMessage("msg-1", "123"); // then final Record<WorkflowInstanceSubscriptionRecordValue> triggeredEvent = RecordingExporter.workflowInstanceSubscriptionRecords( WorkflowInstanceSubscriptionIntent.CORRELATED) .getFirst(); Assertions.assertThat(triggeredEvent.getValue()) .hasElementInstanceKey(gatewayEvent.getKey()) .hasMessageName("msg-1"); assertThat( RecordingExporter.workflowInstanceRecords(WorkflowInstanceIntent.SEQUENCE_FLOW_TAKEN) .withElementId("to-end1") .exists()) .isTrue(); assertThat( RecordingExporter.workflowInstanceRecords(WorkflowInstanceIntent.ELEMENT_COMPLETED) .withElementId(PROCESS_ID) .exists()); }