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> UniAsserterassertEquals(Supplier<io.smallrye.mutiny.Uni<T>> uni, T t) Assert that the value of theUniis equal to the expected value.<T> UniAsserterassertFailedWith(Supplier<io.smallrye.mutiny.Uni<T>> uni, Class<? extends Throwable> c) Used to determine whether theUnicontains the expected failure type.<T> UniAsserterassertFailedWith(Supplier<io.smallrye.mutiny.Uni<T>> uni, Consumer<Throwable> c) Used to determine whether theUnicontains the expected failure.assertFalse(Supplier<io.smallrye.mutiny.Uni<Boolean>> uni) Assert that the value of theUniisfalse.<T> UniAsserterassertNotEquals(Supplier<io.smallrye.mutiny.Uni<T>> uni, T t) Assert that the value of theUniis not equal to the expected value.<T> UniAsserterassertNotNull(Supplier<io.smallrye.mutiny.Uni<T>> uni) Assert that the value of theUniis notnull.<T> UniAsserterassertNotSame(Supplier<io.smallrye.mutiny.Uni<T>> uni, T t) Assert that the value of theUniand the expected value do not refer to the same object.<T> UniAsserterassertNull(Supplier<io.smallrye.mutiny.Uni<T>> uni) Assert that the value of theUniisnull.<T> UniAsserterassertSame(Supplier<io.smallrye.mutiny.Uni<T>> uni, T t) Assert that the value of theUniand the expected value refer to the same object.<T> UniAsserterassertThat(Supplier<io.smallrye.mutiny.Uni<T>> uni, Consumer<T> asserter) Perform a custom assertion on the value of theUniin cases where no exception was thrown.assertTrue(Supplier<io.smallrye.mutiny.Uni<Boolean>> uni) Assert that the value of theUniistrue.voidClear the test data.Execute some arbitrary operation as part of the pipeline.<T> UniAsserterExecute some arbitrary operation as part of the pipeline.fail()Ensure that the whole pipeline always failsAssociate the value with the given key.<T> UniAssertersurroundWith(Function<io.smallrye.mutiny.Uni<T>, io.smallrye.mutiny.Uni<T>> uni)
-
Method Details
-
assertThat
Perform a custom assertion on the value of theUniin 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 theUniis equal to the expected value. If both arenull, they are considered equal.- See Also:
-
assertNotEquals
Assert that the value of theUniis not equal to the expected value. Fails if both arenull.- See Also:
-
assertSame
Assert that the value of theUniand the expected value refer to the same object. -
assertNotSame
Assert that the value of theUniand the expected value do not refer to the same object. -
assertNull
Assert that the value of theUniisnull.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 theUniis 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 theUniistrue. -
assertFalse
Assert that the value of theUniisfalse. -
assertFailedWith
Used to determine whether theUnicontains the expected failure. The assertions fail if theUnidoes not fail.- Parameters:
c- Consumer that performs custom assertions on whether the failure matches expectations. This allows asserting on anything present in theThrowablelike, the cause or the message
-
assertFailedWith
<T> UniAsserter assertFailedWith(Supplier<io.smallrye.mutiny.Uni<T>> uni, Class<? extends Throwable> c) Used to determine whether theUnicontains the expected failure type. The assertions fail if theUnidoes 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
nullif there was no data for the given key
-
clearData
void clearData()Clear the test data.
-