Debian Codegraph @

src/test/java/io/reactivex/rxjava3/parallel/ParallelFlatMapIterableTest.java

raw
1 /*
2 * Copyright (c) 2016-present, RxJava Contributors.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in
5 * compliance with the License. You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software distributed under the License is
10 * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See
11 * the License for the specific language governing permissions and limitations under the License.
12 */
13
14 package io.reactivex.rxjava3.parallel;
15
16 import java.util.Arrays;
17
18 import org.junit.Test;
19
20 import io.reactivex.rxjava3.core.*;
21
22 public class ParallelFlatMapIterableTest extends RxJavaTest {
23
24 @Test
25 public void subscriberCount() {
26 ParallelFlowableTest.checkSubscriberCount(Flowable.range(1, 5).parallel()
27 .flatMapIterable(v -> Arrays.asList(1, 2, 3)));
28 }
29
30 @Test
31 public void normal() {
32 for (int i = 1; i < 32; i++) {
33 Flowable.range(1, 1000)
34 .parallel(i)
35 .flatMapIterable(v -> Arrays.asList(v, v + 1))
36 .sequential()
37 .test()
38 .withTag("Parallelism: " + i)
39 .assertValueCount(2000)
40 .assertNoErrors()
41 .assertComplete();
42 }
43 }
44
45 @Test
46 public void none() {
47 for (int i = 1; i < 32; i++) {
48 Flowable.range(1, 1000)
49 .parallel(i)
50 .flatMapIterable(v -> Arrays.asList())
51 .sequential()
52 .test()
53 .withTag("Parallelism: " + i)
54 .assertResult();
55 }
56 }
57
58 @Test
59 public void mixed() {
60 for (int i = 1; i < 32; i++) {
61 Flowable.range(1, 1000)
62 .parallel(i)
63 .flatMapIterable(v -> v % 2 == 0 ? Arrays.asList(v) : Arrays.asList())
64 .sequential()
65 .test()
66 .withTag("Parallelism: " + i)
67 .assertValueCount(500)
68 .assertNoErrors()
69 .assertComplete();
70 }
71 }
72 }