Package io.quarkus.test.vertx
Interface UniAsserter
- All Known Subinterfaces:
UnwrappableUniAsserter
- All Known Implementing Classes:
DefaultUniAsserter
,UniAsserterInterceptor
public interface UniAsserter
Used in conjunction with
RunOnVertxContext
(or similar annotations) in order to test assertions
on APIs that return Uni
and whose execution needs to occur on a Vert.x Event Loop Thread (such as Hibernate Reactive
for example).
The following example shows how this class is meant to be used:
@QuarkusTest public class SomeTestClass { @RunOnVertxContext @Test public void someTest(UniAsserter asserter) { asserter .assertNotNull(() -> MyAPI.someObject()) .assertEquals(() -> MyAPI.count(), 0L); } }As can be seen in example,
UniAsserter
is used as parameter of a test method for a class annotated with
QuarkusTest
.
As far as the API is concerned, each assertion in the pipeline is executed when the result of the corresponding Uni becomes available.
-
Method Summary
Modifier and TypeMethodDescription<T> UniAsserter
assertEquals
(Supplier<io.smallrye.mutiny.Uni<T>> uni, T t) Assert that the value of theUni
is equal to the expected value.<T> UniAsserter
assertFailedWith
(Supplier<io.smallrye.mutiny.Uni<T>> uni, Class<? extends Throwable> c) Used to determine whether theUni
contains the expected failure type.<T> UniAsserter
assertFailedWith
(Supplier<io.smallrye.mutiny.Uni<T>> uni, Consumer<Throwable> c) Used to determine whether theUni
contains the expected failure.assertFalse
(Supplier<io.smallrye.mutiny.Uni<Boolean>> uni) Assert that the value of theUni
isfalse
.<T> UniAsserter
assertNotEquals
(Supplier<io.smallrye.mutiny.Uni<T>> uni, T t) Assert that the value of theUni
is not equal to the expected value.<T> UniAsserter
assertNotNull
(Supplier<io.smallrye.mutiny.Uni<T>> uni) Assert that the value of theUni
is notnull
.<T> UniAsserter
assertNotSame
(Supplier<io.smallrye.mutiny.Uni<T>> uni, T t) Assert that the value of theUni
and the expected value do not refer to the same object.<T> UniAsserter
assertNull
(Supplier<io.smallrye.mutiny.Uni<T>> uni) Assert that the value of theUni
isnull
.<T> UniAsserter
assertSame
(Supplier<io.smallrye.mutiny.Uni<T>> uni, T t) Assert that the value of theUni
and the expected value refer to the same object.<T> UniAsserter
assertThat
(Supplier<io.smallrye.mutiny.Uni<T>> uni, Consumer<T> asserter) Perform a custom assertion on the value of theUni
in cases where no exception was thrown.assertTrue
(Supplier<io.smallrye.mutiny.Uni<Boolean>> uni) Assert that the value of theUni
istrue
.void
Clear the test data.Execute some arbitrary operation as part of the pipeline.<T> UniAsserter
Execute some arbitrary operation as part of the pipeline.fail()
Ensure that the whole pipeline always failsAssociate the value with the given key.<T> UniAsserter
surroundWith
(Function<io.smallrye.mutiny.Uni<T>, io.smallrye.mutiny.Uni<T>> uni)
-
Method Details
-
assertThat
Perform a custom assertion on the value of theUni
in cases where no exception was thrown.If an exception is expected, then one of
assertFailedWith(java.util.function.Supplier<io.smallrye.mutiny.Uni<T>>, java.util.function.Consumer<java.lang.Throwable>)
methods should be used. -
execute
Execute some arbitrary operation as part of the pipeline. -
execute
Execute some arbitrary operation as part of the pipeline. -
assertEquals
Assert that the value of theUni
is equal to the expected value. If both arenull
, they are considered equal.- See Also:
-
assertNotEquals
Assert that the value of theUni
is not equal to the expected value. Fails if both arenull
.- See Also:
-
assertSame
Assert that the value of theUni
and the expected value refer to the same object. -
assertNotSame
Assert that the value of theUni
and the expected value do not refer to the same object. -
assertNull
Assert that the value of theUni
isnull
.If an exception is expected, then one of
assertFailedWith(java.util.function.Supplier<io.smallrye.mutiny.Uni<T>>, java.util.function.Consumer<java.lang.Throwable>)
methods should be used. -
assertNotNull
Assert that the value of theUni
is notnull
.If an exception is expected, then one of
assertFailedWith(java.util.function.Supplier<io.smallrye.mutiny.Uni<T>>, java.util.function.Consumer<java.lang.Throwable>)
methods should be used. -
surroundWith
-
fail
UniAsserter fail()Ensure that the whole pipeline always fails -
assertTrue
Assert that the value of theUni
istrue
. -
assertFalse
Assert that the value of theUni
isfalse
. -
assertFailedWith
Used to determine whether theUni
contains the expected failure. The assertions fail if theUni
does not fail.- Parameters:
c
- Consumer that performs custom assertions on whether the failure matches expectations. This allows asserting on anything present in theThrowable
like, the cause or the message
-
assertFailedWith
<T> UniAsserter assertFailedWith(Supplier<io.smallrye.mutiny.Uni<T>> uni, Class<? extends Throwable> c) Used to determine whether theUni
contains the expected failure type. The assertions fail if theUni
does not fail. -
getData
- Returns:
- the test data associated with the given key, or
null
- See Also:
-
putData
Associate the value with the given key.- Returns:
- the previous value, or
null
if there was no data for the given key
-
clearData
void clearData()Clear the test data.
-