.setRestartCount(2)
.setTimeRangeMillis(1000)
.build();
assertFalse(controller.isFlapping());
when(clock.now()).thenReturn(new Instant(0));
controller.started();
when(clock.now()).thenReturn(new Instant(1));
controller.exited(); // 1 second of runtime T=1
assertFalse(controller.isFlapping());
controller.started();
when(clock.now()).thenReturn(new Instant(2));
controller.exited(); // total of 2ms of runtime T=2
assertTrue(controller.isFlapping()); // next time job would start would be at t=7 seconds
controller.started();
when(clock.now()).thenReturn(new Instant(8));
controller.exited(); // total of 3ms of runtime T=8 (5 of that is throttle)
assertTrue(controller.isFlapping()); // next time job would start would be at t=13
controller.started();
when(clock.now()).thenReturn(new Instant(1034));
controller.exited(); // ran 1021ms additionally here, so should disengage flapping T=1034
assertFalse(controller.isFlapping());
}