@Test public void cancelOnArrival() { MaybeSubject.create() .test(true) .assertEmpty(); }
@Test public void cancelOnArrival2() { MaybeSubject<Integer> ms = MaybeSubject.create(); ms.test(); ms .test(true) .assertEmpty(); }
@Test public void checkDisposed() { PublishSubject<Integer> ps = PublishSubject.create(); MaybeSubject<Integer> ms = MaybeSubject.create(); TestHelper.checkDisposed(ps.switchMapMaybe(Functions.justFunction(ms))); }
@Test public void untilMaybeMainSuccess() { MaybeSubject<Integer> main = MaybeSubject.create(); MaybeSubject<Integer> other = MaybeSubject.create(); TestObserver<Integer> to = main.takeUntil(other).test(); assertTrue("Main no observers?", main.hasObservers()); assertTrue("Other no observers?", other.hasObservers()); main.onSuccess(1); assertFalse("Main has observers?", main.hasObservers()); assertFalse("Other has observers?", other.hasObservers()); to.assertResult(1); }
@Test public void untilMaybeOtherSuccess() { MaybeSubject<Integer> main = MaybeSubject.create(); MaybeSubject<Integer> other = MaybeSubject.create(); TestObserver<Integer> to = main.takeUntil(other).test(); assertTrue("Main no observers?", main.hasObservers()); assertTrue("Other no observers?", other.hasObservers()); other.onSuccess(1); assertFalse("Main has observers?", main.hasObservers()); assertFalse("Other has observers?", other.hasObservers()); to.assertResult(); }
@Test public void untilMaybeMainComplete() { MaybeSubject<Integer> main = MaybeSubject.create(); MaybeSubject<Integer> other = MaybeSubject.create(); TestObserver<Integer> to = main.takeUntil(other).test(); assertTrue("Main no observers?", main.hasObservers()); assertTrue("Other no observers?", other.hasObservers()); main.onComplete(); assertFalse("Main has observers?", main.hasObservers()); assertFalse("Other has observers?", other.hasObservers()); to.assertResult(); }
@Test public void untilMaybeOtherComplete() { MaybeSubject<Integer> main = MaybeSubject.create(); MaybeSubject<Integer> other = MaybeSubject.create(); TestObserver<Integer> to = main.takeUntil(other).test(); assertTrue("Main no observers?", main.hasObservers()); assertTrue("Other no observers?", other.hasObservers()); other.onComplete(); assertFalse("Main has observers?", main.hasObservers()); assertFalse("Other has observers?", other.hasObservers()); to.assertResult(); }
@Test public void untilMaybeMainError() { MaybeSubject<Integer> main = MaybeSubject.create(); MaybeSubject<Integer> other = MaybeSubject.create(); TestObserver<Integer> to = main.takeUntil(other).test(); assertTrue("Main no observers?", main.hasObservers()); assertTrue("Other no observers?", other.hasObservers()); main.onError(new TestException()); assertFalse("Main has observers?", main.hasObservers()); assertFalse("Other has observers?", other.hasObservers()); to.assertFailure(TestException.class); }
@Test public void untilMaybeOtherError() { MaybeSubject<Integer> main = MaybeSubject.create(); MaybeSubject<Integer> other = MaybeSubject.create(); TestObserver<Integer> to = main.takeUntil(other).test(); assertTrue("Main no observers?", main.hasObservers()); assertTrue("Other no observers?", other.hasObservers()); other.onError(new TestException()); assertFalse("Main has observers?", main.hasObservers()); assertFalse("Other has observers?", other.hasObservers()); to.assertFailure(TestException.class); }
@Test public void cancelOther() { MaybeSubject<Object> other = MaybeSubject.create(); TestSubscriber<Object> ts = Flowable.empty() .concatWith(other) .test(); assertTrue(other.hasObservers()); ts.cancel(); assertFalse(other.hasObservers()); }
@Test public void onSubscribeDispose() { MaybeSubject<Integer> ms = MaybeSubject.create(); Disposable d = Disposables.empty(); ms.onSubscribe(d); assertFalse(d.isDisposed()); ms.onComplete(); d = Disposables.empty(); ms.onSubscribe(d); assertTrue(d.isDisposed()); }
@Test public void cancel() { final PublishSubject<Integer> ps = PublishSubject.create(); final MaybeSubject<Integer> cs = MaybeSubject.create(); TestObserver<Integer> to = ps.mergeWith(cs).test(); assertTrue(ps.hasObservers()); assertTrue(cs.hasObservers()); to.cancel(); assertFalse(ps.hasObservers()); assertFalse(cs.hasObservers()); }
@Test public void cancelMain() { MaybeSubject<Integer> ms = MaybeSubject.create(); PublishProcessor<Integer> pp = PublishProcessor.create(); TestSubscriber<Integer> ts = ms.flatMapPublisher(Functions.justFunction(pp)) .test(); assertTrue(ms.hasObservers()); assertFalse(pp.hasSubscribers()); ts.cancel(); assertFalse(ms.hasObservers()); assertFalse(pp.hasSubscribers()); }
@Test public void untilPublisherOtherOnComplete() { MaybeSubject<Integer> main = MaybeSubject.create(); PublishProcessor<Integer> other = PublishProcessor.create(); TestObserver<Integer> to = main.takeUntil(other).test(); assertTrue("Main no observers?", main.hasObservers()); assertTrue("Other no observers?", other.hasSubscribers()); other.onComplete(); assertFalse("Main has observers?", main.hasObservers()); assertFalse("Other has observers?", other.hasSubscribers()); to.assertResult(); }
@Test public void untilPublisherMainSuccess() { MaybeSubject<Integer> main = MaybeSubject.create(); PublishProcessor<Integer> other = PublishProcessor.create(); TestObserver<Integer> to = main.takeUntil(other).test(); assertTrue("Main no observers?", main.hasObservers()); assertTrue("Other no observers?", other.hasSubscribers()); main.onSuccess(1); assertFalse("Main has observers?", main.hasObservers()); assertFalse("Other has observers?", other.hasSubscribers()); to.assertResult(1); }
@Test public void cancelMain() { MaybeSubject<Integer> ms = MaybeSubject.create(); PublishSubject<Integer> ps = PublishSubject.create(); TestObserver<Integer> to = ms.flatMapObservable(Functions.justFunction(ps)) .test(); assertTrue(ms.hasObservers()); assertFalse(ps.hasObservers()); to.cancel(); assertFalse(ms.hasObservers()); assertFalse(ps.hasObservers()); }
@Test public void untilPublisherMainComplete() { MaybeSubject<Integer> main = MaybeSubject.create(); PublishProcessor<Integer> other = PublishProcessor.create(); TestObserver<Integer> to = main.takeUntil(other).test(); assertTrue("Main no observers?", main.hasObservers()); assertTrue("Other no observers?", other.hasSubscribers()); main.onComplete(); assertFalse("Main has observers?", main.hasObservers()); assertFalse("Other has observers?", other.hasSubscribers()); to.assertResult(); }
@Test public void untilPublisherOtherOnNext() { MaybeSubject<Integer> main = MaybeSubject.create(); PublishProcessor<Integer> other = PublishProcessor.create(); TestObserver<Integer> to = main.takeUntil(other).test(); assertTrue("Main no observers?", main.hasObservers()); assertTrue("Other no observers?", other.hasSubscribers()); other.onNext(1); assertFalse("Main has observers?", main.hasObservers()); assertFalse("Other has observers?", other.hasSubscribers()); to.assertResult(); }
@Test public void untilPublisherMainError() { MaybeSubject<Integer> main = MaybeSubject.create(); PublishProcessor<Integer> other = PublishProcessor.create(); TestObserver<Integer> to = main.takeUntil(other).test(); assertTrue("Main no observers?", main.hasObservers()); assertTrue("Other no observers?", other.hasSubscribers()); main.onError(new TestException()); assertFalse("Main has observers?", main.hasObservers()); assertFalse("Other has observers?", other.hasSubscribers()); to.assertFailure(TestException.class); }
@Test public void untilPublisherOtherError() { MaybeSubject<Integer> main = MaybeSubject.create(); PublishProcessor<Integer> other = PublishProcessor.create(); TestObserver<Integer> to = main.takeUntil(other).test(); assertTrue("Main no observers?", main.hasObservers()); assertTrue("Other no observers?", other.hasSubscribers()); other.onError(new TestException()); assertFalse("Main has observers?", main.hasObservers()); assertFalse("Other has observers?", other.hasSubscribers()); to.assertFailure(TestException.class); }