@Override public Publisher<Integer> apply(Flowable<Integer> g) { return g.map(new Function<Integer, Integer>() { @Override public Integer apply(Integer v) throws Exception { return v + 1; } }); } };
@Override public Publisher<Integer> apply(Flowable<Integer> g) { return g.map(new Function<Integer, Integer>() { @Override public Integer apply(Integer v) throws Exception { return v + 1; } }); } };
@Override public Flowable<Integer> apply(final Integer leftValue, Flowable<Integer> rightValues) { return rightValues.map(new Function<Integer, Integer>() { @Override public Integer apply(Integer rightValue) throws Exception { return add.apply(leftValue, rightValue); } }); }
@Override public Publisher<String> apply(Flowable<Integer> t1) { return t1.map(new Function<Integer, String>() { @Override public String apply(Integer v) { return String.valueOf(v); } }); } })
@Override public Flowable<String> apply(Flowable<Map<String, String>> f) { return f.map(new Function<Map<String, String>, String>() { @Override public String apply(Map<String, String> map) { return map.get("firstName"); } }); }
@Override public Flowable<Integer> apply(Integer v) throws Exception { return Flowable.range(1, 2).map(new Function<Integer, Integer>() { @Override public Integer apply(Integer v) throws Exception { throw new TestException(); } }); } })
@Override public Flowable<Object> apply(Integer v) throws Exception { return Flowable.range(1, 2).map(new Function<Integer, Object>() { @Override public Object apply(Integer w) throws Exception { throw new TestException(); } }); } })
@Override public Flowable<Integer> apply(Integer v) throws Exception { return Flowable.range(1, 2).map(new Function<Integer, Integer>() { @Override public Integer apply(Integer w) throws Exception { throw new TestException(); } }); } }, true)
@Override public Flowable<Object> apply(Flowable<Object> f) throws Exception { return f.map(Functions.identity()); } });
@Override public Object apply(Flowable<Object> f) throws Exception { return f.map(Functions.identity()); } }, false, 1, 1, 1);
@Override public Publisher<Integer> createPublisher(long elements) { return Flowable.range(0, (int)elements).map(Functions.<Integer>identity()) ; } }
@Test(expected = NullPointerException.class) public void mapReturnsNull() { just1.map(new Function<Integer, Object>() { @Override public Object apply(Integer v) { return null; } }).blockingSubscribe(); }
@Test public void testTake2() { Flowable<Integer> f = Flowable.just(1, 2, 3, 4, 5); Iterable<String> it = Arrays.asList("a", "b", "c", "d", "e"); SquareStr squareStr = new SquareStr(); f.map(squareStr).zipWith(it, concat2Strings).take(2).subscribe(printer); assertEquals(2, squareStr.counter.get()); }
@SuppressWarnings("unchecked") @Test public void source() { Flowable<Integer> f = Flowable.just(1); assertSame(f, ((HasUpstreamPublisher<Integer>)f.map(Functions.<Integer>identity())).source()); } }
@Test(expected = IllegalArgumentException.class) public void testMapWithIssue417() { Flowable.just(1).observeOn(Schedulers.computation()) .map(new Function<Integer, Integer>() { @Override public Integer apply(Integer arg0) { throw new IllegalArgumentException("any error"); } }).blockingSingle(); }
@Test public void fusionCrash() { MulticastProcessor<Integer> mp = Flowable.range(1, 5) .map(new Function<Integer, Integer>() { @Override public Integer apply(Integer v) throws Exception { throw new IOException(); } }) .subscribeWith(MulticastProcessor.<Integer>create()); mp.test().assertFailure(IOException.class); }
@Test public void synchronousFusedCrash() { Completable.concat(Flowable.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 fusedCrash() { Flowable.range(1, 2) .map(new Function<Integer, Object>() { @Override public Object apply(Integer v) throws Exception { throw new TestException(); } }) .concatMap(Functions.justFunction(Flowable.just(1))) .test() .assertFailure(TestException.class); }
@Test public void fusedSync() { TestSubscriber<Integer> ts = SubscriberFusion.newTest(QueueFuseable.ANY); Flowable.range(1, 5) .map(Functions.<Integer>identity()) .subscribe(ts); SubscriberFusion.assertFusion(ts, QueueFuseable.SYNC) .assertResult(1, 2, 3, 4, 5); }
@Test public void testBackpressure2() { TestSubscriber<Integer> ts = new TestSubscriber<Integer>(); Flowable.range(1, 100000).takeLast(Flowable.bufferSize() * 4) .observeOn(Schedulers.newThread()).map(newSlowProcessor()).subscribe(ts); ts.awaitTerminalEvent(); ts.assertNoErrors(); assertEquals(Flowable.bufferSize() * 4, ts.valueCount()); }