@Test public void shouldOpenMessageSubscription() { final long workflowInstanceKey = testClient.createWorkflowInstance(PROCESS_ID, asMsgPack("orderId", "order-123")); final Record<WorkflowInstanceRecordValue> catchEventEntered = testClient.receiveElementInState("receive-message", enteredState); final Record<MessageSubscriptionRecordValue> messageSubscription = RecordingExporter.messageSubscriptionRecords(MessageSubscriptionIntent.OPENED).getFirst(); assertThat(messageSubscription.getMetadata().getValueType()) .isEqualTo(ValueType.MESSAGE_SUBSCRIPTION); assertThat(messageSubscription.getMetadata().getRecordType()).isEqualTo(RecordType.EVENT); assertMessageSubscription( workflowInstanceKey, "order-123", catchEventEntered, messageSubscription); }
@Test public void shouldOpenMessageSubscription() { final long workflowInstanceKey = testClient.createWorkflowInstance(PROCESS_ID, asMsgPack("orderId", "order-123")); final Record<WorkflowInstanceRecordValue> catchEventEntered = testClient.receiveElementInState("receive-message", enteredState); final Record<MessageSubscriptionRecordValue> messageSubscription = RecordingExporter.messageSubscriptionRecords(MessageSubscriptionIntent.OPENED).getFirst(); assertThat(messageSubscription.getMetadata().getValueType()) .isEqualTo(ValueType.MESSAGE_SUBSCRIPTION); assertThat(messageSubscription.getMetadata().getRecordType()).isEqualTo(RecordType.EVENT); assertMessageSubscription( workflowInstanceKey, "order-123", catchEventEntered, messageSubscription); }
@Test public void shouldCorrelateMessageSubscription() { // given final long workflowInstanceKey = testClient.createWorkflowInstance(PROCESS_ID, asMsgPack("orderId", "order-123")); final Record<WorkflowInstanceRecordValue> catchEventEntered = testClient.receiveElementInState("receive-message", enteredState); // when testClient.publishMessage("order canceled", "order-123", asMsgPack("foo", "bar")); // then final Record<MessageSubscriptionRecordValue> subscription = testClient .receiveMessageSubscriptions() .withIntent(MessageSubscriptionIntent.CORRELATED) .getFirst(); assertThat(subscription.getMetadata().getValueType()).isEqualTo(ValueType.MESSAGE_SUBSCRIPTION); assertThat(subscription.getMetadata().getRecordType()).isEqualTo(RecordType.EVENT); assertMessageSubscription(workflowInstanceKey, catchEventEntered, subscription); }
@Test public void shouldCorrelateMessageSubscription() { // given final long workflowInstanceKey = testClient.createWorkflowInstance(PROCESS_ID, asMsgPack("orderId", "order-123")); final Record<WorkflowInstanceRecordValue> catchEventEntered = testClient.receiveElementInState("receive-message", enteredState); // when testClient.publishMessage("order canceled", "order-123", asMsgPack("foo", "bar")); // then final Record<MessageSubscriptionRecordValue> subscription = testClient .receiveMessageSubscriptions() .withIntent(MessageSubscriptionIntent.CORRELATED) .getFirst(); assertThat(subscription.getMetadata().getValueType()).isEqualTo(ValueType.MESSAGE_SUBSCRIPTION); assertThat(subscription.getMetadata().getRecordType()).isEqualTo(RecordType.EVENT); assertMessageSubscription(workflowInstanceKey, catchEventEntered, subscription); }
@Test public void shouldCloseMessageSubscription() { // given final long workflowInstanceKey = testClient.createWorkflowInstance(PROCESS_ID, asMsgPack("orderId", "order-123")); final Record<WorkflowInstanceRecordValue> catchEventEntered = testClient.receiveElementInState("receive-message", enteredState); // when testClient.cancelWorkflowInstance(workflowInstanceKey); // then final Record<MessageSubscriptionRecordValue> messageSubscription = RecordingExporter.messageSubscriptionRecords(MessageSubscriptionIntent.CLOSED).getFirst(); assertThat(messageSubscription.getMetadata().getRecordType()).isEqualTo(RecordType.EVENT); Assertions.assertThat(messageSubscription.getValue()) .hasWorkflowInstanceKey(workflowInstanceKey) .hasElementInstanceKey(catchEventEntered.getKey()) .hasMessageName("order canceled") .hasCorrelationKey(""); }
@Test public void shouldCloseMessageSubscription() { // given final long workflowInstanceKey = testClient.createWorkflowInstance(PROCESS_ID, asMsgPack("orderId", "order-123")); final Record<WorkflowInstanceRecordValue> catchEventEntered = testClient.receiveElementInState("receive-message", enteredState); // when testClient.cancelWorkflowInstance(workflowInstanceKey); // then final Record<MessageSubscriptionRecordValue> messageSubscription = RecordingExporter.messageSubscriptionRecords(MessageSubscriptionIntent.CLOSED).getFirst(); assertThat(messageSubscription.getMetadata().getRecordType()).isEqualTo(RecordType.EVENT); Assertions.assertThat(messageSubscription.getValue()) .hasWorkflowInstanceKey(workflowInstanceKey) .hasElementInstanceKey(catchEventEntered.getKey()) .hasMessageName("order canceled") .hasCorrelationKey(""); }