@Test public void shouldCloseSubscriptionForOldVersions() { // given testClient.deploy(createWorkflowWithOneMessageStartEvent()); // when testClient.deploy(createWorkflowWithOneMessageStartEvent()); // then final List<Record<MessageStartEventSubscriptionRecordValue>> subscriptions = RecordingExporter.messageStartEventSubscriptionRecords().limit(6).asList(); final List<Intent> intents = subscriptions.stream().map(s -> s.getMetadata().getIntent()).collect(Collectors.toList()); assertThat(intents) .containsExactly( MessageStartEventSubscriptionIntent.OPEN, MessageStartEventSubscriptionIntent.OPENED, MessageStartEventSubscriptionIntent.CLOSE, // close old version MessageStartEventSubscriptionIntent.OPEN, // open new MessageStartEventSubscriptionIntent.CLOSED, MessageStartEventSubscriptionIntent.OPENED); final long closingWorkflowKey = subscriptions.get(2).getValue().getWorkflowKey(); assertThat(closingWorkflowKey).isEqualTo(subscriptions.get(0).getValue().getWorkflowKey()); }
@Test public void shouldCloseSubscriptionForOldVersions() { // given testClient.deploy(createWorkflowWithOneMessageStartEvent()); // when testClient.deploy(createWorkflowWithOneMessageStartEvent()); // then final List<Record<MessageStartEventSubscriptionRecordValue>> subscriptions = RecordingExporter.messageStartEventSubscriptionRecords().limit(6).asList(); final List<Intent> intents = subscriptions.stream().map(s -> s.getMetadata().getIntent()).collect(Collectors.toList()); assertThat(intents) .containsExactly( MessageStartEventSubscriptionIntent.OPEN, MessageStartEventSubscriptionIntent.OPENED, MessageStartEventSubscriptionIntent.CLOSE, // close old version MessageStartEventSubscriptionIntent.OPEN, // open new MessageStartEventSubscriptionIntent.CLOSED, MessageStartEventSubscriptionIntent.OPENED); final long closingWorkflowKey = subscriptions.get(2).getValue().getWorkflowKey(); assertThat(closingWorkflowKey).isEqualTo(subscriptions.get(0).getValue().getWorkflowKey()); }
@Test public void shouldOpenSubscriptionsForAllMessageStartEvents() { // when testClient.deploy(createWorkflowWithTwoMessageStartEvent()); final List<Record<MessageStartEventSubscriptionRecordValue>> subscriptions = RecordingExporter.messageStartEventSubscriptionRecords( MessageStartEventSubscriptionIntent.OPENED) .limit(2) .asList(); // then assertThat(subscriptions.size()).isEqualTo(2); assertThat(subscriptions) .hasSize(2) .extracting(Record::getValue) .extracting(s -> tuple(s.getMessageName(), s.getStartEventId())) .containsExactlyInAnyOrder( tuple(MESSAGE_NAME1, EVENT_ID1), tuple(MESSAGE_NAME2, EVENT_ID2)); }
@Test public void shouldOpenSubscriptionsForAllMessageStartEvents() { // when testClient.deploy(createWorkflowWithTwoMessageStartEvent()); final List<Record<MessageStartEventSubscriptionRecordValue>> subscriptions = RecordingExporter.messageStartEventSubscriptionRecords( MessageStartEventSubscriptionIntent.OPENED) .limit(2) .asList(); // then assertThat(subscriptions.size()).isEqualTo(2); assertThat(subscriptions) .hasSize(2) .extracting(Record::getValue) .extracting(s -> tuple(s.getMessageName(), s.getStartEventId())) .containsExactlyInAnyOrder( tuple(MESSAGE_NAME1, EVENT_ID1), tuple(MESSAGE_NAME2, EVENT_ID2)); }
@Test public void shouldOpenMessageStartEventSubscriptionOnAllPartitions() { testClient.deploy(createWorkflowWithOneMessageStartEvent()); final List<Record<MessageStartEventSubscriptionRecordValue>> subscriptions = RecordingExporter.messageStartEventSubscriptionRecords( MessageStartEventSubscriptionIntent.OPENED) .limit(3) .asList(); assertThat(subscriptions) .hasSize(3) .extracting(Record::getValue) .extracting(v -> tuple(v.getStartEventId(), v.getMessageName())) .containsOnly(tuple(EVENT_ID1, MESSAGE_NAME1)); assertThat(subscriptions) .extracting(r -> r.getMetadata().getPartitionId()) .containsExactlyInAnyOrder(0, 1, 2); }
@Test public void shouldOpenMessageStartEventSubscriptionOnAllPartitions() { testClient.deploy(createWorkflowWithOneMessageStartEvent()); final List<Record<MessageStartEventSubscriptionRecordValue>> subscriptions = RecordingExporter.messageStartEventSubscriptionRecords( MessageStartEventSubscriptionIntent.OPENED) .limit(3) .asList(); assertThat(subscriptions) .hasSize(3) .extracting(Record::getValue) .extracting(v -> tuple(v.getStartEventId(), v.getMessageName())) .containsOnly(tuple(EVENT_ID1, MESSAGE_NAME1)); assertThat(subscriptions) .extracting(r -> r.getMetadata().getPartitionId()) .containsExactlyInAnyOrder(0, 1, 2); }