Package brave.test.util
Class AssertableCallback<V>
java.lang.Object
java.util.concurrent.CountDownLatch
brave.test.util.AssertableCallback<V>
- All Implemented Interfaces:
BiConsumer<V,Throwable>
public final class AssertableCallback<V> extends CountDownLatch implements BiConsumer<V,Throwable>
A callback of a single result or error that supports assertions.
This is a bridge to async libraries such as CompletableFuture complete, completeExceptionally.
Implementations will call either onSuccess(V) or onError(java.lang.Throwable), but not both.
-
Constructor Summary
Constructors Constructor Description AssertableCallback() -
Method Summary
Modifier and Type Method Description voidaccept(V v, Throwable throwable)org.assertj.core.api.AbstractThrowableAssert<?,? extends Throwable>assertThatError()org.assertj.core.api.ObjectAssert<V>assertThatSuccess()Vjoin()Returns the value after performing state checksvoidonError(Throwable throwable)Invoked when computation produces a possibly null value successfully.voidonSuccess(V value)Invoked when computation produces its potentially null value successfully.AssertableCallback<V>setListener(Runnable listener)Methods inherited from class java.util.concurrent.CountDownLatch
await, await, countDown, getCount, toString
-
Constructor Details
-
AssertableCallback
public AssertableCallback()
-
-
Method Details
-
setListener
-
onSuccess
Invoked when computation produces its potentially null value successfully.When this is called,
onError(java.lang.Throwable)won't be. -
onError
Invoked when computation produces a possibly null value successfully.When this is called,
onSuccess(V)won't be. -
join
Returns the value after performing state checks -
assertThatSuccess
-
assertThatError
-
accept
- Specified by:
acceptin interfaceBiConsumer<V,Throwable>
-