use of io.kestra.core.models.triggers.types.Schedule in project kestra by kestra-io.
the class YamlFlowParserTest method triggerEmpty.
@Test
void triggerEmpty() {
Flow parse = this.parse("flows/tests/trigger-empty.yaml");
assertThat(((Schedule) parse.getTriggers().get(0)).getBackfill().getStart(), nullValue());
}
use of io.kestra.core.models.triggers.types.Schedule in project kestra by kestra-io.
the class YamlFlowParserTest method trigger.
@Test
void trigger() {
Flow parse = this.parse("flows/tests/trigger.yaml");
assertThat(((Schedule) parse.getTriggers().get(0)).getBackfill().getStart(), is(ZonedDateTime.parse("2020-01-01T00:00:00+02:00")));
}
use of io.kestra.core.models.triggers.types.Schedule in project kestra by kestra-io.
the class ConditionServiceTest method exception.
@Test
void exception() throws InterruptedException {
List<LogEntry> logs = new ArrayList<>();
logQueue.receive(logs::add);
Flow flow = TestsUtils.mockFlow();
Schedule schedule = Schedule.builder().id("unit").type(Schedule.class.getName()).cron("0 0 1 * *").build();
RunContext runContext = runContextFactory.of(flow, schedule);
ConditionContext conditionContext = conditionService.conditionContext(runContext, flow, null);
List<Condition> conditions = Collections.singletonList(ExecutionFlowCondition.builder().namespace(flow.getNamespace()).flowId(flow.getId()).build());
conditionService.valid(flow, conditions, conditionContext);
Thread.sleep(250);
assertThat(logs.stream().filter(logEntry -> logEntry.getNamespace().equals("io.kestra.core.services.ConditionServiceTest")).count(), greaterThan(0L));
assertThat(logs.stream().filter(logEntry -> logEntry.getFlowId().equals("exception")).count(), greaterThan(0L));
}
use of io.kestra.core.models.triggers.types.Schedule in project kestra by kestra-io.
the class CronExpressionTest method cronValidation.
@Test
void cronValidation() throws Exception {
Schedule build = Schedule.builder().id(IdUtils.create()).type(Schedule.class.getName()).cron("* * * * *").build();
assertThat(modelValidator.isValid(build).isEmpty(), is(true));
build = Schedule.builder().type(Schedule.class.getName()).cron("$ome Inv@lid Cr0n").build();
assertThat(modelValidator.isValid(build).isPresent(), is(true));
assertThat(modelValidator.isValid(build).get().getMessage(), containsString("invalid cron expression"));
}
Aggregations