Package io.quarkus.test.vertx
Interface UniAsserter
-
- All Known Subinterfaces:
UnwrappableUniAsserter
- All Known Implementing Classes:
DefaultUniAsserter
,UniAsserterInterceptor
public interface UniAsserter
Used in conjunction withRunOnVertxContext
(or similar annotations) in order to test assertions on APIs that returnUni
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 withQuarkusTest
.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
All Methods Instance Methods Abstract Methods Modifier and Type Method Description <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.UniAsserter
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.UniAsserter
assertTrue(Supplier<io.smallrye.mutiny.Uni<Boolean>> uni)
Assert that the value of theUni
istrue
.void
clearData()
Clear the test data.UniAsserter
execute(Runnable c)
Execute some arbitrary operation as part of the pipeline.<T> UniAsserter
execute(Supplier<io.smallrye.mutiny.Uni<T>> uni)
Execute some arbitrary operation as part of the pipeline.UniAsserter
fail()
Ensure that the whole pipeline always failsObject
getData(String key)
Object
putData(String key, Object value)
Associate the value with the given key.<T> UniAsserter
surroundWith(Function<io.smallrye.mutiny.Uni<T>,io.smallrye.mutiny.Uni<T>> uni)
-
-
-
Method Detail
-
assertThat
<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.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
<T> UniAsserter execute(Supplier<io.smallrye.mutiny.Uni<T>> uni)
Execute some arbitrary operation as part of the pipeline.
-
execute
UniAsserter execute(Runnable c)
Execute some arbitrary operation as part of the pipeline.
-
assertEquals
<T> UniAsserter assertEquals(Supplier<io.smallrye.mutiny.Uni<T>> uni, T t)
Assert that the value of theUni
is equal to the expected value. If both arenull
, they are considered equal.- See Also:
Object.equals(Object)
-
assertNotEquals
<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. Fails if both arenull
.- See Also:
Object.equals(Object)
-
assertSame
<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.
-
assertNotSame
<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.
-
assertNull
<T> UniAsserter assertNull(Supplier<io.smallrye.mutiny.Uni<T>> uni)
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
<T> UniAsserter assertNotNull(Supplier<io.smallrye.mutiny.Uni<T>> uni)
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
<T> UniAsserter surroundWith(Function<io.smallrye.mutiny.Uni<T>,io.smallrye.mutiny.Uni<T>> uni)
-
fail
UniAsserter fail()
Ensure that the whole pipeline always fails
-
assertTrue
UniAsserter assertTrue(Supplier<io.smallrye.mutiny.Uni<Boolean>> uni)
Assert that the value of theUni
istrue
.
-
assertFalse
UniAsserter assertFalse(Supplier<io.smallrye.mutiny.Uni<Boolean>> uni)
Assert that the value of theUni
isfalse
.
-
assertFailedWith
<T> UniAsserter assertFailedWith(Supplier<io.smallrye.mutiny.Uni<T>> uni, Consumer<Throwable> c)
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
Object getData(String key)
- Returns:
- the test data associated with the given key, or
null
- See Also:
putData(String, Object)
-
putData
Object putData(String key, Object value)
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.
-
-