### Question:
MultiOnCompleteResumeWith implements Multi<T> { @Override public void subscribe(Flow.Subscriber<? super T> subscriber) { source.subscribe(new OnCompleteResumeWithSubscriber<>(subscriber, fallbackPublisher)); } MultiOnCompleteResumeWith(Multi<T> source, Flow.Publisher<? extends T> fallbackPublisher); @Override void subscribe(Flow.Subscriber<? super T> subscriber);  }### Answer:
@Test public void nullFallbackPublisher() { TestSubscriber<Integer> ts = new TestSubscriber<>(); assertThrows(NullPointerException.class, () -> Multi.<Integer>empty() .onCompleteResumeWith(null) .subscribe(ts)); }
@Test public void fallbackToError() { TestSubscriber<Integer> ts = new TestSubscriber<>(); Multi.<Integer>empty() .onCompleteResumeWith(Multi.error(new IllegalArgumentException())) .subscribe(ts); ts.assertFailure(IllegalArgumentException.class); }
@Test public void errorSource() { TestSubscriber<Integer> ts = new TestSubscriber<>(); Multi.<Integer>error(new IOException()) .onCompleteResume(666) .subscribe(ts); ts.assertItemCount(0); ts.assertError(IOException.class); }
@Test public void emptyFallback() { TestSubscriber<Integer> ts = new TestSubscriber<>(); Multi.<Integer>empty() .onCompleteResumeWith(Multi.empty()) .subscribe(ts); ts.assertResult(); }
@Test public void appendAfterItems() { TestSubscriber<Integer> ts = new TestSubscriber<>(Long.MAX_VALUE); Multi.concat(Multi.range(1, 3), Multi.<Integer>empty()) .onCompleteResumeWith(Multi.range(4, 2)) .subscribe(ts); ts.assertResult(1, 2, 3, 4, 5); }
@Test public void appendAfterItemsBackpressure() { TestSubscriber<Integer> ts = new TestSubscriber<>(); Multi.concat(Multi.range(1, 3), Multi.<Integer>empty()) .onCompleteResumeWith(Multi.range(4, 2)) .subscribe(ts); ts.assertEmpty() .request(3) .assertValuesOnly(1, 2, 3) .request(2) .assertResult(1, 2, 3, 4, 5); }
@Test public void multipleAppendAfterItemsBackpressure() { TestSubscriber<Integer> ts = new TestSubscriber<>(); Multi.concat(Multi.<Integer>empty(), Multi.just(1, 2, 3)) .onCompleteResumeWith(Multi.just(4, 5)) .onCompleteResumeWith(Multi.just(6, 7)) .subscribe(ts); ts.assertEmpty() .request(3) .assertValuesOnly(1, 2, 3) .request(2) .assertValuesOnly(1, 2, 3, 4, 5) .request(1) .assertValuesOnly(1, 2, 3, 4, 5, 6) .request(1) .assertResult(1, 2, 3, 4, 5, 6, 7); }
@Test public void appendChain() { TestSubscriber<Integer> ts = new TestSubscriber<>(); Multi.<Integer>just(1, 2, 3) .onCompleteResume(4) .onCompleteResume(5) .onCompleteResumeWith(Multi.just(6, 7)) .onCompleteResume(8) .subscribe(ts); ts.assertEmpty() .requestMax() .assertComplete() .assertResult(1, 2, 3, 4, 5, 6, 7, 8); }