use of com.oath.cyclops.util.SimpleTimer in project cyclops by aol.
the class FutureOrElseValueTest method recoverWith_nonBlocking.
@Test
public void recoverWith_nonBlocking() throws InterruptedException {
SimpleTimer timer = new SimpleTimer();
Future.of(() -> {
try {
Thread.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
throw new RuntimeException();
}).recoverWith(() -> {
try {
Thread.sleep(100000);
} catch (InterruptedException e) {
e.printStackTrace();
}
return Future.ofResult(1);
});
Thread.sleep(100);
assertThat(timer.getElapsedMillis(), lessThan(1000L));
}
use of com.oath.cyclops.util.SimpleTimer in project cyclops by aol.
the class AsyncRSBatchingTest method judder.
@Test
public void judder() {
SimpleTimer timer = new SimpleTimer();
assertThat(of(1, 2, 3, 4, 5, 6).jitter(10000).collect(Collectors.toList()).size(), is(6));
assertThat(timer.getElapsedNanoseconds(), greaterThan(20000l));
}
use of com.oath.cyclops.util.SimpleTimer in project cyclops by aol.
the class AsyncRSBatchingTest method debounce.
@Test
public void debounce() {
SimpleTimer timer = new SimpleTimer();
assertThat(of(1, 2, 3, 4, 5, 6).debounce(1000, TimeUnit.SECONDS).collect(Collectors.toList()).size(), is(1));
}
use of com.oath.cyclops.util.SimpleTimer in project cyclops by aol.
the class BatchingRSTest method debounce.
@Test
public void debounce() {
SimpleTimer timer = new SimpleTimer();
assertThat(of(1, 2, 3, 4, 5, 6).debounce(1000, TimeUnit.SECONDS).to(Streamable::fromStream).collect(Collectors.toList()).size(), is(1));
}
use of com.oath.cyclops.util.SimpleTimer in project cyclops by aol.
the class BatchingRSTest method onePer.
@Test
public void onePer() {
SimpleTimer timer = new SimpleTimer();
System.out.println(of(1, 2, 3, 4, 5, 6).onePer(1000, TimeUnit.NANOSECONDS).to(Streamable::fromStream).collect(Collectors.toList()));
assertThat(of(1, 2, 3, 4, 5, 6).onePer(1000, TimeUnit.NANOSECONDS).to(Streamable::fromStream).collect(Collectors.toList()).size(), is(6));
assertThat(timer.getElapsedNanoseconds(), greaterThan(600l));
}
Aggregations