@Test(expected = NullPointerException.class) public void getNullUnit() { normal.completable.blockingGet(1, null); }
@Test(timeout = 5000) public void getTimeout() { try { Completable.never().blockingGet(100, TimeUnit.MILLISECONDS); } catch (RuntimeException ex) { if (!(ex.getCause() instanceof TimeoutException)) { Assert.fail("Wrong exception cause: " + ex.getCause()); } } }
@Override public void run() throws Exception { Completable.complete().delay(10, TimeUnit.SECONDS).blockingGet(); } })
@Test(timeout = 5000) public void getError() { Assert.assertTrue(error.completable.blockingGet() instanceof TestException); }
@Test(timeout = 5000) public void getNormal() { Assert.assertNull(normal.completable.blockingGet()); }
@Test public void blockingGetTimeout() { assertNull(Completable.complete().blockingGet(1, TimeUnit.SECONDS)); }
@Test public void blockingGet() { assertNull(Completable.complete().blockingGet()); }
@Test public void blockingGetError() { TestException ex = new TestException(); assertSame(ex, Completable.error(ex).blockingGet()); }
@Test public void blockingGetErrorTimeout() { TestException ex = new TestException(); assertSame(ex, Completable.error(ex).blockingGet(1, TimeUnit.SECONDS)); }
@Test(timeout = 5000) public void timeoutEmitError() { Throwable e = Completable.never().timeout(100, TimeUnit.MILLISECONDS).blockingGet(); Assert.assertTrue(e instanceof TimeoutException); }
@Test public void testWithEmpty() { assertNull(Observable.empty().ignoreElements().blockingGet()); }
@Test public void testUpstreamIsProcessedButIgnored() { final int num = 10; final AtomicInteger upstreamCount = new AtomicInteger(); Object count = ignoreElements(Flowable.range(1, num) .doOnNext(new Consumer<Integer>() { @Override public void accept(Integer t) { upstreamCount.incrementAndGet(); } }) ) .blockingGet(); assertEquals(num, upstreamCount.get()); assertNull(count); }
@Test public void testUpstreamIsProcessedButIgnored() { final int num = 10; final AtomicInteger upstreamCount = new AtomicInteger(); Object count = Observable.range(1, num) .doOnNext(new Consumer<Integer>() { @Override public void accept(Integer t) { upstreamCount.incrementAndGet(); } }) .ignoreElements() .blockingGet(); assertEquals(num, upstreamCount.get()); assertNull(count); }
@Test public void testWithNonEmpty() { assertNull(ignoreElements(Flowable.just(1, 2, 3)).blockingGet()); }
@Test public void testWithNonEmpty() { assertNull(Observable.just(1, 2, 3).ignoreElements().blockingGet()); }
@Test public void testWithEmpty() { assertNull(ignoreElements(Flowable.empty()).blockingGet()); }