use of org.openhab.core.scheduler.CronAdjuster in project openhab-core by openhab.
the class CronAdjusterTest method testCronExpression.
@ParameterizedTest
@MethodSource("arguments")
@Timeout(value = 2, unit = TimeUnit.SECONDS)
public void testCronExpression(String in, String cron, String[] outs) {
final CronAdjuster cronAdjuster = new CronAdjuster(cron);
Temporal ldt = LocalDateTime.parse(in);
for (final String out : outs) {
ldt = ldt.with(cronAdjuster);
assertThat("CronAdjuster did return expected next cron string for expression: " + cron, ldt.toString(), equalTo(out));
}
}
use of org.openhab.core.scheduler.CronAdjuster in project openhab-core by openhab.
the class CronSchedulerImpl method schedule.
@Override
public ScheduledCompletableFuture<@Nullable Void> schedule(CronJob job, Map<String, Object> config, String cronExpression) {
final CronAdjuster cronAdjuster = new CronAdjuster(cronExpression);
final SchedulerRunnable runnable = () -> job.run(config);
if (cronAdjuster.isReboot()) {
return scheduler.at(runnable, Instant.ofEpochMilli(1));
} else {
return scheduler.schedule(runnable, cronAdjuster);
}
}
Aggregations