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)oronError(java.lang.Throwable), but not both.
-
-
Constructor Summary
Constructors Constructor Description AssertableCallback()
-
Method Summary
All Methods Instance Methods Concrete Methods 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
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.function.BiConsumer
andThen
-
-
-
-
Method Detail
-
setListener
public AssertableCallback<V> setListener(Runnable listener)
-
onSuccess
public void onSuccess(@Nullable V value)Invoked when computation produces its potentially null value successfully.When this is called,
onError(java.lang.Throwable)won't be.
-
onError
public void onError(Throwable throwable)
Invoked when computation produces a possibly null value successfully.When this is called,
onSuccess(V)won't be.
-
join
@Nullable public V join()
Returns the value after performing state checks
-
assertThatSuccess
public org.assertj.core.api.ObjectAssert<V> assertThatSuccess()
-
assertThatError
public org.assertj.core.api.AbstractThrowableAssert<?,? extends Throwable> assertThatError()
-
-