From c44eab767a1639c80b58b3dd98a279429660548e Mon Sep 17 00:00:00 2001 From: Davide D'Alto Date: Tue, 31 Oct 2023 15:27:59 +0100 Subject: [PATCH] [#36582] Add UnwrappableUniAsserter 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 ++-- .../test/vertx/UnwrappableUniAsserter.java | 17 +++++++++++++++++ 5 files changed, 24 insertions(+), 12 deletions(-) create mode 100644 test-framework/vertx/src/main/java/io/quarkus/test/vertx/UnwrappableUniAsserter.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 e5f8ff9ece395..d983369c88704 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 UnwrappableUniAsserter { 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 ca55758fd9d46..734891926397b 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 UnwrappableUniAsserter 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 = (UnwrappableUniAsserter) 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 UnwrappableUniAsserter 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 = (UnwrappableUniAsserter) 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 803d8725e9a3b..5abe24c09dfd4 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 d622a5459436a..90a0f713820d7 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 UnwrappableUniAsserter { private final UniAsserter delegate; @@ -192,6 +192,6 @@ public void clearData() { @Override public Uni asUni() { - return delegate.asUni(); + return ((UnwrappableUniAsserter) delegate).asUni(); } } \ No newline at end of file diff --git a/test-framework/vertx/src/main/java/io/quarkus/test/vertx/UnwrappableUniAsserter.java b/test-framework/vertx/src/main/java/io/quarkus/test/vertx/UnwrappableUniAsserter.java new file mode 100644 index 0000000000000..613b0d3eaafad --- /dev/null +++ b/test-framework/vertx/src/main/java/io/quarkus/test/vertx/UnwrappableUniAsserter.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 + *

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