Skip to content

Commit bf29c61

Browse files
committed
Adding missing javadocs to TestSubscriber (#1322)
1 parent f4b9b5a commit bf29c61

File tree

1 file changed

+37
-12
lines changed

1 file changed

+37
-12
lines changed

rxjava-core/src/main/java/rx/observers/TestSubscriber.java

Lines changed: 37 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
import rx.Subscriber;
2525

2626
/**
27-
* Subscriber usable for unit testing to perform assertions, inspect received events or wrap a mocked
27+
* Subscriber usable for unit testing to perform assertions, inspect received events, or wrap a mocked
2828
* Subscriber.
2929
*/
3030
public class TestSubscriber<T> extends Subscriber<T> {
@@ -73,10 +73,10 @@ public void onCompleted() {
7373
}
7474

7575
/**
76-
* Get the {@link Notification}s representing each time this subscriber was notified of sequence completion
76+
* Get the {@link Notification}s representing each time this Subscriber was notified of sequence completion
7777
* via {@link #onCompleted}, as a {@link List}.
7878
*
79-
* @return a list of Notifications representing calls to this subscriber's {@link #onCompleted} method
79+
* @return a list of Notifications representing calls to this Subscriber's {@link #onCompleted} method
8080
*/
8181
public List<Notification<T>> getOnCompletedEvents() {
8282
return testObserver.getOnCompletedEvents();
@@ -93,9 +93,9 @@ public void onError(Throwable e) {
9393
}
9494

9595
/**
96-
* Get the {@link Throwable}s this subscriber was notified of via {@link #onError} as a {@link List}.
96+
* Get the {@link Throwable}s this Subscriber was notified of via {@link #onError} as a {@link List}.
9797
*
98-
* @return a list of Throwables passed to this subscriber's {@link #onError} method
98+
* @return a list of the Throwables that were passed to this Subscriber's {@link #onError} method
9999
*/
100100
public List<Throwable> getOnErrorEvents() {
101101
return testObserver.getOnErrorEvents();
@@ -108,16 +108,16 @@ public void onNext(T t) {
108108
}
109109

110110
/**
111-
* Get the sequence of items observed by this subscriber, as an ordered {@link List}.
111+
* Get the sequence of items observed by this Subscriber, as an ordered {@link List}.
112112
*
113-
* @return a list of items observed by this subscriber, in the order in which they were observed
113+
* @return a list of items observed by this Subscriber, in the order in which they were observed
114114
*/
115115
public List<T> getOnNextEvents() {
116116
return testObserver.getOnNextEvents();
117117
}
118118

119119
/**
120-
* Assert that a particular sequence of items was received in order.
120+
* Assert that a particular sequence of items was received by this Subscriber in order.
121121
*
122122
* @param items
123123
* the sequence of items expected to have been observed
@@ -150,14 +150,24 @@ public void assertUnsubscribed() {
150150
}
151151
}
152152

153+
/**
154+
* Assert that this {@code Subscriber} has received no {@code onError} notifications.
155+
*
156+
* @throws AssertionError
157+
* if this {@code Subscriber} has received one or more {@code onError} notifications
158+
*/
153159
public void assertNoErrors() {
154160
if (getOnErrorEvents().size() > 0) {
155161
throw new AssertionError("Unexpected onError events: " + getOnErrorEvents().size(), getOnErrorEvents().get(0));
156162
}
157163
}
158164

159165
/**
160-
* @warn javadoc missing
166+
* Blocks until this Subscriber receives a notification that the Observable is complete (either an
167+
* {@code onCompleted} or {@code onError} notification).
168+
*
169+
* @throws RuntimeException
170+
* if the Subscriber is interrupted before the Observable is able to complete
161171
*/
162172
public void awaitTerminalEvent() {
163173
try {
@@ -168,9 +178,15 @@ public void awaitTerminalEvent() {
168178
}
169179

170180
/**
171-
* @warn javadoc missing
181+
* Blocks until this Subscriber receives a notification that the Observable is complete (either an
182+
* {@code onCompleted} or {@code onError} notification), or until a timeout expires.
183+
*
172184
* @param timeout
185+
* the duration of the timeout
173186
* @param unit
187+
* the units in which {@code timeout} is expressed
188+
* @throws RuntimeException
189+
* if the Subscriber is interrupted before the Observable is able to complete
174190
*/
175191
public void awaitTerminalEvent(long timeout, TimeUnit unit) {
176192
try {
@@ -181,9 +197,15 @@ public void awaitTerminalEvent(long timeout, TimeUnit unit) {
181197
}
182198

183199
/**
184-
* @warn javadoc missing
200+
* Blocks until this Subscriber receives a notification that the Observable is complete (either an
201+
* {@code onCompleted} or {@code onError} notification), or until a timeout expires; if the Subscriber
202+
* is interrupted before either of these events take place, this method unsubscribes the Subscriber from the
203+
* Observable).
204+
*
185205
* @param timeout
206+
* the duration of the timeout
186207
* @param unit
208+
* the units in which {@code timeout} is expressed
187209
*/
188210
public void awaitTerminalEventAndUnsubscribeOnTimeout(long timeout, TimeUnit unit) {
189211
try {
@@ -194,7 +216,10 @@ public void awaitTerminalEventAndUnsubscribeOnTimeout(long timeout, TimeUnit uni
194216
}
195217

196218
/**
197-
* @warn javadoc missing
219+
* Returns the last thread that was in use when an item or notification was received by this Subscriber.
220+
*
221+
* @return the {@code Thread} on which this Subscriber last received an item or notification from the
222+
* Observable it is subscribed to
198223
*/
199224
public Thread getLastSeenThread() {
200225
return lastSeenThread;

0 commit comments

Comments
 (0)