use of cyclops.futurestream.SimpleReact in project cyclops by aol.
the class AnyOfTest method testAnyOfCompletableFilterNoError.
// unreliable with filter, as filtered records count as completed.
@Test
// unreliable with filter, as filtered records count as completed.
@Ignore
public void testAnyOfCompletableFilterNoError() {
String result = new SimpleReact().of("hello", "world", "2").onFail(it -> "hello").filter(it -> !"2".equals(it)).peek(it -> System.out.println(it)).anyOf(data -> {
System.out.println(data);
return data;
}).block().firstValue(null);
assertThat(result, is(notNullValue()));
}
use of cyclops.futurestream.SimpleReact in project cyclops by aol.
the class AnyOfTest method testAnyOfCompletableFutureOnFailRecovers.
@Test
public void testAnyOfCompletableFutureOnFailRecovers() {
List<String> urls = Arrays.asList("hello", "world", "2");
List<String> result = new SimpleReact().fromStream(urls.stream().<CompletableFuture<String>>map(it -> handle(it))).capture(e -> e.printStackTrace()).onFail(e -> "woot!").anyOf(data -> {
System.out.println(data);
return data;
}).block();
assertThat(result.size(), is(1));
}
use of cyclops.futurestream.SimpleReact in project cyclops by aol.
the class CaptureTest method capture.
@Test
public void capture() throws InterruptedException {
t = null;
new SimpleReact().of("hello", "world").capture(e -> t = e).peek(System.out::println).then(this::exception).peek(System.out::println).then(s -> "hello" + s).run();
Thread.sleep(500);
assertNotNull(t);
assertFalse(t.toString(), t instanceof SimpleReactFailedStageException);
assertTrue(t.toString(), t instanceof InternalException);
}
use of cyclops.futurestream.SimpleReact in project cyclops by aol.
the class CaptureTest method captureLast.
@Test
public void captureLast() throws InterruptedException {
t = null;
new SimpleReact().of("hello", "world").capture(e -> t = e).peek(System.out::println).peek(System.out::println).then(s -> "hello" + s).then(this::exception).run();
Thread.sleep(500);
assertNotNull(t);
assertFalse(t.toString(), t instanceof SimpleReactFailedStageException);
assertTrue(t.toString(), t instanceof InternalException);
}
use of cyclops.futurestream.SimpleReact in project cyclops by aol.
the class MergeTest method testMergeTypes.
@Test
public void testMergeTypes() throws InterruptedException, ExecutionException {
SimpleReactStream<Integer> stage1 = new SimpleReact().<Integer>ofAsync(() -> 1, () -> 2, () -> 3);
SimpleReactStream<String> stage2 = new SimpleReact().<Integer>ofAsync(() -> 4, () -> 5, () -> 6).then(it -> "*" + it);
List<Object> result = SimpleReactStream.<Object>merge(stage1, stage2).block();
assertThat(result.size(), is(6));
}
Aggregations