@@ -56,7 +56,9 @@ public void onNext(Object t) {
56
56
57
57
/**
58
58
* Constructs a TestSubscriber with the initial request to be requested from upstream.
59
+ *
59
60
* @param initialRequest the initial request value, negative value will revert to the default unbounded behavior
61
+ * @since (if this graduates from "Experimental" replace this parenthetical with the release number)
60
62
*/
61
63
@ SuppressWarnings ("unchecked" )
62
64
@ Experimental
@@ -67,8 +69,10 @@ public TestSubscriber(long initialRequest) {
67
69
/**
68
70
* Constructs a TestSubscriber with the initial request to be requested from upstream
69
71
* and a delegate Observer to wrap.
72
+ *
70
73
* @param initialRequest the initial request value, negative value will revert to the default unbounded behavior
71
74
* @param delegate the Observer instance to wrap
75
+ * @since (if this graduates from "Experimental" replace this parenthetical with the release number)
72
76
*/
73
77
@ Experimental
74
78
public TestSubscriber (Observer <T > delegate , long initialRequest ) {
@@ -78,7 +82,7 @@ public TestSubscriber(Observer<T> delegate, long initialRequest) {
78
82
this .testObserver = new TestObserver <T >(delegate );
79
83
this .initialRequest = initialRequest ;
80
84
}
81
-
85
+
82
86
public TestSubscriber (Subscriber <T > delegate ) {
83
87
this (delegate , -1 );
84
88
}
@@ -305,6 +309,9 @@ public Thread getLastSeenThread() {
305
309
306
310
/**
307
311
* Assert if there is exactly a single completion event.
312
+ *
313
+ * @throws AssertionError if there were zero, or more than one, onCompleted events
314
+ * @since (if this graduates from "Experimental" replace this parenthetical with the release number)
308
315
*/
309
316
@ Experimental
310
317
public void assertCompleted () {
@@ -316,8 +323,12 @@ public void assertCompleted() {
316
323
throw new AssertionError ("Completed multiple times: " + s );
317
324
}
318
325
}
326
+
319
327
/**
320
328
* Assert if there is no completion event.
329
+ *
330
+ * @throws AssertionError if there were one or more than one onCompleted events
331
+ * @since (if this graduates from "Experimental" replace this parenthetical with the release number)
321
332
*/
322
333
@ Experimental
323
334
public void assertNotCompleted () {
@@ -329,9 +340,14 @@ public void assertNotCompleted() {
329
340
throw new AssertionError ("Completed multiple times: " + s );
330
341
}
331
342
}
343
+
332
344
/**
333
345
* Assert if there is exactly one error event which is a subclass of the given class.
346
+ *
334
347
* @param clazz the class to check the error against.
348
+ * @throws AssertionError if there were zero, or more than one, onError events, or if the single onError
349
+ * event did not carry an error of a subclass of the given class
350
+ * @since (if this graduates from "Experimental" replace this parenthetical with the release number)
335
351
*/
336
352
@ Experimental
337
353
public void assertError (Class <? extends Throwable > clazz ) {
@@ -346,9 +362,14 @@ public void assertError(Class<? extends Throwable> clazz) {
346
362
throw new AssertionError ("Exceptions differ; expected: " + clazz + ", actual: " + err .get (0 ), err .get (0 ));
347
363
}
348
364
}
365
+
349
366
/**
350
367
* Assert there is a single onError event with the exact exception.
368
+ *
351
369
* @param throwable the throwable to check
370
+ * @throws AssertionError if there were zero, or more than one, onError events, or if the single onError
371
+ * event did not carry an error that matches the specified throwable
372
+ * @since (if this graduates from "Experimental" replace this parenthetical with the release number)
352
373
*/
353
374
@ Experimental
354
375
public void assertError (Throwable throwable ) {
@@ -363,8 +384,12 @@ public void assertError(Throwable throwable) {
363
384
throw new AssertionError ("Exceptions differ; expected: " + throwable + ", actual: " + err .get (0 ), err .get (0 ));
364
385
}
365
386
}
387
+
366
388
/**
367
389
* Assert for no onError and onCompleted events.
390
+ *
391
+ * @throws AssertionError if there was either an onError or onCompleted event
392
+ * @since (if this graduates from "Experimental" replace this parenthetical with the release number)
368
393
*/
369
394
@ Experimental
370
395
public void assertNoTerminalEvent () {
@@ -381,8 +406,12 @@ public void assertNoTerminalEvent() {
381
406
}
382
407
}
383
408
}
409
+
384
410
/**
385
411
* Assert if there are no onNext events received.
412
+ *
413
+ * @throws AssertionError if there were any onNext events
414
+ * @since (if this graduates from "Experimental" replace this parenthetical with the release number)
386
415
*/
387
416
@ Experimental
388
417
public void assertNoValues () {
@@ -391,9 +420,13 @@ public void assertNoValues() {
391
420
throw new AssertionError ("No onNext events expected yet some received: " + s );
392
421
}
393
422
}
423
+
394
424
/**
395
425
* Assert if the given number of onNext events are received.
426
+ *
396
427
* @param count the expected number of onNext events
428
+ * @throws AssertionError if there were more or fewer onNext events than specified by {@code count}
429
+ * @since (if this graduates from "Experimental" replace this parenthetical with the release number)
397
430
*/
398
431
@ Experimental
399
432
public void assertValueCount (int count ) {
@@ -404,19 +437,26 @@ public void assertValueCount(int count) {
404
437
}
405
438
406
439
/**
407
- * Assert if the received onNext events, in order, are the specified values.
408
- * @param values the values to check
440
+ * Assert if the received onNext events, in order, are the specified items.
441
+ *
442
+ * @param values the items to check
443
+ * @throws AssertionError if the items emitted do not exactly match those specified by {@code values}
444
+ * @since (if this graduates from "Experimental" replace this parenthetical with the release number)
409
445
*/
410
446
@ Experimental
411
447
public void assertValues (T ... values ) {
412
448
assertReceivedOnNext (Arrays .asList (values ));
413
449
}
450
+
414
451
/**
415
- * Assert if there is only a single received onNext event.
416
- * @param values the values to check
452
+ * Assert if there is only a single received onNext event and that it marks the emission of a specific item.
453
+ *
454
+ * @param value the item to check
455
+ * @throws AssertionError if the Observable does not emit only the single item specified by {@code value}
456
+ * @since (if this graduates from "Experimental" replace this parenthetical with the release number)
417
457
*/
418
458
@ Experimental
419
459
public void assertValue (T value ) {
420
460
assertReceivedOnNext (Collections .singletonList (value ));
421
461
}
422
- }
462
+ }
0 commit comments