@ExperimentalApi(value="https://github.com/grpc/grpc-java/issues/1791") public class StreamRecorder<T> extends Object implements io.grpc.stub.StreamObserver<T>
StreamObserver
used in testing. Records all the observed
values produced by the stream as well as any errors.Modifier and Type | Method and Description |
---|---|
void |
awaitCompletion()
Waits for the stream to terminate.
|
boolean |
awaitCompletion(int timeout,
TimeUnit unit)
Waits a fixed timeout for the stream to terminate.
|
static <T> StreamRecorder<T> |
create()
Creates a new recorder.
|
com.google.common.util.concurrent.ListenableFuture<T> |
firstValue()
Returns a
ListenableFuture for the first value received from the stream. |
Throwable |
getError()
Returns the stream terminating error.
|
List<T> |
getValues()
Returns the current set of received values.
|
void |
onCompleted() |
void |
onError(Throwable t) |
void |
onNext(T value) |
public static <T> StreamRecorder<T> create()
public void onError(Throwable t)
onError
in interface io.grpc.stub.StreamObserver<T>
public void onCompleted()
onCompleted
in interface io.grpc.stub.StreamObserver<T>
public void awaitCompletion() throws Exception
Exception
public boolean awaitCompletion(int timeout, TimeUnit unit) throws Exception
Exception
public com.google.common.util.concurrent.ListenableFuture<T> firstValue()
ListenableFuture
for the first value received from the stream. Useful
for testing unary call patterns.