Package io.quarkus.test.vertx
Interface UniAsserter
-
- All Known Subinterfaces:
UnwrappableUniAsserter
- All Known Implementing Classes:
DefaultUniAsserter,UniAsserterInterceptor
public interface UniAsserterUsed in conjunction withRunOnVertxContext(or similar annotations) in order to test assertions on APIs that returnUniand 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,UniAsserteris 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> 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.UniAsserterassertFalse(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.UniAsserterassertTrue(Supplier<io.smallrye.mutiny.Uni<Boolean>> uni)Assert that the value of theUniistrue.voidclearData()Clear the test data.UniAsserterexecute(Runnable c)Execute some arbitrary operation as part of the pipeline.<T> UniAsserterexecute(Supplier<io.smallrye.mutiny.Uni<T>> uni)Execute some arbitrary operation as part of the pipeline.UniAsserterfail()Ensure that the whole pipeline always failsObjectgetData(String key)ObjectputData(String key, Object value)Associate the value with the given key.<T> UniAssertersurroundWith(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 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
<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 theUniis 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 theUniis 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 theUniand 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 theUniand 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 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
<T> UniAsserter assertNotNull(Supplier<io.smallrye.mutiny.Uni<T>> uni)
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
<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 theUniistrue.
-
assertFalse
UniAsserter assertFalse(Supplier<io.smallrye.mutiny.Uni<Boolean>> uni)
Assert that the value of theUniisfalse.
-
assertFailedWith
<T> UniAsserter assertFailedWith(Supplier<io.smallrye.mutiny.Uni<T>> uni, Consumer<Throwable> c)
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
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
nullif there was no data for the given key
-
clearData
void clearData()
Clear the test data.
-
-