Skip to content

Commit

Permalink
Improved CatchupSubscriptionModelTest
Browse files Browse the repository at this point in the history
  • Loading branch information
johanhaleby committed May 3, 2024
1 parent db19400 commit f3ccfa5
Showing 1 changed file with 6 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -153,25 +153,18 @@ void catchup_subscription_reads_events_that_were_persisted_during_catchup_phase(
CountDownLatch waitForNewEventsToBePublished = new CountDownLatch(1);

new Thread(() -> {
try {
waitBeforePublishingNewEvents.await(1, TimeUnit.MINUTES);
mongoEventStore.write("3", 0, serialize(nameDefined3));
mongoEventStore.write("4", 0, serialize(nameDefined4));
waitForNewEventsToBePublished.countDown();
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
awaitLatch(waitBeforePublishingNewEvents);
awaitLatch(waitBeforePublishingNewEvents);
mongoEventStore.write("3", 0, serialize(nameDefined3));
mongoEventStore.write("4", 0, serialize(nameDefined4));
waitForNewEventsToBePublished.countDown();
}).start();

// When
subscription.subscribe(UUID.randomUUID().toString(), StartAt.subscriptionPosition(TimeBasedSubscriptionPosition.beginningOfTime()), e -> {
if (state.size() == 1) {
waitBeforePublishingNewEvents.countDown();
try {
waitForNewEventsToBePublished.await(1, TimeUnit.MINUTES);
} catch (InterruptedException ex) {
throw new RuntimeException(ex);
}
awaitLatch(waitForNewEventsToBePublished);
}
state.add(e);
}).waitUntilStarted();
Expand Down

0 comments on commit f3ccfa5

Please sign in to comment.