@Test
public void testRetries() throws InterruptedException {

    AtomicInteger counter = new AtomicInteger();
    ScheduleReference reference = localScheduler.scheduleMono(
            scheduleDescriptor.toBuilder().withName("testRetries").build(),
            tick -> Mono.defer(() ->
                    counter.incrementAndGet() % 2 == 0
                            ? Mono.empty()
                            : Mono.error(new RuntimeException("Simulated error at iteration " + counter.get()))),
            Schedulers.parallel()
    );
    expectScheduleAdded(reference);
    expectScheduleUpdateEvent(SchedulingState.Running);
    expectScheduleUpdateEvent(SchedulingState.Failed);
    expectScheduleUpdateEvent(SchedulingState.Waiting);
    expectScheduleUpdateEvent(SchedulingState.Running);
    expectScheduleUpdateEvent(SchedulingState.Succeeded);
}