use of cyclops.reactive.Spouts.of in project cyclops by aol.
the class FlatMapTest method flatMapAsync2.
@Test
public void flatMapAsync2() {
for (int k = 0; k < 100; k++) {
List<Integer> res = Spouts.of(1, 2, 3).flatMap(i -> nextAsync()).toList();
assertThat(res.size(), equalTo(Arrays.asList(1, 2, 1, 2, 1, 2).size()));
assertThat(res, hasItems(1, 2));
int one = 0;
int two = 0;
for (Integer next : res) {
if (next == 1) {
one++;
}
if (next == 2) {
two++;
}
}
assertThat(one, equalTo(3));
assertThat(two, equalTo(3));
}
}
Aggregations