public Optional<DateTime> nextFutureTime(JobTriggerDto trigger) {
        final DateTime now = clock.nowUTC();
        final DateTime lastNextTime = trigger.nextTime();
        final DateTime lastExecutionTime = trigger.lock().lastLockTime();
        final JobSchedule schedule = trigger.schedule();

        // This is using nextTime to make sure we take the runtime into account and schedule at
        // exactly after the last nextTime.
        final Optional<DateTime> optionalNextTime = schedule.calculateNextTime(lastExecutionTime, lastNextTime, clock);

        if (!optionalNextTime.isPresent()) {
            return Optional.empty();
        }

        DateTime nextTime = optionalNextTime.get();

        // If calculated nextTime is in the past, calculate next time until it is in the future
        // TODO: Is this something we should notify the user about? If a job is using this helper method it probably
        //       doesn't care about this situation. Jobs where it's important that the time doesn't automatically
        //       advance, should probably use a different helper method.
        while (!nextTime.isAfter(now)) {
            LOG.debug("New nextTime <{}> is in the past, re-calculating again", nextTime);
            nextTime = schedule.calculateNextTime(lastExecutionTime, nextTime, clock).orElse(null);
            if (nextTime == null) {
                return Optional.empty();
            }
        }

        return Optional.of(nextTime);
    }
@Test
    public void nextFutureTime() {
        final JobTriggerDto trigger = JobTriggerDto.builderWithClock(clock)
                .jobDefinitionId("abc-123")
                .jobDefinitionType("event-processor-execution-v1")
                .schedule(IntervalJobSchedule.builder()
                        .interval(1)
                        .unit(TimeUnit.SECONDS)
                        .build())
                .build();

        final DateTime nextFutureTime1 = strategies.nextFutureTime(trigger).orElse(null);

        assertThat(nextFutureTime1)
                .isNotNull()
                .isGreaterThanOrEqualTo(clock.nowUTC())
                .isEqualByComparingTo(clock.nowUTC().plusSeconds(1));

        clock.plus(10, TimeUnit.SECONDS);

        final DateTime nextFutureTime2 = strategies.nextFutureTime(trigger).orElse(null);

        assertThat(nextFutureTime2)
                .isNotNull()
                .isGreaterThanOrEqualTo(clock.nowUTC())
                .isEqualByComparingTo(clock.nowUTC().plusSeconds(1));
    }