From 73e6e456da8698fd351c7ceeaedbc9eaae2a8b1b Mon Sep 17 00:00:00 2001 From: Martin Kouba Date: Thu, 2 Nov 2023 15:59:15 +0100 Subject: [PATCH] TransactionalUniAsserterTest: test that injected argument is used - UniAsserterTest: add test for UniAsserter#fail() --- .../reactive/TransactionalUniAsserterTest.java | 12 ++++++++++++ .../java/io/quarkus/test/vertx/UniAsserterTest.java | 8 +++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/integration-tests/hibernate-reactive-panache/src/test/java/io/quarkus/it/panache/reactive/TransactionalUniAsserterTest.java b/integration-tests/hibernate-reactive-panache/src/test/java/io/quarkus/it/panache/reactive/TransactionalUniAsserterTest.java index e04ce655b113f..2586929e2143c 100644 --- a/integration-tests/hibernate-reactive-panache/src/test/java/io/quarkus/it/panache/reactive/TransactionalUniAsserterTest.java +++ b/integration-tests/hibernate-reactive-panache/src/test/java/io/quarkus/it/panache/reactive/TransactionalUniAsserterTest.java @@ -3,7 +3,11 @@ import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import java.util.concurrent.atomic.AtomicBoolean; + +import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.Test; import io.quarkus.hibernate.reactive.panache.Panache; @@ -14,11 +18,14 @@ @QuarkusTest public class TransactionalUniAsserterTest { + private static final AtomicBoolean ASSERTER_USED = new AtomicBoolean(); + @RunOnVertxContext @Test public void testTransactionalUniAsserter(TransactionalUniAsserter asserter) { assertNotNull(asserter); asserter.assertThat(Panache::currentTransaction, transaction -> { + ASSERTER_USED.set(true); assertNotNull(transaction); assertFalse(transaction.isMarkedForRollback()); asserter.putData("tx", transaction); @@ -30,4 +37,9 @@ public void testTransactionalUniAsserter(TransactionalUniAsserter asserter) { }); } + @AfterAll + static void afterAll() { + assertTrue(ASSERTER_USED.get()); + } + } diff --git a/test-framework/vertx/src/test/java/io/quarkus/test/vertx/UniAsserterTest.java b/test-framework/vertx/src/test/java/io/quarkus/test/vertx/UniAsserterTest.java index dd1103d359552..effafa73dbc06 100644 --- a/test-framework/vertx/src/test/java/io/quarkus/test/vertx/UniAsserterTest.java +++ b/test-framework/vertx/src/test/java/io/quarkus/test/vertx/UniAsserterTest.java @@ -12,6 +12,7 @@ import java.util.function.Supplier; import org.junit.jupiter.api.Test; +import org.opentest4j.AssertionFailedError; import io.smallrye.mutiny.Uni; @@ -94,6 +95,11 @@ public void testAssertThat() { testAsserterFailure(ua -> ua.assertThat(() -> Uni.createFrom().item("foo"), foo -> assertEquals("bar", foo))); } + @Test + public void testFail() { + testAsserterFailure(ua -> ua.fail(), t -> AssertionFailedError.class.isInstance(t)); + } + @Test public void testExecute() throws InterruptedException, ExecutionException { CompletableFuture cf = new CompletableFuture<>(); @@ -238,7 +244,7 @@ private void testAsserterFailure(Consumer assertion, Predicate