@Test
public void testReschedule() throws NoSuchFieldException, IllegalAccessException {

    ScheduledService scheduler = new MeasurableScheduler(NoopRegistry.INSTANCE, "poller", 2);
    LookoutConfig lookoutConfig = new LookoutConfig();
    lookoutConfig.setStepInterval(PRIORITY.HIGH, 1000);
    lookoutConfig.setStepInterval(PRIORITY.NORMAL, 1000);
    lookoutConfig.setStepInterval(PRIORITY.LOW, 1000);
    ReScheduleSupport support = new ReScheduleSupport(scheduler, lookoutConfig, Clock.SYSTEM);
    support.reschedulePoll(function);
    try {
        Thread.sleep(2000);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
    Field field = ReScheduleSupport.class.getDeclaredField("taskResults");
    field.setAccessible(true);
    Set<ReScheduleSupport.TaskResult> set = (Set<ReScheduleSupport.TaskResult>) field
        .get(support);
    phase++;
    support.reschedulePoll(function); //restart
    //assert
    for (ReScheduleSupport.TaskResult result : set) {
        Assert.assertTrue(result.getFuture().isCancelled());
        Assert.assertFalse(result.getEnable().get());
    }
    Assert.assertTrue(phase1Counter.get() > 0);
    try {
        Thread.sleep(2000);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
    Assert.assertTrue(phase2Counter.get() > 0);
}