From 37cd35220ed9f8e6a0ee1cc17dc63e4de6346290 Mon Sep 17 00:00:00 2001 From: Davide D'Alto Date: Tue, 31 Oct 2023 15:27:59 +0100 Subject: [PATCH] [#36582] Add UnwrappableUni interface The goal is to extract the `asUni()` method from `UniAsserter` --- .../quarkus/test/vertx/DefaultUniAsserter.java | 2 +- .../RunOnVertxContextTestMethodInvoker.java | 8 ++++---- .../java/io/quarkus/test/vertx/UniAsserter.java | 5 ----- .../test/vertx/UniAsserterInterceptor.java | 4 ++-- .../quarkus/test/vertx/UnwrappableAsserter.java | 17 +++++++++++++++++ 5 files changed, 24 insertions(+), 12 deletions(-) create mode 100644 test-framework/vertx/src/main/java/io/quarkus/test/vertx/UnwrappableAsserter.java diff --git a/test-framework/vertx/src/main/java/io/quarkus/test/vertx/DefaultUniAsserter.java b/test-framework/vertx/src/main/java/io/quarkus/test/vertx/DefaultUniAsserter.java index e5f8ff9ece3956..695fb3d6912607 100644 --- a/test-framework/vertx/src/main/java/io/quarkus/test/vertx/DefaultUniAsserter.java +++ b/test-framework/vertx/src/main/java/io/quarkus/test/vertx/DefaultUniAsserter.java @@ -10,7 +10,7 @@ import io.smallrye.mutiny.Uni; -public final class DefaultUniAsserter implements UniAsserter { +public final class DefaultUniAsserter implements UnwrappableAsserter { private final ConcurrentMap data; diff --git a/test-framework/vertx/src/main/java/io/quarkus/test/vertx/RunOnVertxContextTestMethodInvoker.java b/test-framework/vertx/src/main/java/io/quarkus/test/vertx/RunOnVertxContextTestMethodInvoker.java index ca55758fd9d461..0d42cf49557277 100644 --- a/test-framework/vertx/src/main/java/io/quarkus/test/vertx/RunOnVertxContextTestMethodInvoker.java +++ b/test-framework/vertx/src/main/java/io/quarkus/test/vertx/RunOnVertxContextTestMethodInvoker.java @@ -156,7 +156,7 @@ public void run() { private final Object testInstance; private final Method targetMethod; private final List methodArgs; - private final UniAsserter uniAsserter; + private final UnwrappableAsserter uniAsserter; private final CompletableFuture future; public RunTestMethodOnVertxEventLoopContextHandler(Object testInstance, Method targetMethod, List methodArgs, @@ -165,7 +165,7 @@ public RunTestMethodOnVertxEventLoopContextHandler(Object testInstance, Method t this.future = future; this.targetMethod = targetMethod; this.methodArgs = methodArgs; - this.uniAsserter = uniAsserter; + this.uniAsserter = (UnwrappableAsserter) uniAsserter; } @Override @@ -219,14 +219,14 @@ public static class RunTestMethodOnVertxBlockingContextHandler implements Handle private final Object testInstance; private final Method targetMethod; private final List methodArgs; - private final UniAsserter uniAsserter; + private final UnwrappableAsserter uniAsserter; public RunTestMethodOnVertxBlockingContextHandler(Object testInstance, Method targetMethod, List methodArgs, UniAsserter uniAsserter) { this.testInstance = testInstance; this.targetMethod = targetMethod; this.methodArgs = methodArgs; - this.uniAsserter = uniAsserter; + this.uniAsserter = (UnwrappableAsserter) uniAsserter; } @Override diff --git a/test-framework/vertx/src/main/java/io/quarkus/test/vertx/UniAsserter.java b/test-framework/vertx/src/main/java/io/quarkus/test/vertx/UniAsserter.java index 803d8725e9a3b2..5abe24c09dfd4b 100644 --- a/test-framework/vertx/src/main/java/io/quarkus/test/vertx/UniAsserter.java +++ b/test-framework/vertx/src/main/java/io/quarkus/test/vertx/UniAsserter.java @@ -144,9 +144,4 @@ public interface UniAsserter { * Clear the test data. */ void clearData(); - - /** - * @return a {@link Uni} representing the operations pipeline up to this point - */ - Uni asUni(); } diff --git a/test-framework/vertx/src/main/java/io/quarkus/test/vertx/UniAsserterInterceptor.java b/test-framework/vertx/src/main/java/io/quarkus/test/vertx/UniAsserterInterceptor.java index d622a5459436af..0b0b87cab8a2a9 100644 --- a/test-framework/vertx/src/main/java/io/quarkus/test/vertx/UniAsserterInterceptor.java +++ b/test-framework/vertx/src/main/java/io/quarkus/test/vertx/UniAsserterInterceptor.java @@ -65,7 +65,7 @@ * * */ -public abstract class UniAsserterInterceptor implements UniAsserter { +public abstract class UniAsserterInterceptor implements UnwrappableAsserter { private final UniAsserter delegate; @@ -192,6 +192,6 @@ public void clearData() { @Override public Uni asUni() { - return delegate.asUni(); + return ((UnwrappableAsserter) delegate).asUni(); } } \ No newline at end of file diff --git a/test-framework/vertx/src/main/java/io/quarkus/test/vertx/UnwrappableAsserter.java b/test-framework/vertx/src/main/java/io/quarkus/test/vertx/UnwrappableAsserter.java new file mode 100644 index 00000000000000..d85c0dfaa4e55e --- /dev/null +++ b/test-framework/vertx/src/main/java/io/quarkus/test/vertx/UnwrappableAsserter.java @@ -0,0 +1,17 @@ +package io.quarkus.test.vertx; + +import io.smallrye.mutiny.Uni; + +/** + * A {@link UniAsserter} that exposes the internal {@link Uni}. + *

+ * We've added this interface so that we don't expose the method {@link #asUni()} to the user + *

+ */ +public interface UnwrappableAsserter extends UniAsserter { + + /** + * @return a {@link Uni} representing the operations pipeline up to this point + */ + Uni asUni(); +}