use of cyclops.futurestream.SimpleReact in project cyclops by aol.
the class BlockingTest method testLast.
@Test
public void testLast() throws InterruptedException, ExecutionException {
Integer result = new SimpleReact().<Integer>ofAsync(() -> 1, () -> 2, () -> 3, () -> 5).then(it -> it * 100).then(it -> sleep(it)).block().takeRight(1).get(0);
assertThat(result, is(500));
}
use of cyclops.futurestream.SimpleReact in project cyclops by aol.
the class BlockingTest method testBreakoutExceptionTimes.
@Test
public void testBreakoutExceptionTimes() throws InterruptedException, ExecutionException {
count = new AtomicInteger(0);
List<Integer> results = new SimpleReact().<Integer>ofAsync(() -> 1, () -> 2, () -> 3).then(it -> it * 100).<Integer>then(it -> {
throw new RuntimeException("boo!");
}).capture(e -> count.incrementAndGet()).block(status -> status.getCompleted() >= 1);
assertThat(results.size(), is(0));
assertThat(count.get(), is(3));
}
use of cyclops.futurestream.SimpleReact in project cyclops by aol.
the class BlockingTest method testBreakoutException.
@Test
public void testBreakoutException() throws InterruptedException, ExecutionException {
Throwable[] error = { null };
List<Integer> results = new SimpleReact().<Integer>ofAsync(() -> 1, () -> 2, () -> 3).then(it -> it * 100).<Integer>then(it -> {
throw new RuntimeException("boo!");
}).capture(e -> error[0] = e.getCause()).block(status -> status.getCompleted() >= 1);
assertThat(results.size(), is(0));
assertThat(error[0], instanceOf(RuntimeException.class));
}
use of cyclops.futurestream.SimpleReact in project cyclops by aol.
the class BlockingTest method testFirstSimple.
@Test
public void testFirstSimple() throws InterruptedException, ExecutionException {
SimpleReactStream<Integer> stage = new SimpleReact().<Integer>ofAsync(() -> 1, () -> 2, () -> 3, () -> 5).then(it -> it * 100).then(it -> sleep(it));
int result = stage.block().firstValue(null);
assertThat(result, is(100));
stage.block();
}
use of cyclops.futurestream.SimpleReact in project cyclops by aol.
the class BlockingTest method testTypeInferencingThen.
@Test
public void testTypeInferencingThen() {
List<String> result = new SimpleReact().ofAsync(() -> "World", () -> "Hello").then(in -> "hello").block();
assertThat(result.size(), is(2));
}
Aggregations