@Override public Flowable<Object> apply(Flowable<Object> f) throws Exception { return f.dematerialize(); } });
@Test public void testErrorPassThru() { Exception exception = new Exception("test"); Flowable<Integer> flowable = Flowable.error(exception); Flowable<Integer> dematerialize = flowable.dematerialize(); Subscriber<Integer> subscriber = TestHelper.mockSubscriber(); dematerialize.subscribe(subscriber); verify(subscriber, times(1)).onError(exception); verify(subscriber, times(0)).onComplete(); verify(subscriber, times(0)).onNext(any(Integer.class)); }
@Test public void testDematerialize2() { Throwable exception = new Throwable("test"); Flowable<Integer> flowable = Flowable.error(exception); Flowable<Integer> dematerialize = flowable.materialize().dematerialize(); Subscriber<Integer> subscriber = TestHelper.mockSubscriber(); dematerialize.subscribe(subscriber); verify(subscriber, times(1)).onError(exception); verify(subscriber, times(0)).onComplete(); verify(subscriber, times(0)).onNext(any(Integer.class)); }
@Test public void testDematerialize3() { Exception exception = new Exception("test"); Flowable<Integer> flowable = Flowable.error(exception); Flowable<Integer> dematerialize = flowable.materialize().dematerialize(); Subscriber<Integer> subscriber = TestHelper.mockSubscriber(); dematerialize.subscribe(subscriber); verify(subscriber, times(1)).onError(exception); verify(subscriber, times(0)).onComplete(); verify(subscriber, times(0)).onNext(any(Integer.class)); }
@Test public void testDematerialize1() { Flowable<Notification<Integer>> notifications = Flowable.just(1, 2).materialize(); Flowable<Integer> dematerialize = notifications.dematerialize(); Subscriber<Integer> subscriber = TestHelper.mockSubscriber(); dematerialize.subscribe(subscriber); verify(subscriber, times(1)).onNext(1); verify(subscriber, times(1)).onNext(2); verify(subscriber, times(1)).onComplete(); verify(subscriber, never()).onError(any(Throwable.class)); }
@Test public void testCompletePassThru() { Flowable<Integer> flowable = Flowable.empty(); Flowable<Integer> dematerialize = flowable.dematerialize(); Subscriber<Integer> subscriber = TestHelper.mockSubscriber(); TestSubscriber<Integer> ts = new TestSubscriber<Integer>(subscriber); dematerialize.subscribe(ts); System.out.println(ts.errors()); verify(subscriber, never()).onError(any(Throwable.class)); verify(subscriber, times(1)).onComplete(); verify(subscriber, times(0)).onNext(any(Integer.class)); }
@Test public void simpleSelector() { Flowable<Notification<Integer>> notifications = Flowable.just(1, 2).materialize(); Flowable<Integer> dematerialize = notifications.dematerialize(Functions.<Notification<Integer>>identity()); Subscriber<Integer> subscriber = TestHelper.mockSubscriber(); dematerialize.subscribe(subscriber); verify(subscriber, times(1)).onNext(1); verify(subscriber, times(1)).onNext(2); verify(subscriber, times(1)).onComplete(); verify(subscriber, never()).onError(any(Throwable.class)); }
@Test public void testMaterializeDematerializeChaining() { Flowable<Integer> obs = Flowable.just(1); Flowable<Integer> chained = obs.materialize() .dematerialize(Functions.<Notification<Integer>>identity()); Subscriber<Integer> subscriber = TestHelper.mockSubscriber(); chained.subscribe(subscriber); verify(subscriber, times(1)).onNext(1); verify(subscriber, times(1)).onComplete(); verify(subscriber, times(0)).onError(any(Throwable.class)); }
@Test public void testHonorsContractWhenThrows() { Flowable<Integer> source = Flowable.error(new TestException()); Flowable<Integer> result = source.materialize().dematerialize(); Subscriber<Integer> subscriber = TestHelper.mockSubscriber(); result.subscribe(subscriber); verify(subscriber, never()).onNext(any(Integer.class)); verify(subscriber, never()).onComplete(); verify(subscriber).onError(any(TestException.class)); }
@Test public void testHonorsContractWhenCompleted() { Flowable<Integer> source = Flowable.just(1); Flowable<Integer> result = source.materialize().dematerialize(); Subscriber<Integer> subscriber = TestHelper.mockSubscriber(); result.subscribe(subscriber); verify(subscriber).onNext(1); verify(subscriber).onComplete(); verify(subscriber, never()).onError(any(Throwable.class)); }
@Test public void dispose() { TestHelper.checkDisposed(Flowable.just(Notification.createOnComplete()).dematerialize()); }
@Test public void selectorNull() { Flowable.just(1, 2) .materialize() .dematerialize(new Function<Notification<Integer>, Notification<Object>>() { @Override public Notification<Object> apply(Notification<Integer> v) throws Exception { return null; } }) .test() .assertFailure(NullPointerException.class); }
@Test public void selectorCrash() { Flowable.just(1, 2) .materialize() .dematerialize(new Function<Notification<Integer>, Notification<Object>>() { @Override public Notification<Object> apply(Notification<Integer> v) throws Exception { throw new TestException(); } }) .test() .assertFailure(TestException.class); }
@Test public void testErrorThrownIssue1685() { List<Throwable> errors = TestHelper.trackPluginErrors(); try { FlowableProcessor<Object> processor = ReplayProcessor.create(); Flowable.error(new RuntimeException("oops")) .materialize() .delay(1, TimeUnit.SECONDS) .dematerialize(Functions.<Notification<Object>>identity()) .subscribe(processor); processor.subscribe(); processor.materialize().blockingFirst(); System.out.println("Done"); TestHelper.assertError(errors, 0, OnErrorNotImplementedException.class); } finally { RxJavaPlugins.reset(); } }
private Flowable<Tuple2<T1, T2>> build() { return Call.createWithTwoOutParameters(b.connection, b.sql, b.parameterGroups(), b.params, cls1, cls2) // .dematerialize(); } }
private Flowable<Tuple3<T1, T2, T3>> build() { return Call .createWithThreeOutParameters(b.connection, b.sql, b.parameterGroups(), b.params, cls1, cls2, cls3) // .dematerialize(); } }
private Flowable<CallableResultSetN> build() { return Call.createWithNResultSets(b.connection, b.sql, b.parameterGroups(), b.params, functions, 0) // .dematerialize(); } }
private Flowable<T1> build() { return Call.createWithOneOutParameter(b.connection, b.sql, b.parameterGroups(), b.params, cls) // .dematerialize(); } }
private Flowable<CallableResultSet2<T1, T2>> build() { return Call.createWithTwoResultSets(b.connection, b.sql, b.parameterGroups(), b.params, f1, f2, 0) // .dematerialize(); } }
static Flowable<Integer> createWithZeroOutParameters(Single<Connection> connection, String sql, Flowable<List<Object>> parameterGroups, List<ParameterPlaceholder> parameterPlaceholders) { return connection.toFlowable() .flatMap(con -> Call.<Integer>createWithParameters(con, sql, parameterGroups, parameterPlaceholders, (stmt, parameters) -> createWithZeroOutParameters(stmt, parameters, parameterPlaceholders))) .dematerialize(); }