| 1 |
/* |
| 2 |
* Copyright (c) 2016-present, RxJava Contributors. |
| 3 |
* |
| 4 |
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in |
| 5 |
* compliance with the License. You may obtain a copy of the License at |
| 6 |
* |
| 7 |
* http://www.apache.org/licenses/LICENSE-2.0 |
| 8 |
* |
| 9 |
* Unless required by applicable law or agreed to in writing, software distributed under the License is |
| 10 |
* distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See |
| 11 |
* the License for the specific language governing permissions and limitations under the License. |
| 12 |
*/ |
| 13 |
|
| 14 |
package io.reactivex.rxjava3.internal.operators.completable; |
| 15 |
|
| 16 |
import static org.junit.Assert.*; |
| 17 |
|
| 18 |
import java.util.*; |
| 19 |
import java.util.concurrent.atomic.AtomicBoolean; |
| 20 |
|
| 21 |
import org.junit.Test; |
| 22 |
import org.reactivestreams.Subscriber; |
| 23 |
|
| 24 |
import io.reactivex.rxjava3.core.*; |
| 25 |
import io.reactivex.rxjava3.disposables.*; |
| 26 |
import io.reactivex.rxjava3.exceptions.*; |
| 27 |
import io.reactivex.rxjava3.functions.Function; |
| 28 |
import io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription; |
| 29 |
import io.reactivex.rxjava3.internal.util.AtomicThrowable; |
| 30 |
import io.reactivex.rxjava3.observers.TestObserver; |
| 31 |
import io.reactivex.rxjava3.plugins.RxJavaPlugins; |
| 32 |
import io.reactivex.rxjava3.processors.PublishProcessor; |
| 33 |
import io.reactivex.rxjava3.subjects.CompletableSubject; |
| 34 |
import io.reactivex.rxjava3.testsupport.*; |
| 35 |
|
| 36 |
public class CompletableMergeTest extends RxJavaTest { |
| 37 |
@Test |
| 38 |
public void invalidPrefetch() { |
| 39 |
try { |
| 40 |
Completable.merge(Flowable.just(Completable.complete()), -99); |
| 41 |
fail("Should have thrown IllegalArgumentExceptio"); |
| 42 |
} catch (IllegalArgumentException ex) { |
| 43 |
assertEquals("maxConcurrency > 0 required but it was -99", ex.getMessage()); |
| 44 |
} |
| 45 |
} |
| 46 |
|
| 47 |
@Test |
| 48 |
public void cancelAfterFirst() { |
| 49 |
final TestObserver<Void> to = new TestObserver<>(); |
| 50 |
|
| 51 |
Completable.mergeArray(new Completable() { |
| 52 |
@Override |
| 53 |
protected void subscribeActual(CompletableObserver observer) { |
| 54 |
observer.onSubscribe(Disposable.empty()); |
| 55 |
observer.onComplete(); |
| 56 |
to.dispose(); |
| 57 |
} |
| 58 |
}, Completable.complete()) |
| 59 |
.subscribe(to); |
| 60 |
|
| 61 |
to.assertEmpty(); |
| 62 |
} |
| 63 |
|
| 64 |
@Test |
| 65 |
public void cancelAfterFirstDelayError() { |
| 66 |
final TestObserver<Void> to = new TestObserver<>(); |
| 67 |
|
| 68 |
Completable.mergeArrayDelayError(new Completable() { |
| 69 |
@Override |
| 70 |
protected void subscribeActual(CompletableObserver observer) { |
| 71 |
observer.onSubscribe(Disposable.empty()); |
| 72 |
observer.onComplete(); |
| 73 |
to.dispose(); |
| 74 |
} |
| 75 |
}, Completable.complete()) |
| 76 |
.subscribe(to); |
| 77 |
|
| 78 |
to.assertEmpty(); |
| 79 |
} |
| 80 |
|
| 81 |
@Test |
| 82 |
public void onErrorAfterComplete() { |
| 83 |
List<Throwable> errors = TestHelper.trackPluginErrors(); |
| 84 |
try { |
| 85 |
final CompletableObserver[] co = { null }; |
| 86 |
|
| 87 |
Completable.mergeArrayDelayError(Completable.complete(), new Completable() { |
| 88 |
@Override |
| 89 |
protected void subscribeActual(CompletableObserver observer) { |
| 90 |
observer.onSubscribe(Disposable.empty()); |
| 91 |
observer.onComplete(); |
| 92 |
co[0] = observer; |
| 93 |
} |
| 94 |
}) |
| 95 |
.test() |
| 96 |
.assertResult(); |
| 97 |
|
| 98 |
co[0].onError(new TestException()); |
| 99 |
|
| 100 |
TestHelper.assertUndeliverable(errors, 0, TestException.class); |
| 101 |
} finally { |
| 102 |
RxJavaPlugins.reset(); |
| 103 |
} |
| 104 |
} |
| 105 |
|
| 106 |
@Test |
| 107 |
public void completeAfterMain() { |
| 108 |
PublishProcessor<Integer> pp = PublishProcessor.create(); |
| 109 |
|
| 110 |
TestObserver<Void> to = Completable.mergeArray(Completable.complete(), pp.ignoreElements()) |
| 111 |
.test(); |
| 112 |
|
| 113 |
pp.onComplete(); |
| 114 |
|
| 115 |
to.assertResult(); |
| 116 |
} |
| 117 |
|
| 118 |
@Test |
| 119 |
public void completeAfterMainDelayError() { |
| 120 |
PublishProcessor<Integer> pp = PublishProcessor.create(); |
| 121 |
|
| 122 |
TestObserver<Void> to = Completable.mergeArrayDelayError(Completable.complete(), pp.ignoreElements()) |
| 123 |
.test(); |
| 124 |
|
| 125 |
pp.onComplete(); |
| 126 |
|
| 127 |
to.assertResult(); |
| 128 |
} |
| 129 |
|
| 130 |
@Test |
| 131 |
public void errorAfterMainDelayError() { |
| 132 |
PublishProcessor<Integer> pp = PublishProcessor.create(); |
| 133 |
|
| 134 |
TestObserver<Void> to = Completable.mergeArrayDelayError(Completable.complete(), pp.ignoreElements()) |
| 135 |
.test(); |
| 136 |
|
| 137 |
pp.onError(new TestException()); |
| 138 |
|
| 139 |
to.assertFailure(TestException.class); |
| 140 |
} |
| 141 |
|
| 142 |
@Test |
| 143 |
public void dispose() { |
| 144 |
TestHelper.checkDisposed(Completable.merge(Flowable.just(Completable.complete()))); |
| 145 |
} |
| 146 |
|
| 147 |
@Test |
| 148 |
public void disposePropagates() { |
| 149 |
|
| 150 |
PublishProcessor<Integer> pp = PublishProcessor.create(); |
| 151 |
|
| 152 |
TestObserver<Void> to = Completable.merge(Flowable.just(pp.ignoreElements())).test(); |
| 153 |
|
| 154 |
assertTrue(pp.hasSubscribers()); |
| 155 |
|
| 156 |
to.dispose(); |
| 157 |
|
| 158 |
assertFalse(pp.hasSubscribers()); |
| 159 |
|
| 160 |
to.assertEmpty(); |
| 161 |
} |
| 162 |
|
| 163 |
@Test |
| 164 |
public void innerComplete() { |
| 165 |
PublishProcessor<Integer> pp = PublishProcessor.create(); |
| 166 |
|
| 167 |
TestObserver<Void> to = Completable.merge(Flowable.just(pp.ignoreElements())).test(); |
| 168 |
|
| 169 |
pp.onComplete(); |
| 170 |
|
| 171 |
to.assertResult(); |
| 172 |
} |
| 173 |
|
| 174 |
@Test |
| 175 |
public void innerError() { |
| 176 |
PublishProcessor<Integer> pp = PublishProcessor.create(); |
| 177 |
|
| 178 |
TestObserver<Void> to = Completable.merge(Flowable.just(pp.ignoreElements())).test(); |
| 179 |
|
| 180 |
pp.onError(new TestException()); |
| 181 |
|
| 182 |
to.assertFailure(TestException.class); |
| 183 |
} |
| 184 |
|
| 185 |
@Test |
| 186 |
public void innerErrorDelayError() { |
| 187 |
PublishProcessor<Integer> pp = PublishProcessor.create(); |
| 188 |
|
| 189 |
TestObserver<Void> to = Completable.mergeDelayError(Flowable.just(pp.ignoreElements())).test(); |
| 190 |
|
| 191 |
pp.onError(new TestException()); |
| 192 |
|
| 193 |
to.assertFailure(TestException.class); |
| 194 |
} |
| 195 |
|
| 196 |
@Test |
| 197 |
public void mainErrorInnerErrorRace() { |
| 198 |
for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) { |
| 199 |
List<Throwable> errors = TestHelper.trackPluginErrors(); |
| 200 |
try { |
| 201 |
final PublishProcessor<Integer> pp1 = PublishProcessor.create(); |
| 202 |
final PublishProcessor<Integer> pp2 = PublishProcessor.create(); |
| 203 |
|
| 204 |
TestObserverEx<Void> to = Completable.merge(pp1.map(new Function<Integer, Completable>() { |
| 205 |
@Override |
| 206 |
public Completable apply(Integer v) throws Exception { |
| 207 |
return pp2.ignoreElements(); |
| 208 |
} |
| 209 |
})).to(TestHelper.<Void>testConsumer()); |
| 210 |
|
| 211 |
pp1.onNext(1); |
| 212 |
|
| 213 |
final Throwable ex1 = new TestException(); |
| 214 |
final Throwable ex2 = new TestException(); |
| 215 |
|
| 216 |
Runnable r1 = new Runnable() { |
| 217 |
@Override |
| 218 |
public void run() { |
| 219 |
pp1.onError(ex1); |
| 220 |
} |
| 221 |
}; |
| 222 |
Runnable r2 = new Runnable() { |
| 223 |
@Override |
| 224 |
public void run() { |
| 225 |
pp2.onError(ex2); |
| 226 |
} |
| 227 |
}; |
| 228 |
|
| 229 |
TestHelper.race(r1, r2); |
| 230 |
|
| 231 |
Throwable ex = to.errors().get(0); |
| 232 |
if (ex instanceof CompositeException) { |
| 233 |
to.assertSubscribed().assertNoValues().assertNotComplete(); |
| 234 |
|
| 235 |
errors = TestHelper.compositeList(ex); |
| 236 |
TestHelper.assertError(errors, 0, TestException.class); |
| 237 |
TestHelper.assertError(errors, 1, TestException.class); |
| 238 |
} else { |
| 239 |
to.assertFailure(TestException.class); |
| 240 |
|
| 241 |
if (!errors.isEmpty()) { |
| 242 |
TestHelper.assertUndeliverable(errors, 0, TestException.class); |
| 243 |
} |
| 244 |
} |
| 245 |
} finally { |
| 246 |
RxJavaPlugins.reset(); |
| 247 |
} |
| 248 |
} |
| 249 |
} |
| 250 |
|
| 251 |
@Test |
| 252 |
public void mainErrorInnerErrorDelayedRace() { |
| 253 |
for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) { |
| 254 |
final PublishProcessor<Integer> pp1 = PublishProcessor.create(); |
| 255 |
final PublishProcessor<Integer> pp2 = PublishProcessor.create(); |
| 256 |
|
| 257 |
TestObserverEx<Void> to = Completable.mergeDelayError(pp1.map(new Function<Integer, Completable>() { |
| 258 |
@Override |
| 259 |
public Completable apply(Integer v) throws Exception { |
| 260 |
return pp2.ignoreElements(); |
| 261 |
} |
| 262 |
})).to(TestHelper.<Void>testConsumer()); |
| 263 |
|
| 264 |
pp1.onNext(1); |
| 265 |
|
| 266 |
final Throwable ex1 = new TestException(); |
| 267 |
|
| 268 |
Runnable r1 = new Runnable() { |
| 269 |
@Override |
| 270 |
public void run() { |
| 271 |
pp1.onError(ex1); |
| 272 |
} |
| 273 |
}; |
| 274 |
|
| 275 |
final Throwable ex2 = new TestException(); |
| 276 |
Runnable r2 = new Runnable() { |
| 277 |
@Override |
| 278 |
public void run() { |
| 279 |
pp2.onError(ex2); |
| 280 |
} |
| 281 |
}; |
| 282 |
|
| 283 |
TestHelper.race(r1, r2); |
| 284 |
|
| 285 |
to.assertFailure(CompositeException.class); |
| 286 |
|
| 287 |
List<Throwable> errors = TestHelper.compositeList(to.errors().get(0)); |
| 288 |
|
| 289 |
TestHelper.assertError(errors, 0, TestException.class); |
| 290 |
TestHelper.assertError(errors, 1, TestException.class); |
| 291 |
} |
| 292 |
} |
| 293 |
|
| 294 |
@Test |
| 295 |
public void maxConcurrencyOne() { |
| 296 |
final PublishProcessor<Integer> pp1 = PublishProcessor.create(); |
| 297 |
final PublishProcessor<Integer> pp2 = PublishProcessor.create(); |
| 298 |
|
| 299 |
TestObserver<Void> to = Completable.merge(Flowable.just(pp1.ignoreElements(), pp2.ignoreElements()), 1) |
| 300 |
.test(); |
| 301 |
|
| 302 |
assertTrue(pp1.hasSubscribers()); |
| 303 |
assertFalse(pp2.hasSubscribers()); |
| 304 |
|
| 305 |
pp1.onComplete(); |
| 306 |
|
| 307 |
assertTrue(pp2.hasSubscribers()); |
| 308 |
|
| 309 |
pp2.onComplete(); |
| 310 |
|
| 311 |
to.assertResult(); |
| 312 |
} |
| 313 |
|
| 314 |
@Test |
| 315 |
public void maxConcurrencyOneDelayError() { |
| 316 |
final PublishProcessor<Integer> pp1 = PublishProcessor.create(); |
| 317 |
final PublishProcessor<Integer> pp2 = PublishProcessor.create(); |
| 318 |
|
| 319 |
TestObserver<Void> to = Completable.mergeDelayError(Flowable.just(pp1.ignoreElements(), pp2.ignoreElements()), 1) |
| 320 |
.test(); |
| 321 |
|
| 322 |
assertTrue(pp1.hasSubscribers()); |
| 323 |
assertFalse(pp2.hasSubscribers()); |
| 324 |
|
| 325 |
pp1.onComplete(); |
| 326 |
|
| 327 |
assertTrue(pp2.hasSubscribers()); |
| 328 |
|
| 329 |
pp2.onComplete(); |
| 330 |
|
| 331 |
to.assertResult(); |
| 332 |
} |
| 333 |
|
| 334 |
@Test |
| 335 |
public void maxConcurrencyOneDelayErrorFirst() { |
| 336 |
final PublishProcessor<Integer> pp1 = PublishProcessor.create(); |
| 337 |
final PublishProcessor<Integer> pp2 = PublishProcessor.create(); |
| 338 |
|
| 339 |
TestObserver<Void> to = Completable.mergeDelayError(Flowable.just(pp1.ignoreElements(), pp2.ignoreElements()), 1) |
| 340 |
.test(); |
| 341 |
|
| 342 |
assertTrue(pp1.hasSubscribers()); |
| 343 |
assertFalse(pp2.hasSubscribers()); |
| 344 |
|
| 345 |
pp1.onError(new TestException()); |
| 346 |
|
| 347 |
assertTrue(pp2.hasSubscribers()); |
| 348 |
|
| 349 |
pp2.onComplete(); |
| 350 |
|
| 351 |
to.assertFailure(TestException.class); |
| 352 |
} |
| 353 |
|
| 354 |
@Test |
| 355 |
public void maxConcurrencyOneDelayMainErrors() { |
| 356 |
final PublishProcessor<PublishProcessor<Integer>> pp0 = PublishProcessor.create(); |
| 357 |
final PublishProcessor<Integer> pp1 = PublishProcessor.create(); |
| 358 |
final PublishProcessor<Integer> pp2 = PublishProcessor.create(); |
| 359 |
|
| 360 |
TestObserver<Void> to = Completable.mergeDelayError( |
| 361 |
pp0.map(new Function<PublishProcessor<Integer>, Completable>() { |
| 362 |
@Override |
| 363 |
public Completable apply(PublishProcessor<Integer> v) throws Exception { |
| 364 |
return v.ignoreElements(); |
| 365 |
} |
| 366 |
}), 1) |
| 367 |
.test(); |
| 368 |
|
| 369 |
pp0.onNext(pp1); |
| 370 |
|
| 371 |
assertTrue(pp1.hasSubscribers()); |
| 372 |
assertFalse(pp2.hasSubscribers()); |
| 373 |
|
| 374 |
pp1.onComplete(); |
| 375 |
|
| 376 |
pp0.onNext(pp2); |
| 377 |
pp0.onError(new TestException()); |
| 378 |
|
| 379 |
assertTrue(pp2.hasSubscribers()); |
| 380 |
|
| 381 |
pp2.onComplete(); |
| 382 |
|
| 383 |
to.assertFailure(TestException.class); |
| 384 |
} |
| 385 |
|
| 386 |
@Test |
| 387 |
public void mainDoubleOnError() { |
| 388 |
List<Throwable> errors = TestHelper.trackPluginErrors(); |
| 389 |
try { |
| 390 |
Completable.mergeDelayError(new Flowable<Completable>() { |
| 391 |
@Override |
| 392 |
protected void subscribeActual(Subscriber<? super Completable> s) { |
| 393 |
s.onSubscribe(new BooleanSubscription()); |
| 394 |
s.onNext(Completable.complete()); |
| 395 |
s.onError(new TestException("First")); |
| 396 |
s.onError(new TestException("Second")); |
| 397 |
} |
| 398 |
}) |
| 399 |
.to(TestHelper.<Void>testConsumer()) |
| 400 |
.assertFailureAndMessage(TestException.class, "First"); |
| 401 |
|
| 402 |
TestHelper.assertUndeliverable(errors, 0, TestException.class, "Second"); |
| 403 |
} finally { |
| 404 |
RxJavaPlugins.reset(); |
| 405 |
} |
| 406 |
} |
| 407 |
|
| 408 |
@Test |
| 409 |
public void innerDoubleOnError() { |
| 410 |
List<Throwable> errors = TestHelper.trackPluginErrors(); |
| 411 |
try { |
| 412 |
final CompletableObserver[] o = { null }; |
| 413 |
Completable.mergeDelayError(Flowable.just(new Completable() { |
| 414 |
@Override |
| 415 |
protected void subscribeActual(CompletableObserver observer) { |
| 416 |
observer.onSubscribe(Disposable.empty()); |
| 417 |
observer.onError(new TestException("First")); |
| 418 |
o[0] = observer; |
| 419 |
} |
| 420 |
})) |
| 421 |
.to(TestHelper.<Void>testConsumer()) |
| 422 |
.assertFailureAndMessage(TestException.class, "First"); |
| 423 |
|
| 424 |
o[0].onError(new TestException("Second")); |
| 425 |
|
| 426 |
TestHelper.assertUndeliverable(errors, 0, TestException.class, "Second"); |
| 427 |
} finally { |
| 428 |
RxJavaPlugins.reset(); |
| 429 |
} |
| 430 |
} |
| 431 |
|
| 432 |
@Test |
| 433 |
public void innerIsDisposed() { |
| 434 |
final TestObserver<Void> to = new TestObserver<>(); |
| 435 |
|
| 436 |
Completable.mergeDelayError(Flowable.just(new Completable() { |
| 437 |
@Override |
| 438 |
protected void subscribeActual(CompletableObserver observer) { |
| 439 |
observer.onSubscribe(Disposable.empty()); |
| 440 |
assertFalse(((Disposable)observer).isDisposed()); |
| 441 |
|
| 442 |
to.dispose(); |
| 443 |
|
| 444 |
assertTrue(((Disposable)observer).isDisposed()); |
| 445 |
} |
| 446 |
})) |
| 447 |
.subscribe(to); |
| 448 |
} |
| 449 |
|
| 450 |
@Test |
| 451 |
public void mergeArrayInnerErrorRace() { |
| 452 |
for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) { |
| 453 |
List<Throwable> errors = TestHelper.trackPluginErrors(); |
| 454 |
try { |
| 455 |
final PublishProcessor<Integer> pp1 = PublishProcessor.create(); |
| 456 |
final PublishProcessor<Integer> pp2 = PublishProcessor.create(); |
| 457 |
|
| 458 |
TestObserver<Void> to = Completable.mergeArray(pp1.ignoreElements(), pp2.ignoreElements()).test(); |
| 459 |
|
| 460 |
pp1.onNext(1); |
| 461 |
|
| 462 |
final Throwable ex1 = new TestException(); |
| 463 |
final Throwable ex2 = new TestException(); |
| 464 |
|
| 465 |
Runnable r1 = new Runnable() { |
| 466 |
@Override |
| 467 |
public void run() { |
| 468 |
pp1.onError(ex1); |
| 469 |
} |
| 470 |
}; |
| 471 |
Runnable r2 = new Runnable() { |
| 472 |
@Override |
| 473 |
public void run() { |
| 474 |
pp2.onError(ex2); |
| 475 |
} |
| 476 |
}; |
| 477 |
|
| 478 |
TestHelper.race(r1, r2); |
| 479 |
|
| 480 |
to.assertFailure(TestException.class); |
| 481 |
|
| 482 |
if (!errors.isEmpty()) { |
| 483 |
TestHelper.assertUndeliverable(errors, 0, TestException.class); |
| 484 |
} |
| 485 |
} finally { |
| 486 |
RxJavaPlugins.reset(); |
| 487 |
} |
| 488 |
} |
| 489 |
} |
| 490 |
|
| 491 |
@Test |
| 492 |
public void delayErrorIterableCancel() { |
| 493 |
Completable.mergeDelayError(Arrays.asList(Completable.complete())) |
| 494 |
.test(true) |
| 495 |
.assertEmpty(); |
| 496 |
} |
| 497 |
|
| 498 |
@Test |
| 499 |
public void delayErrorIterableCancelAfterHasNext() { |
| 500 |
final TestObserver<Void> to = new TestObserver<>(); |
| 501 |
|
| 502 |
Completable.mergeDelayError(new Iterable<Completable>() { |
| 503 |
@Override |
| 504 |
public Iterator<Completable> iterator() { |
| 505 |
return new Iterator<Completable>() { |
| 506 |
@Override |
| 507 |
public boolean hasNext() { |
| 508 |
to.dispose(); |
| 509 |
return true; |
| 510 |
} |
| 511 |
|
| 512 |
@Override |
| 513 |
public Completable next() { |
| 514 |
return Completable.complete(); |
| 515 |
} |
| 516 |
|
| 517 |
@Override |
| 518 |
public void remove() { |
| 519 |
throw new UnsupportedOperationException(); |
| 520 |
} |
| 521 |
}; |
| 522 |
} |
| 523 |
}) |
| 524 |
.subscribe(to); |
| 525 |
|
| 526 |
to.assertEmpty(); |
| 527 |
} |
| 528 |
|
| 529 |
@Test |
| 530 |
public void delayErrorIterableCancelAfterNext() { |
| 531 |
final TestObserver<Void> to = new TestObserver<>(); |
| 532 |
|
| 533 |
Completable.mergeDelayError(new Iterable<Completable>() { |
| 534 |
@Override |
| 535 |
public Iterator<Completable> iterator() { |
| 536 |
return new Iterator<Completable>() { |
| 537 |
@Override |
| 538 |
public boolean hasNext() { |
| 539 |
return true; |
| 540 |
} |
| 541 |
|
| 542 |
@Override |
| 543 |
public Completable next() { |
| 544 |
to.dispose(); |
| 545 |
return Completable.complete(); |
| 546 |
} |
| 547 |
|
| 548 |
@Override |
| 549 |
public void remove() { |
| 550 |
throw new UnsupportedOperationException(); |
| 551 |
} |
| 552 |
}; |
| 553 |
} |
| 554 |
}) |
| 555 |
.subscribe(to); |
| 556 |
|
| 557 |
to.assertEmpty(); |
| 558 |
} |
| 559 |
|
| 560 |
@Test |
| 561 |
public void arrayUndeliverableUponCancel() { |
| 562 |
TestHelper.checkUndeliverableUponCancel(new FlowableConverter<Integer, Completable>() { |
| 563 |
@Override |
| 564 |
public Completable apply(Flowable<Integer> upstream) { |
| 565 |
return Completable.mergeArray(upstream.ignoreElements(), Completable.complete().hide()); |
| 566 |
} |
| 567 |
}); |
| 568 |
} |
| 569 |
|
| 570 |
@Test |
| 571 |
public void iterableUndeliverableUponCancel() { |
| 572 |
TestHelper.checkUndeliverableUponCancel(new FlowableConverter<Integer, Completable>() { |
| 573 |
@Override |
| 574 |
public Completable apply(Flowable<Integer> upstream) { |
| 575 |
return Completable.merge(Arrays.asList(upstream.ignoreElements(), Completable.complete().hide())); |
| 576 |
} |
| 577 |
}); |
| 578 |
} |
| 579 |
|
| 580 |
@Test |
| 581 |
public void arrayUndeliverableUponCancelDelayError() { |
| 582 |
TestHelper.checkUndeliverableUponCancel(new FlowableConverter<Integer, Completable>() { |
| 583 |
@Override |
| 584 |
public Completable apply(Flowable<Integer> upstream) { |
| 585 |
return Completable.mergeArrayDelayError(upstream.ignoreElements(), Completable.complete().hide()); |
| 586 |
} |
| 587 |
}); |
| 588 |
} |
| 589 |
|
| 590 |
@Test |
| 591 |
public void iterableUndeliverableUponCancelDelayError() { |
| 592 |
TestHelper.checkUndeliverableUponCancel(new FlowableConverter<Integer, Completable>() { |
| 593 |
@Override |
| 594 |
public Completable apply(Flowable<Integer> upstream) { |
| 595 |
return Completable.mergeDelayError(Arrays.asList(upstream.ignoreElements(), Completable.complete().hide())); |
| 596 |
} |
| 597 |
}); |
| 598 |
} |
| 599 |
|
| 600 |
@Test |
| 601 |
public void iterableCompleteLater() { |
| 602 |
CompletableSubject cs = CompletableSubject.create(); |
| 603 |
|
| 604 |
TestObserver<Void> to = Completable.mergeDelayError(Arrays.asList(cs, cs, cs)) |
| 605 |
.test(); |
| 606 |
|
| 607 |
to.assertEmpty(); |
| 608 |
|
| 609 |
cs.onComplete(); |
| 610 |
|
| 611 |
to.assertResult(); |
| 612 |
} |
| 613 |
|
| 614 |
@Test |
| 615 |
public void terminalDisposed() { |
| 616 |
TestHelper.checkDisposed(new CompletableMergeArrayDelayError.TryTerminateAndReportDisposable(new AtomicThrowable())); |
| 617 |
} |
| 618 |
|
| 619 |
@Test |
| 620 |
public void innerDisposed() { |
| 621 |
TestHelper.checkDisposed(new CompletableMergeArray.InnerCompletableObserver(new TestObserver<Void>(), new AtomicBoolean(), new CompositeDisposable(), 1)); |
| 622 |
} |
| 623 |
|
| 624 |
@Test |
| 625 |
public void doubleOnSubscribe() { |
| 626 |
TestHelper.<Completable>checkDoubleOnSubscribeFlowableToCompletable(f -> Completable.merge(f)); |
| 627 |
} |
| 628 |
} |