public void schedule(final ScheduledHealthCheck check, final boolean healthy) {
        unschedule(check.getName());

        final Duration interval;
        if (healthy) {
            interval = check.getSchedule().getCheckInterval();
        } else {
            interval = check.getSchedule().getDowntimeInterval();
        }

        schedule(check, interval, interval);
    }
@Test
    void shouldScheduleCheckForNotAlreadyScheduledUnhealthyDependency() {
        final String name = "test";
        final Schedule schedule = new Schedule();

        final ScheduledHealthCheck check = mock(ScheduledHealthCheck.class);
        when(check.getName())
            .thenReturn(name);
        when(check.getSchedule())
            .thenReturn(schedule);

        when(executor.scheduleWithFixedDelay(check, schedule.getDowntimeInterval().toMilliseconds(),
            schedule.getDowntimeInterval().toMilliseconds(), TimeUnit.MILLISECONDS))
            .thenReturn(mock(ScheduledFuture.class));

        scheduler.schedule(check, false);

        verify(executor).scheduleWithFixedDelay(check, schedule.getDowntimeInterval().toMilliseconds(),
            schedule.getDowntimeInterval().toMilliseconds(), TimeUnit.MILLISECONDS);
    }