From ca766b587e6b31ec3a7568e234bef79ced4c1279 Mon Sep 17 00:00:00 2001 From: Julien Ponge Date: Mon, 4 Mar 2024 11:35:54 +0100 Subject: [PATCH] test(UniCreateFromFutureTest): fix a flaky test in slow CI conditions --- .../mutiny/operators/UniCreateFromFutureTest.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/implementation/src/test/java/io/smallrye/mutiny/operators/UniCreateFromFutureTest.java b/implementation/src/test/java/io/smallrye/mutiny/operators/UniCreateFromFutureTest.java index c13a05533..04bb27baa 100644 --- a/implementation/src/test/java/io/smallrye/mutiny/operators/UniCreateFromFutureTest.java +++ b/implementation/src/test/java/io/smallrye/mutiny/operators/UniCreateFromFutureTest.java @@ -1,6 +1,7 @@ package io.smallrye.mutiny.operators; import static org.assertj.core.api.Assertions.assertThat; +import static org.awaitility.Awaitility.await; import static org.junit.jupiter.api.Assertions.assertThrows; import java.io.IOException; @@ -106,10 +107,13 @@ public void testWithException() { @Test public void testWithTimeoutException() throws InterruptedException { UniAssertSubscriber subscriber = UniAssertSubscriber.create(); + AtomicBoolean step = new AtomicBoolean(); CompletableFuture cs = new CompletableFuture<>(); - Uni.createFrom().future(cs, Duration.ofMillis(1)).subscribe().withSubscriber(subscriber); + Uni.createFrom().future(cs, Duration.ofMillis(1)) + .onFailure().invoke(() -> step.set(true)) + .subscribe().withSubscriber(subscriber); // synthetic delay - Thread.sleep(50); + await().untilTrue(step); cs.complete("1"); subscriber .awaitFailure()