| Modifier and Type | Class and Description |
|---|---|
| public static enum | BaseTestConsumer.TestWaitStrategy
Enumeration of default wait strategies when waiting for a specific number of
items in |
| Modifier and Type | Field and Description |
|---|---|
| protected boolean | |
| protected long | completions
The number of completions. |
| protected final CountDownLatch | done
The latch that indicates an onError or onComplete has been called. |
| protected final List | errors
The list of errors received. |
| protected int | |
| protected int | |
| protected Thread | lastThread
The last thread seen by the observer. |
| protected CharSequence | tag
The optional tag associated with this test consumer. |
| protected boolean | timeout
Indicates that one of the awaitX method has timed out. |
| protected final List | values
The list of values received. |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public final U | Returns: thisAssert that this TestObserver/TestSubscriber received exactly one onComplete event. |
| public final U | Returns: thisAssert that the TestObserver/TestSubscriber has received a Disposable but no other events. |
| public final U | Returns: thisthe error to check error)Assert that this TestObserver/TestSubscriber received exactly the specified onError event value. |
| public final U | Returns: thisthe error class to expect errorClass)Asserts that this TestObserver/TestSubscriber received exactly one onError event which is an instance of the specified errorClass class. |
| public final U | Returns: thisthe predicate that receives the error Throwable
and should return true for expected errors. errorPredicate)Asserts that this TestObserver/TestSubscriber received exactly one onError event for which the provided predicate returns true. |
| public final U | Returns: thisthe message expected message)Assert that there is a single error and it has the given message. |
| public final U | Returns: thisthe expected exception (parent) class error, T... the expected values, asserted in order values)Assert that the upstream signalled the specified values in order and then failed with a specific class or subclass of Throwable. |
| public final U | Returns: thisthe predicate that receives the error Throwable
and should return true for expected errors. errorPredicate, T... the expected values, asserted in order values)Assert that the upstream signalled the specified values in order and then failed with a Throwable for which the provided predicate returns true. |
| public final U | Returns: thisthe expected exception (parent) class error, String the expected failure message message, T... the expected values, asserted in order values)Assert that the upstream signalled the specified values in order, then failed with a specific class or subclass of Throwable and with the given exact error message. |
| public final U | Returns: thisthe value to expect not being received value)Assert that this TestObserver/TestSubscriber did not receive an onNext value which is equal to the given value with respect to null-safe Object.equals. |
| public final U | Returns: thisthe predicate that receives the onNext value
and should return true for the expected value. valuePredicate)Asserts that this TestObserver/TestSubscriber did not receive any onNext value for which the provided predicate returns true. |
| public final U | Returns: thisAssert that this TestObserver/TestSubscriber has not received any onError event. |
| public final U | Returns: thisAssert that this TestObserver/TestSubscriber has not received any onComplete event. |
| public final U | |
| public abstract U | |
| public final U | Returns: thisAssert that the TestObserver/TestSubscriber has not terminated (i.e., the terminal latch is still non-zero). |
| public final U | Returns: thisAssert that this TestObserver/TestSubscriber has not received any onNext events. |
| public final U | Returns: thisthe expected values, asserted in order values)Assert that the upstream signalled the specified values in order and completed normally. |
| public abstract U | |
| public final U | Returns: thisAssert that the TestObserver/TestSubscriber terminated (i.e., the terminal latch reached zero). |
| public final U | |
| public final U | Returns: thisthe value to expect value)Assert that this TestObserver/TestSubscriber received exactly one onNext value which is equal to the given value with respect to Objects.equals. |
| public final U | Returns: thisthe predicate that receives the onNext value
and should return true for the expected value. valuePredicate)Asserts that this TestObserver/TestSubscriber received exactly one onNext value for which the provided predicate returns true. |
| public final U | Returns: thisthe position to assert on index, T the value to expect value)Asserts that this TestObserver/TestSubscriber received an onNext value at the given index which is equal to the given value with respect to null-safe Object.equals. |
| public final U | Returns: thisthe position to assert on index, Predicate<T> the predicate that receives the onNext value
and should return true for the expected value. valuePredicate)Asserts that this TestObserver/TestSubscriber received an onNext value at the given index for the provided predicate returns true. |
| public final U | Returns: thisthe expected number of onNext events count)Assert that this TestObserver/TestSubscriber received the specified number onNext events. |
| public final U | Returns: thisthe values expected values)Assert that the TestObserver/TestSubscriber received only the specified values in the specified order. |
| public final U | Returns: thisthe sequence of expected values in order sequence)Assert that the TestObserver/TestSubscriber received only the specified sequence of values in the same order. |
| public final U | Returns: thisthe sequence of expected values in order sequence)Assert that the TestObserver/TestSubscriber received only the specified values in the specified order without terminating. |
| public final U | Returns: thisthe collection of values expected in any order expected)Assert that the TestObserver/TestSubscriber received only items that are in the specified collection as well, irrespective of the order they were received. |
| public final U | Returns: thisthe collection of values expected in any order expected)Assert that the TestObserver/TestSubscriber received only the specified values in any order without terminating. |
| public final U | Returns: thisthe values expected values)Assert that the TestObserver/TestSubscriber received only the specified values in the specified order without terminating. |
| public final U | Returns: thisAwaits until this TestObserver/TestSubscriber receives an onError or onComplete events. |
| public final boolean | Returns: true if the TestObserver/TestSubscriber terminated, false if timeout happenedthe waiting time time, TimeUnit the time unit of the waiting time unit)Awaits the specified amount of time or until this TestObserver/TestSubscriber receives an onError or onComplete events, whichever happens first. |
| public final U | Returns: thisthe number of items expected at least atLeast)Await until the TestObserver/TestSubscriber receives the given number of items or terminates by sleeping 10 milliseconds at a time up to 5000 milliseconds of timeout. |
| public final U | Returns: thisthe number of items expected at least atLeast, Runnable a Runnable called when the current received count
hasn't reached the expected value and there was
no terminal event either, see waitStrategy)TestWaitStrategy
for examplesAwait until the TestObserver/TestSubscriber receives the given number of items or terminates by waiting according to the wait strategy and up to 5000 milliseconds of timeout. |
| public final U | Returns: thisthe number of items expected at least atLeast, Runnable a Runnable called when the current received count
hasn't reached the expected value and there was
no terminal event either, see waitStrategy, long TestWaitStrategy
for examplesif positive, the await ends if the specified amount of
time has passed no matter how many items were received timeoutMillis)Await until the TestObserver/TestSubscriber receives the given number of items or terminates. |
| public final U | |
| public final boolean | Returns: true if the TestObserver/TestSubscriber terminated, false if the wait has been interruptedWaits until the any terminal event has been received by this TestObserver/TestSubscriber or returns false if the wait has been interrupted. |
| public final boolean | Returns: true if the TestObserver/TestSubscriber terminated, false if timeout or interrupt happenedthe waiting time duration, TimeUnit the time unit of the waiting time unit)Awaits the specified amount of time or until this TestObserver/TestSubscriber receives an onError or onComplete events, whichever happens first. |
| public final U | |
| public final long | Returns: the number of times onComplete was calledReturns the number of times onComplete was called. |
| public final int | Returns: the number of onError exceptions receivedReturns the number of onError exceptions received. |
| public final List | Returns: a list of received events onError exceptionsReturns a shared list of received onError exceptions. |
| protected final AssertionError | |
| public final List | Returns: a list of (values, errors, completion-notifications)Returns a list of 3 other lists: the first inner list contains the plain values received; the second list contains the potential errors and the final list contains the potential completions as Notifications. |
| public final boolean | Returns: true if TestObserver/TestSubscriber received any onError or onComplete eventsReturns true if TestObserver/TestSubscriber received any onError or onComplete events. |
| public final boolean | Returns: true if one of the timeout-based await methods has timed out.History: 2.0.7 - experimental Returns true if an await timed out. |
| public final Thread | Returns: the last thread which called the onXXX methodsReturns the last thread which called the onXXX methods of this TestObserver/TestSubscriber. |
| public static String | Returns: the string representationthe object o)Appends the class name to a non-null value. |
| public final int | Returns: the number of onNext values receivedReturns the number of onNext values received. |
| public final List | |
| public final U | Returns: thisthe string to display (null won't print any tag) tag)Set the tag displayed along with an assertion failure's other state information. |
| checkSubscriptionOnce | back to summary |
|---|---|
| protected boolean checkSubscriptionOnce | |
| completions | back to summary |
|---|---|
| protected long completions The number of completions. | |
| done | back to summary |
|---|---|
| protected final CountDownLatch done The latch that indicates an onError or onComplete has been called. | |
| errors | back to summary |
|---|---|
| protected final List<Throwable> errors The list of errors received. | |
| establishedFusionMode | back to summary |
|---|---|
| protected int establishedFusionMode | |
| initialFusionMode | back to summary |
|---|---|
| protected int initialFusionMode | |
| lastThread | back to summary |
|---|---|
| protected Thread lastThread The last thread seen by the observer. | |
| tag | back to summary |
|---|---|
| protected CharSequence tag The optional tag associated with this test consumer.
| |
| timeout | back to summary |
|---|---|
| protected boolean timeout Indicates that one of the awaitX method has timed out.
| |
| values | back to summary |
|---|---|
| protected final List<T> values The list of values received. | |
| BaseTestConsumer | back to summary |
|---|---|
| public BaseTestConsumer() | |
| assertComplete | back to summary |
|---|---|
| public final U assertComplete() Assert that this TestObserver/TestSubscriber received exactly one onComplete event.
| |
| assertEmpty | back to summary |
|---|---|
| public final U assertEmpty() Assert that the TestObserver/TestSubscriber has received a Disposable but no other events.
| |
| assertError | back to summary |
|---|---|
| public final U assertError(Throwable error) Assert that this TestObserver/TestSubscriber received exactly the specified onError event value. The comparison is performed via Objects.equals(); since most exceptions don't
implement equals(), this assertion may fail. Use the
| |
| assertError | back to summary |
|---|---|
| public final U assertError(Class<? extends Throwable> errorClass) Asserts that this TestObserver/TestSubscriber received exactly one onError event which is an instance of the specified errorClass class.
| |
| assertError | back to summary |
|---|---|
| public final U assertError(Predicate<Throwable> errorPredicate) Asserts that this TestObserver/TestSubscriber received exactly one onError event for which the provided predicate returns true.
| |
| assertErrorMessage | back to summary |
|---|---|
| public final U assertErrorMessage(String message) Assert that there is a single error and it has the given message.
| |
| assertFailure | back to summary |
|---|---|
| public final U assertFailure(Class<? extends Throwable> error, T... values) Assert that the upstream signalled the specified values in order and then failed with a specific class or subclass of Throwable. | |
| assertFailure | back to summary |
|---|---|
| public final U assertFailure(Predicate<Throwable> errorPredicate, T... values) Assert that the upstream signalled the specified values in order and then failed with a Throwable for which the provided predicate returns true. | |
| assertFailureAndMessage | back to summary |
|---|---|
| public final U assertFailureAndMessage(Class<? extends Throwable> error, String message, T... values) Assert that the upstream signalled the specified values in order, then failed with a specific class or subclass of Throwable and with the given exact error message. | |
| assertNever | back to summary |
|---|---|
| public final U assertNever(T value) Assert that this TestObserver/TestSubscriber did not receive an onNext value which is equal to the given value with respect to null-safe Object.equals. History: 2.0.5 - experimental
| |
| assertNever | back to summary |
|---|---|
| public final U assertNever(Predicate<? super T> valuePredicate) Asserts that this TestObserver/TestSubscriber did not receive any onNext value for which the provided predicate returns true. History: 2.0.5 - experimental
| |
| assertNoErrors | back to summary |
|---|---|
| public final U assertNoErrors() Assert that this TestObserver/TestSubscriber has not received any onError event.
| |
| assertNotComplete | back to summary |
|---|---|
| public final U assertNotComplete() Assert that this TestObserver/TestSubscriber has not received any onComplete event.
| |
| assertNoTimeout | back to summary |
|---|---|
| public final U assertNoTimeout() Asserts that some awaitX method has not timed out. History: 2.0.7 - experimental
| |
| assertNotSubscribed | back to summary |
|---|---|
| public abstract U assertNotSubscribed() Assert that the onSubscribe method hasn't been called at all.
| |
| assertNotTerminated | back to summary |
|---|---|
| public final U assertNotTerminated() Assert that the TestObserver/TestSubscriber has not terminated (i.e., the terminal latch is still non-zero).
| |
| assertNoValues | back to summary |
|---|---|
| public final U assertNoValues() Assert that this TestObserver/TestSubscriber has not received any onNext events.
| |
| assertResult | back to summary |
|---|---|
| public final U assertResult(T... values) Assert that the upstream signalled the specified values in order and completed normally.
| |
| assertSubscribed | back to summary |
|---|---|
| public abstract U assertSubscribed() Assert that the onSubscribe method was called exactly once.
| |
| assertTerminated | back to summary |
|---|---|
| public final U assertTerminated() Assert that the TestObserver/TestSubscriber terminated (i.e., the terminal latch reached zero).
| |
| assertTimeout | back to summary |
|---|---|
| public final U assertTimeout() Asserts that some awaitX method has timed out. History: 2.0.7 - experimental
| |
| assertValue | back to summary |
|---|---|
| public final U assertValue(T value) Assert that this TestObserver/TestSubscriber received exactly one onNext value which is equal to the given value with respect to Objects.equals.
| |
| assertValue | back to summary |
|---|---|
| public final U assertValue(Predicate<T> valuePredicate) Asserts that this TestObserver/TestSubscriber received exactly one onNext value for which the provided predicate returns true.
| |
| assertValueAt | back to summary |
|---|---|
| public final U assertValueAt(int index, T value) Asserts that this TestObserver/TestSubscriber received an onNext value at the given index which is equal to the given value with respect to null-safe Object.equals. History: 2.1.3 - experimental
| |
| assertValueAt | back to summary |
|---|---|
| public final U assertValueAt(int index, Predicate<T> valuePredicate) Asserts that this TestObserver/TestSubscriber received an onNext value at the given index for the provided predicate returns true.
| |
| assertValueCount | back to summary |
|---|---|
| public final U assertValueCount(int count) Assert that this TestObserver/TestSubscriber received the specified number onNext events.
| |
| assertValues | back to summary |
|---|---|
| public final U assertValues(T... values) Assert that the TestObserver/TestSubscriber received only the specified values in the specified order.
| |
| assertValueSequence | back to summary |
|---|---|
| public final U assertValueSequence(Iterable<? extends T> sequence) Assert that the TestObserver/TestSubscriber received only the specified sequence of values in the same order.
| |
| assertValueSequenceOnly | back to summary |
|---|---|
| public final U assertValueSequenceOnly(Iterable<? extends T> sequence) Assert that the TestObserver/TestSubscriber received only the specified values in the specified order without terminating. History: 2.1.14 - experimental
| |
| assertValueSet | back to summary |
|---|---|
| public final U assertValueSet(Collection<? extends T> expected) Assert that the TestObserver/TestSubscriber received only items that are in the specified collection as well, irrespective of the order they were received. This helps asserting when the order of the values is not guaranteed, i.e., when merging asynchronous streams.
To ensure that only the expected items have been received, no more and no less, in any order,
apply
| |
| assertValueSetOnly | back to summary |
|---|---|
| public final U assertValueSetOnly(Collection<? extends T> expected) Assert that the TestObserver/TestSubscriber received only the specified values in any order without terminating. History: 2.1.14 - experimental
| |
| assertValuesOnly | back to summary |
|---|---|
| public final U assertValuesOnly(T... values) Assert that the TestObserver/TestSubscriber received only the specified values in the specified order without terminating. History: 2.1.4 - experimental
| |
| await | back to summary |
|---|---|
| public final U await() throws InterruptedException Awaits until this TestObserver/TestSubscriber receives an onError or onComplete events.
| |
| await | back to summary |
|---|---|
| public final boolean await(long time, TimeUnit unit) throws InterruptedException Awaits the specified amount of time or until this TestObserver/TestSubscriber receives an onError or onComplete events, whichever happens first.
| |
| awaitCount | back to summary |
|---|---|
| public final U awaitCount(int atLeast) Await until the TestObserver/TestSubscriber receives the given number of items or terminates by sleeping 10 milliseconds at a time up to 5000 milliseconds of timeout. History: 2.0.7 - experimental
| |
| awaitCount | back to summary |
|---|---|
| public final U awaitCount(int atLeast, Runnable waitStrategy) Await until the TestObserver/TestSubscriber receives the given number of items or terminates by waiting according to the wait strategy and up to 5000 milliseconds of timeout. History: 2.0.7 - experimental
| |
| awaitCount | back to summary |
|---|---|
| public final U awaitCount(int atLeast, Runnable waitStrategy, long timeoutMillis) Await until the TestObserver/TestSubscriber receives the given number of items or terminates. History: 2.0.7 - experimental
| |
| awaitDone | back to summary |
|---|---|
| public final U awaitDone(long time, TimeUnit unit) Awaits until the internal latch is counted down. If the wait times out or gets interrupted, the TestObserver/TestSubscriber is cancelled.
| |
| awaitTerminalEvent | back to summary |
|---|---|
| public final boolean awaitTerminalEvent() Waits until the any terminal event has been received by this TestObserver/TestSubscriber or returns false if the wait has been interrupted.
| |
| awaitTerminalEvent | back to summary |
|---|---|
| public final boolean awaitTerminalEvent(long duration, TimeUnit unit) Awaits the specified amount of time or until this TestObserver/TestSubscriber receives an onError or onComplete events, whichever happens first.
| |
| clearTimeout | back to summary |
|---|---|
| public final U clearTimeout() Clears the timeout flag set by the await methods when they timed out. History: 2.0.7 - experimental
| |
| completions | back to summary |
|---|---|
| public final long completions() Returns the number of times onComplete was called.
| |
| errorCount | back to summary |
|---|---|
| public final int errorCount() Returns the number of onError exceptions received.
| |
| errors | back to summary |
|---|---|
| public final List Returns a shared list of received onError exceptions.
Note that accessing the errors via certain methods of the
The
A view of the returned List can be created via | |
| fail | back to summary |
|---|---|
| protected final AssertionError fail(String message) Fail with the given message and add the sequence of errors as suppressed ones. Note this is deliberately the only fail method. Most of the times an assertion would fail but it is possible it was due to an exception somewhere. This construct will capture those potential errors and report it along with the original failure.
| |
| getEvents | back to summary |
|---|---|
| public final List Returns a list of 3 other lists: the first inner list contains the plain values received; the second list contains the potential errors and the final list contains the potential completions as Notifications.
| |
| isTerminated | back to summary |
|---|---|
| public final boolean isTerminated() Returns true if TestObserver/TestSubscriber received any onError or onComplete events.
| |
| isTimeout | back to summary |
|---|---|
| public final boolean isTimeout() Returns true if an await timed out.
| |
| lastThread | back to summary |
|---|---|
| public final Thread lastThread() Returns the last thread which called the onXXX methods of this TestObserver/TestSubscriber.
| |
| valueAndClass | back to summary |
|---|---|
| public static String valueAndClass(Object o) Appends the class name to a non-null value. | |
| valueCount | back to summary |
|---|---|
| public final int valueCount() Returns the number of onNext values received.
| |
| values | back to summary |
|---|---|
| public final List Returns a shared list of received onNext values.
Note that accessing the items via certain methods of the
The
A view of the returned List can be created via
| |
| withTag | back to summary |
|---|---|
| public final U withTag(CharSequence tag) Set the tag displayed along with an assertion failure's other state information. History: 2.0.7 - experimental
| |
BaseTestConsumer#awaitCount(int, Runnable).
History: 2.0.7 - experimental
| Modifier and Type | Field and Description |
|---|---|
| public static final BaseTestConsumer. | SLEEP_1000MS
The current thread sleeps for 1000 milliseconds. |
| public static final BaseTestConsumer. | SLEEP_100MS
The current thread sleeps for 100 milliseconds. |
| public static final BaseTestConsumer. | SLEEP_10MS
The current thread sleeps for 10 milliseconds. |
| public static final BaseTestConsumer. | SLEEP_1MS
The current thread sleeps for 1 millisecond. |
| public static final BaseTestConsumer. | SPIN
The wait loop will spin as fast as possible. |
| public static final BaseTestConsumer. | YIELD
The current thread will be yielded. |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public abstract void | |
| pack-priv static void | |
| public static BaseTestConsumer. | |
| public static BaseTestConsumer. |
| SLEEP_1000MS | back to summary |
|---|---|
| public static final BaseTestConsumer. The current thread sleeps for 1000 milliseconds. | |
| SLEEP_100MS | back to summary |
|---|---|
| public static final BaseTestConsumer. The current thread sleeps for 100 milliseconds. | |
| SLEEP_10MS | back to summary |
|---|---|
| public static final BaseTestConsumer. The current thread sleeps for 10 milliseconds. | |
| SLEEP_1MS | back to summary |
|---|---|
| public static final BaseTestConsumer. The current thread sleeps for 1 millisecond. | |
| SPIN | back to summary |
|---|---|
| public static final BaseTestConsumer. The wait loop will spin as fast as possible. | |
| YIELD | back to summary |
|---|---|
| public static final BaseTestConsumer. The current thread will be yielded. | |
| TestWaitStrategy | back to summary |
|---|---|
| private TestWaitStrategy() | |
| run | back to summary |
|---|---|
| public abstract void run() Redeclares java. Doc from java. Runs this operation.
| |
| sleep | back to summary |
|---|---|
| pack-priv static void sleep(int millis) | |
| valueOf | back to summary |
|---|---|
| public static BaseTestConsumer. | |
| values | back to summary |
|---|---|
| public static BaseTestConsumer. | |