@Test
public void executorTest() throws InterruptedException, ExecutionException {
ExecutorService executor = Executors.newSingleThreadExecutor();
CompletableFuture<Integer> nTicks = new CompletableFuture<>();
executor.execute(() -> {
EventCounter counter = new EventCounter();
Subscription sub = EventStreams.ticks(Duration.ofMillis(100), scheduler, executor).subscribe(counter);
ScheduledExecutorServiceTimer.create(Duration.ofMillis(350), sub::unsubscribe, scheduler, executor).restart(); // stop after 3 ticks
// wait a little more to test that no more than 3 ticks arrive anyway
ScheduledExecutorServiceTimer.create(Duration.ofMillis(550), () -> nTicks.complete(counter.get()), scheduler, executor).restart();