@Override public Observable<Integer> apply(final Integer leftValue, Observable<Integer> rightValues) { return rightValues.map(new Function<Integer, Integer>() { @Override public Integer apply(Integer rightValue) throws Exception { return add.apply(leftValue, rightValue); } }); }
@Override public Observable<HorrorMovie> apply(Observable<HorrorMovie> t1) { return t1.map(new Function<HorrorMovie, HorrorMovie>() { @Override public HorrorMovie apply(HorrorMovie v) { return v; } }); } });
@Override public ObservableSource<Object> apply(Observable<Object> v) throws Exception { return v.map(new Function<Object, Object>() { @Override public Object apply(Object w) throws Exception { throw new TestException(); } }); } })
@Override public Observable<String> apply(Observable<Map<String, String>> o) { return o.map(new Function<Map<String, String>, String>() { @Override public String apply(Map<String, String> map) { return map.get("firstName"); } }); }
@Override public ObservableSource<?> apply(Observable<Notification<Object>> no) throws Exception { Observable<Throwable> map = no .takeWhile(ErrorMapperFilter.INSTANCE) .map(ErrorMapperFilter.INSTANCE); return handler.apply(map); } }
@Override public ObservableSource<Object> apply(Observable<Object> o) throws Exception { return o.map(Functions.identity()); } });
@Override public Object apply(Observable<Object> o) throws Exception { return o.map(Functions.identity()); } }, false, 1, 1, 1);
@Override public ObservableSource<Object> apply(Integer v) throws Exception { return Observable.range(1, 2).map(new Function<Integer, Object>() { @Override public Object apply(Integer w) throws Exception { throw new TestException(); } }); } })
@Override public ObservableSource<Integer> apply(Integer v) throws Exception { return Observable.range(1, 2).map(new Function<Integer, Integer>() { @Override public Integer apply(Integer v) throws Exception { throw new TestException(); } }); } })
@Override public Observable<HorrorMovie> apply(Observable<Movie> t) { return Observable.just(new HorrorMovie()).map(new Function<HorrorMovie, HorrorMovie>() { @Override public HorrorMovie apply(HorrorMovie v) { return v; } }); } }
private Observable<Integer> mergeNAsyncStreamsOfN(final int outerSize, final int innerSize) { Observable<Observable<Integer>> os = Observable.range(1, outerSize) .map(new Function<Integer, Observable<Integer>>() { @Override public Observable<Integer> apply(Integer i) { return Observable.range(1, innerSize).subscribeOn(Schedulers.computation()); } }); return Observable.merge(os); }
@Override public Observable<Object> apply(Observable<? extends Throwable> t1) { return t1.map(new Function<Throwable, Integer>() { @Override public Integer apply(Throwable t1) { return 0; } }).startWith(0).cast(Object.class); } }).subscribe(observer);
@Test(expected = NullPointerException.class) public void mapReturnsNull() { just1.map(new Function<Integer, Object>() { @Override public Object apply(Integer v) { return null; } }).blockingSubscribe(); }
@Override public Observable<String> apply(final GroupedObservable<Integer, Integer> group) { return group.subscribeOn(Schedulers.newThread()).map(new Function<Integer, String>() { @Override public String apply(Integer t1) { System.out.println("Received: " + t1 + " on group : " + group.getKey()); return "first groups: " + t1; } }); }
/** * We expect IllegalStateException to pass thru map. */ @Test(expected = IllegalStateException.class) public void testErrorPassesThruMap2() { Observable.error(new IllegalStateException()).map(new Function<Object, Object>() { @Override public Object apply(Object i) { return i; } }).blockingSingle(); }
@Override public Observable<String> apply(final String s) { return Observable.just(s) .mergeWith(Observable.interval(10, TimeUnit.MILLISECONDS) .map(new Function<Long, String>() { @Override public String apply(Long i) { return s + " " + i; } })).take(250); } })
@SuppressWarnings("unchecked") @Test public void source() { Observable<Integer> o = Observable.just(1); assertSame(o, ((HasUpstreamObservableSource<Integer>)o.map(Functions.<Integer>identity())).source()); } }
@Test public void synchronousFusedCrash() { Completable.concat(Observable.range(1, 2).map(new Function<Integer, Completable>() { @Override public Completable apply(Integer v) throws Exception { throw new TestException(); } })) .test() .assertFailure(TestException.class); }
@Test public void fusedReject() { TestObserver<Integer> to = ObserverFusion.newTest(QueueDisposable.ANY | QueueDisposable.BOUNDARY); Observable.range(1, 5) .map(Functions.<Integer>identity()) .subscribe(to); ObserverFusion.assertFusion(to, QueueDisposable.NONE) .assertResult(1, 2, 3, 4, 5); }
@Test public void testBackpressure1() { TestObserver<Integer> ts = new TestObserver<Integer>(); Observable.range(1, 100000).takeLast(1) .observeOn(Schedulers.newThread()) .map(newSlowProcessor()).subscribe(ts); ts.awaitTerminalEvent(); ts.assertNoErrors(); ts.assertValue(100000); }