use of cyclops.reactive.Spouts.of in project cyclops by aol.
the class FlatMapPublisherTest method flatMapPAsync3.
@Test
public void flatMapPAsync3() {
for (int k = 0; k < 10; k++) {
List<Integer> res = Spouts.of(1, 2, 3).mergeMap(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));
}
}
use of cyclops.reactive.Spouts.of in project cyclops by aol.
the class FlatMapPublisherTest method flatMapPAsyncRS3.
@Test
public void flatMapPAsyncRS3() {
for (int k = 0; k < 100; k++) {
Flux<Integer> flux = Flux.from(Spouts.of(1, 2, 3).peek(System.out::println).mergeMap(i -> nextAsync()));
List<Integer> res = flux.collect(Collectors.toList()).block();
System.out.println(res);
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));
}
}
use of cyclops.reactive.Spouts.of in project cyclops by aol.
the class FlatMapPublisherTest method flatMapPAsync2.
@Test
public void flatMapPAsync2() {
for (int k = 0; k < 500; k++) {
System.out.println("****************************NEXT ITERATION " + k);
System.out.println("****************************NEXT ITERATION " + k);
System.out.println("****************************NEXT ITERATION " + k);
System.out.println("****************************NEXT ITERATION " + k);
System.out.println("****************************NEXT ITERATION " + k);
System.out.println("****************************NEXT ITERATION " + k);
System.out.println("****************************NEXT ITERATION " + k + "*************************!!!!!!!!!!!!!!!!!!!!!!!!!!!");
List<Integer> res = Spouts.of(1, 2, 3).mergeMap(i -> nextAsync()).toList();
System.out.println("Result is " + res);
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));
}
}
use of cyclops.reactive.Spouts.of in project cyclops by aol.
the class IterableFlatMapTest method flatMapAsync2.
@Test
public void flatMapAsync2() {
for (int k = 0; k < 100; k++) {
List<Integer> res = Spouts.of(1, 2, 3).concatMap(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));
}
}
use of cyclops.reactive.Spouts.of in project cyclops by aol.
the class IterableFlatMapTest method flatMapPAsync3.
@Test
public void flatMapPAsync3() {
for (int k = 0; k < 10; k++) {
List<Integer> res = Spouts.of(1, 2, 3).concatMap(i -> nextAsyncRS()).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