From 7ddeb609f4eba4a3ecbdcdf192f63264d36d1e6e Mon Sep 17 00:00:00 2001 From: Mathieu Gabelle Date: Thu, 9 Jan 2025 14:04:11 +0100 Subject: [PATCH] refactor: migrate package plugin.core.debug to dynamic properties migrate Return task migrate Echo task migrate associated test using these tasks --- .../io/kestra/plugin/core/debug/Echo.java | 20 ++++++++----------- .../io/kestra/plugin/core/debug/Return.java | 13 ++++++------ .../io/kestra/core/models/flows/FlowTest.java | 5 +++-- .../core/models/flows/FlowWithSourceTest.java | 5 +++-- .../AbstractExecutionRepositoryTest.java | 7 ++++--- .../AbstractFlowRepositoryTest.java | 17 ++++++++-------- .../AbstractTemplateRepositoryTest.java | 3 ++- .../core/runners/ExecutionServiceTest.java | 3 ++- .../core/runners/FlowListenersTest.java | 3 ++- .../core/runners/SkipExecutionCaseTest.java | 3 ++- .../schedulers/AbstractSchedulerTest.java | 3 ++- .../SchedulerTriggerChangeTest.java | 7 ++++--- .../kestra/core/services/FlowServiceTest.java | 8 +++++--- .../services/FlowTopologyServiceTest.java | 3 ++- .../java/io/kestra/core/tasks/FetchTest.java | 2 +- .../kestra/plugin/core/trigger/FlowTest.java | 7 ++++--- .../plugin/core/trigger/ScheduleTest.java | 3 ++- .../io/kestra/jdbc/runner/JdbcQueueTest.java | 3 ++- .../controllers/api/FlowControllerTest.java | 5 +++-- .../api/TemplateControllerTest.java | 14 ++++++------- .../api/TriggerControllerTest.java | 3 ++- 21 files changed, 76 insertions(+), 61 deletions(-) diff --git a/core/src/main/java/io/kestra/plugin/core/debug/Echo.java b/core/src/main/java/io/kestra/plugin/core/debug/Echo.java index 3ad48c9edb7..067d78d4bb6 100644 --- a/core/src/main/java/io/kestra/plugin/core/debug/Echo.java +++ b/core/src/main/java/io/kestra/plugin/core/debug/Echo.java @@ -1,8 +1,7 @@ package io.kestra.plugin.core.debug; -import io.kestra.core.models.annotations.PluginProperty; +import io.kestra.core.models.property.Property; import io.kestra.plugin.core.log.Log; -import io.micronaut.core.annotation.NonNull; import io.swagger.v3.oas.annotations.media.Schema; import lombok.*; import lombok.experimental.SuperBuilder; @@ -14,8 +13,9 @@ import io.kestra.core.runners.RunContext; import org.slf4j.event.Level; -import jakarta.validation.constraints.NotBlank; - +/** + * @deprecated + */ @SuperBuilder @ToString @EqualsAndHashCode @@ -46,20 +46,16 @@ ) @Deprecated public class Echo extends Task implements RunnableTask { - @NonNull - @NotBlank - @PluginProperty(dynamic = true) - private String format; + private Property format; @Builder.Default - @PluginProperty - private Level level = Level.INFO; + private Property level = Property.of(Level.INFO); @Override public VoidOutput run(RunContext runContext) throws Exception { Log log = Log.builder() - .level(this.level) - .message(this.format) + .level(runContext.render(this.level).as(Level.class).orElseThrow()) + .message(runContext.render(this.format).as(String.class).orElse(null)) .build(); log.run(runContext); return null; diff --git a/core/src/main/java/io/kestra/plugin/core/debug/Return.java b/core/src/main/java/io/kestra/plugin/core/debug/Return.java index 0951cd10f1d..c524ab07792 100644 --- a/core/src/main/java/io/kestra/plugin/core/debug/Return.java +++ b/core/src/main/java/io/kestra/plugin/core/debug/Return.java @@ -1,12 +1,12 @@ package io.kestra.plugin.core.debug; import io.kestra.core.models.annotations.Metric; +import io.kestra.core.models.property.Property; import io.swagger.v3.oas.annotations.media.Schema; import lombok.*; import lombok.experimental.SuperBuilder; import io.kestra.core.models.annotations.Example; import io.kestra.core.models.annotations.Plugin; -import io.kestra.core.models.annotations.PluginProperty; import io.kestra.core.models.executions.metrics.Counter; import io.kestra.core.models.executions.metrics.Timer; import io.kestra.core.models.tasks.RunnableTask; @@ -24,8 +24,10 @@ @NoArgsConstructor @Schema( title = "Return a value for debugging purposes.", - description = "This task is mostly useful for troubleshooting.\n\n" + - "It allows you to return some templated functions, inputs or outputs." + description = """ + This task is mostly useful for troubleshooting. + + It allows you to return some templated functions, inputs or outputs.""" ) @Plugin( examples = { @@ -51,8 +53,7 @@ public class Return extends Task implements RunnableTask { @Schema( title = "The templated string to render." ) - @PluginProperty(dynamic = true) - private String format; + private Property format; @Override public Return.Output run(RunContext runContext) throws Exception { @@ -60,7 +61,7 @@ public Return.Output run(RunContext runContext) throws Exception { Logger logger = runContext.logger(); - String render = runContext.render(format); + String render = runContext.render(format).as(String.class).orElse(null); logger.debug(render); long end = System.nanoTime(); diff --git a/core/src/test/java/io/kestra/core/models/flows/FlowTest.java b/core/src/test/java/io/kestra/core/models/flows/FlowTest.java index d0ac3989c02..b8bb2615a41 100644 --- a/core/src/test/java/io/kestra/core/models/flows/FlowTest.java +++ b/core/src/test/java/io/kestra/core/models/flows/FlowTest.java @@ -1,6 +1,7 @@ package io.kestra.core.models.flows; import io.kestra.core.exceptions.InternalException; +import io.kestra.core.models.property.Property; import io.kestra.core.models.tasks.Task; import io.kestra.core.models.validations.ModelValidator; import io.kestra.core.serializers.YamlParser; @@ -114,13 +115,13 @@ void updateTask() throws InternalException { Flow updated = flow.updateTask("1-2-2_return", Return.builder() .id("1-2-2_return") .type(Return.class.getName()) - .format("{{task.id}}") + .format(new Property<>("{{task.id}}")) .build() ); Task findUpdated = updated.findTaskByTaskId("1-2-2_return"); - assertThat(((Return) findUpdated).getFormat(), is("{{task.id}}")); + assertThat(((Return) findUpdated).getFormat().toString(), is("{{task.id}}")); } @Test diff --git a/core/src/test/java/io/kestra/core/models/flows/FlowWithSourceTest.java b/core/src/test/java/io/kestra/core/models/flows/FlowWithSourceTest.java index 4cbcb0db6a5..5b98e8d4ddb 100644 --- a/core/src/test/java/io/kestra/core/models/flows/FlowWithSourceTest.java +++ b/core/src/test/java/io/kestra/core/models/flows/FlowWithSourceTest.java @@ -2,6 +2,7 @@ import com.fasterxml.jackson.core.JsonProcessingException; import io.kestra.core.models.Label; +import io.kestra.core.models.property.Property; import io.kestra.plugin.core.condition.Expression; import io.kestra.core.models.flows.input.StringInput; import io.kestra.core.models.listeners.Listener; @@ -28,10 +29,10 @@ void source() throws JsonProcessingException { Return.builder() .id(IdUtils.create()) .type(Return.class.getName()) - .format("123456789 \n123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789\n" + + .format(Property.of("123456789 \n123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789\n" + "123456789 \n" + "123456789 \n" + - "123456789 \n") + "123456789 \n")) .build() )) .build(); diff --git a/core/src/test/java/io/kestra/core/repositories/AbstractExecutionRepositoryTest.java b/core/src/test/java/io/kestra/core/repositories/AbstractExecutionRepositoryTest.java index 8004cc8291d..508f0bb760a 100644 --- a/core/src/test/java/io/kestra/core/repositories/AbstractExecutionRepositoryTest.java +++ b/core/src/test/java/io/kestra/core/repositories/AbstractExecutionRepositoryTest.java @@ -14,6 +14,7 @@ import io.kestra.core.models.executions.statistics.Flow; import io.kestra.core.models.flows.FlowScope; import io.kestra.core.models.flows.State; +import io.kestra.core.models.property.Property; import io.kestra.core.models.tasks.ResolvedTask; import io.kestra.core.utils.IdUtils; import io.kestra.core.utils.NamespaceUtils; @@ -63,17 +64,17 @@ public static Execution.ExecutionBuilder builder(State.Type state, String flowId List taskRuns = Arrays.asList( TaskRun.of(execution.build(), ResolvedTask.of( - Return.builder().id("first").type(Return.class.getName()).format("test").build()) + Return.builder().id("first").type(Return.class.getName()).format(Property.of("test")).build()) ) .withState(State.Type.SUCCESS), spyTaskRun(TaskRun.of(execution.build(), ResolvedTask.of( - Return.builder().id("second").type(Return.class.getName()).format("test").build()) + Return.builder().id("second").type(Return.class.getName()).format(Property.of("test")).build()) ) .withState(state), state ), TaskRun.of(execution.build(), ResolvedTask.of( - Return.builder().id("third").type(Return.class.getName()).format("test").build())).withState(state) + Return.builder().id("third").type(Return.class.getName()).format(Property.of("test")).build())).withState(state) ); if (flowId == null) { diff --git a/core/src/test/java/io/kestra/core/repositories/AbstractFlowRepositoryTest.java b/core/src/test/java/io/kestra/core/repositories/AbstractFlowRepositoryTest.java index 479aca39f4b..321547ecb40 100644 --- a/core/src/test/java/io/kestra/core/repositories/AbstractFlowRepositoryTest.java +++ b/core/src/test/java/io/kestra/core/repositories/AbstractFlowRepositoryTest.java @@ -9,6 +9,7 @@ import io.kestra.core.models.executions.Execution; import io.kestra.core.models.flows.*; import io.kestra.core.models.flows.input.StringInput; +import io.kestra.core.models.property.Property; import io.kestra.core.queues.QueueException; import io.kestra.core.schedulers.AbstractSchedulerTest; import io.kestra.core.serializers.JacksonMapper; @@ -74,7 +75,7 @@ protected void init() throws IOException, URISyntaxException { return Flow.builder() .id(flowId) .namespace("io.kestra.unittest") - .tasks(Collections.singletonList(Return.builder().id(taskId).type(Return.class.getName()).format("test").build())); + .tasks(Collections.singletonList(Return.builder().id(taskId).type(Return.class.getName()).format(Property.of("test")).build())); } @Test @@ -141,7 +142,7 @@ protected void revision() throws JsonProcessingException { Flow first = Flow.builder() .id(flowId) .namespace("io.kestra.unittest") - .tasks(Collections.singletonList(Return.builder().id("test").type(Return.class.getName()).format("test").build())) + .tasks(Collections.singletonList(Return.builder().id("test").type(Return.class.getName()).format(Property.of("test")).build())) .inputs(ImmutableList.of(StringInput.builder().type(Type.STRING).id("a").build())) .build(); // create with repository @@ -384,7 +385,7 @@ void updateConflict() { .id(flowId) .namespace("io.kestra.unittest") .inputs(ImmutableList.of(StringInput.builder().type(Type.STRING).id("a").build())) - .tasks(Collections.singletonList(Return.builder().id("test").type(Return.class.getName()).format("test").build())) + .tasks(Collections.singletonList(Return.builder().id("test").type(Return.class.getName()).format(Property.of("test")).build())) .build(); Flow save = flowRepository.create(flow, flow.generateSource(), pluginDefaultService.injectDefaults(flow.withSource(flow.generateSource()))); @@ -396,7 +397,7 @@ void updateConflict() { .id(IdUtils.create()) .namespace("io.kestra.unittest2") .inputs(ImmutableList.of(StringInput.builder().type(Type.STRING).id("b").build())) - .tasks(Collections.singletonList(Return.builder().id("test").type(Return.class.getName()).format("test").build())) + .tasks(Collections.singletonList(Return.builder().id("test").type(Return.class.getName()).format(Property.of("test")).build())) .build(); ; @@ -422,7 +423,7 @@ void removeTrigger() throws TimeoutException, QueueException { .id("sleep") .type(AbstractSchedulerTest.UnitTest.class.getName()) .build())) - .tasks(Collections.singletonList(Return.builder().id("test").type(Return.class.getName()).format("test").build())) + .tasks(Collections.singletonList(Return.builder().id("test").type(Return.class.getName()).format(Property.of("test")).build())) .build(); flow = flowRepository.create(flow, flow.generateSource(), pluginDefaultService.injectDefaults(flow.withSource(flow.generateSource()))); @@ -432,7 +433,7 @@ void removeTrigger() throws TimeoutException, QueueException { Flow update = Flow.builder() .id(flowId) .namespace("io.kestra.unittest") - .tasks(Collections.singletonList(Return.builder().id("test").type(Return.class.getName()).format("test").build())) + .tasks(Collections.singletonList(Return.builder().id("test").type(Return.class.getName()).format(Property.of("test")).build())) .build(); ; @@ -460,7 +461,7 @@ void removeTriggerDelete() throws TimeoutException, QueueException { .id("sleep") .type(AbstractSchedulerTest.UnitTest.class.getName()) .build())) - .tasks(Collections.singletonList(Return.builder().id("test").type(Return.class.getName()).format("test").build())) + .tasks(Collections.singletonList(Return.builder().id("test").type(Return.class.getName()).format(Property.of("test")).build())) .build(); Flow save = flowRepository.create(flow, flow.generateSource(), pluginDefaultService.injectDefaults(flow.withSource(flow.generateSource()))); @@ -533,7 +534,7 @@ protected void lastRevision() { .tenantId(tenantId) .id(flowId) .namespace(namespace) - .tasks(Collections.singletonList(Return.builder().id("test").type(Return.class.getName()).format("test").build())) + .tasks(Collections.singletonList(Return.builder().id("test").type(Return.class.getName()).format(Property.of("test")).build())) .inputs(ImmutableList.of(StringInput.builder().type(Type.STRING).id("a").build())) .build(); // create with repository diff --git a/core/src/test/java/io/kestra/core/repositories/AbstractTemplateRepositoryTest.java b/core/src/test/java/io/kestra/core/repositories/AbstractTemplateRepositoryTest.java index b0ff40962fd..86aaaf057b8 100644 --- a/core/src/test/java/io/kestra/core/repositories/AbstractTemplateRepositoryTest.java +++ b/core/src/test/java/io/kestra/core/repositories/AbstractTemplateRepositoryTest.java @@ -2,6 +2,7 @@ import io.kestra.core.events.CrudEvent; import io.kestra.core.events.CrudEventType; +import io.kestra.core.models.property.Property; import io.kestra.core.models.templates.Template; import io.kestra.plugin.core.debug.Return; import io.kestra.core.utils.IdUtils; @@ -41,7 +42,7 @@ protected void init() throws IOException, URISyntaxException { return Template.builder() .id(IdUtils.create()) .namespace(namespace == null ? "kestra.test" : namespace) - .tasks(Collections.singletonList(Return.builder().id("test").type(Return.class.getName()).format("test").build())); + .tasks(Collections.singletonList(Return.builder().id("test").type(Return.class.getName()).format(Property.of("test")).build())); } @Test diff --git a/core/src/test/java/io/kestra/core/runners/ExecutionServiceTest.java b/core/src/test/java/io/kestra/core/runners/ExecutionServiceTest.java index f7e16d2865f..ae7f82b523e 100644 --- a/core/src/test/java/io/kestra/core/runners/ExecutionServiceTest.java +++ b/core/src/test/java/io/kestra/core/runners/ExecutionServiceTest.java @@ -9,6 +9,7 @@ import io.kestra.core.models.flows.Flow; import io.kestra.core.models.flows.FlowWithSource; import io.kestra.core.models.flows.State; +import io.kestra.core.models.property.Property; import io.kestra.core.repositories.ExecutionRepositoryInterface; import io.kestra.core.repositories.FlowRepositoryInterface; import io.kestra.core.repositories.LogRepositoryInterface; @@ -83,7 +84,7 @@ void restartSimpleRevision() throws Exception { Return.builder() .id("a") .type(Return.class.getName()) - .format("replace") + .format(Property.of("replace")) .build() ), JacksonMapper.ofYaml().writeValueAsString(flow), diff --git a/core/src/test/java/io/kestra/core/runners/FlowListenersTest.java b/core/src/test/java/io/kestra/core/runners/FlowListenersTest.java index e9e945edcb2..2d8ccb254b5 100644 --- a/core/src/test/java/io/kestra/core/runners/FlowListenersTest.java +++ b/core/src/test/java/io/kestra/core/runners/FlowListenersTest.java @@ -1,6 +1,7 @@ package io.kestra.core.runners; import io.kestra.core.models.flows.FlowWithSource; +import io.kestra.core.models.property.Property; import io.kestra.core.services.PluginDefaultService; import io.kestra.core.junit.annotations.KestraTest; import lombok.SneakyThrows; @@ -35,7 +36,7 @@ protected static FlowWithSource create(String flowId, String taskId) { .tasks(Collections.singletonList(Return.builder() .id(taskId) .type(Return.class.getName()) - .format("test") + .format(Property.of("test")) .build())) .build(); return flow.withSource(flow.generateSource()); diff --git a/core/src/test/java/io/kestra/core/runners/SkipExecutionCaseTest.java b/core/src/test/java/io/kestra/core/runners/SkipExecutionCaseTest.java index cd5d07bf747..6ace6c4fb96 100644 --- a/core/src/test/java/io/kestra/core/runners/SkipExecutionCaseTest.java +++ b/core/src/test/java/io/kestra/core/runners/SkipExecutionCaseTest.java @@ -3,6 +3,7 @@ import io.kestra.core.models.executions.Execution; import io.kestra.core.models.flows.Flow; import io.kestra.core.models.flows.State; +import io.kestra.core.models.property.Property; import io.kestra.core.queues.QueueException; import io.kestra.core.queues.QueueFactoryInterface; import io.kestra.core.queues.QueueInterface; @@ -62,7 +63,7 @@ private Flow createFlow() { .tasks(Collections.singletonList(Return.builder() .id("test") .type(Return.class.getName()) - .format("{{ inputs.testInputs }}") + .format(new Property<>("{{ inputs.testInputs }}")) .build())) .build(); } diff --git a/core/src/test/java/io/kestra/core/schedulers/AbstractSchedulerTest.java b/core/src/test/java/io/kestra/core/schedulers/AbstractSchedulerTest.java index 822aab7572b..76ce7559108 100644 --- a/core/src/test/java/io/kestra/core/schedulers/AbstractSchedulerTest.java +++ b/core/src/test/java/io/kestra/core/schedulers/AbstractSchedulerTest.java @@ -7,6 +7,7 @@ import io.kestra.core.models.executions.ExecutionTrigger; import io.kestra.core.models.flows.*; import io.kestra.core.models.flows.input.StringInput; +import io.kestra.core.models.property.Property; import io.kestra.core.models.tasks.WorkerGroup; import io.kestra.core.models.triggers.AbstractTrigger; import io.kestra.core.models.triggers.PollingTriggerInterface; @@ -89,7 +90,7 @@ protected static FlowWithSource createFlow(List triggers, List< .tasks(Collections.singletonList(Return.builder() .id("test") .type(Return.class.getName()) - .format("{{ inputs.testInputs }}") + .format(new Property<>("{{ inputs.testInputs }}")) .build())); if (list != null) { diff --git a/core/src/test/java/io/kestra/core/schedulers/SchedulerTriggerChangeTest.java b/core/src/test/java/io/kestra/core/schedulers/SchedulerTriggerChangeTest.java index 093ad22f891..03b84102852 100644 --- a/core/src/test/java/io/kestra/core/schedulers/SchedulerTriggerChangeTest.java +++ b/core/src/test/java/io/kestra/core/schedulers/SchedulerTriggerChangeTest.java @@ -5,8 +5,8 @@ import io.kestra.core.models.executions.ExecutionKilled; import io.kestra.core.models.executions.ExecutionKilledTrigger; import io.kestra.core.models.executions.LogEntry; -import io.kestra.core.models.flows.Flow; import io.kestra.core.models.flows.FlowWithSource; +import io.kestra.core.models.property.Property; import io.kestra.core.models.triggers.AbstractTrigger; import io.kestra.core.models.triggers.PollingTriggerInterface; import io.kestra.core.models.triggers.TriggerContext; @@ -34,6 +34,7 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; +import static org.testcontainers.shaded.org.awaitility.Awaitility.await; public class SchedulerTriggerChangeTest extends AbstractSchedulerTest { @Inject @@ -66,7 +67,7 @@ public static FlowWithSource createFlow(Duration sleep) { .tasks(Collections.singletonList(Return.builder() .id("test") .type(Return.class.getName()) - .format("{{ inputs.testInputs }}") + .format(new Property<>("{{ inputs.testInputs }}")) .build()) ) .build(); @@ -113,7 +114,7 @@ void run() throws Exception { WorkerTrigger workerTrigger = worker.getWorkerThreadTasks() .stream() .filter(workerJob -> workerJob instanceof WorkerTrigger) - .map(workerJob -> (WorkerTrigger) workerJob) + .map(WorkerTrigger.class::cast) .findFirst() .orElseThrow(); diff --git a/core/src/test/java/io/kestra/core/services/FlowServiceTest.java b/core/src/test/java/io/kestra/core/services/FlowServiceTest.java index 02fa9fd3a4a..a26fcecd9fd 100644 --- a/core/src/test/java/io/kestra/core/services/FlowServiceTest.java +++ b/core/src/test/java/io/kestra/core/services/FlowServiceTest.java @@ -5,10 +5,10 @@ import io.kestra.core.models.flows.FlowWithSource; import io.kestra.core.models.flows.Type; import io.kestra.core.models.flows.input.StringInput; +import io.kestra.core.models.property.Property; import io.kestra.core.repositories.FlowRepositoryInterface; import io.kestra.plugin.core.debug.Echo; import io.kestra.plugin.core.debug.Return; -import io.kestra.plugin.core.log.Log; import jakarta.inject.Inject; import org.junit.jupiter.api.Test; @@ -42,7 +42,7 @@ private static Flow create(String tenantId, String flowId, String taskId, Intege .tasks(Collections.singletonList(Return.builder() .id(taskId) .type(Return.class.getName()) - .format("test") + .format(Property.of("test")) .build())) .build(); } @@ -270,7 +270,7 @@ void propertyRenamingDeprecation() { .tasks(Collections.singletonList(Echo.builder() .id("taskId") .type(Return.class.getName()) - .format("test") + .format(Property.of("test")) .build())) .build(); @@ -301,7 +301,9 @@ void checkAllowedAllNamespaces() { void delete() { Flow flow = create("deleteTest", "test", 1); FlowWithSource saved = flowRepository.create(flow, flow.generateSource(), flow); + assertThat(flowRepository.findById(flow.getTenantId(), flow.getNamespace(), flow.getId()).isPresent(), is(true)); flowService.delete(saved); + assertThat(flowRepository.findById(flow.getTenantId(), flow.getNamespace(), flow.getId()).isPresent(), is(false)); } @Test diff --git a/core/src/test/java/io/kestra/core/services/FlowTopologyServiceTest.java b/core/src/test/java/io/kestra/core/services/FlowTopologyServiceTest.java index 1911b36e683..b43ac2020e1 100644 --- a/core/src/test/java/io/kestra/core/services/FlowTopologyServiceTest.java +++ b/core/src/test/java/io/kestra/core/services/FlowTopologyServiceTest.java @@ -1,6 +1,7 @@ package io.kestra.core.services; import io.kestra.core.models.flows.FlowWithSource; +import io.kestra.core.models.property.Property; import io.kestra.plugin.core.condition.ExecutionFlow; import io.kestra.plugin.core.condition.ExecutionStatus; import io.kestra.plugin.core.condition.MultipleCondition; @@ -242,7 +243,7 @@ private Return returnTask() { return Return.builder() .id("return") .type(Return.class.getName()) - .format("ok") + .format(Property.of("ok")) .build(); } diff --git a/core/src/test/java/io/kestra/core/tasks/FetchTest.java b/core/src/test/java/io/kestra/core/tasks/FetchTest.java index ae61cf84e4d..f7a6b0f49f1 100644 --- a/core/src/test/java/io/kestra/core/tasks/FetchTest.java +++ b/core/src/test/java/io/kestra/core/tasks/FetchTest.java @@ -12,7 +12,7 @@ import org.junit.jupiter.api.Test; @KestraTest(startRunner = true) -public class FetchTest { +class FetchTest { @Test @ExecuteFlow("flows/valids/get-log.yaml") diff --git a/core/src/test/java/io/kestra/plugin/core/trigger/FlowTest.java b/core/src/test/java/io/kestra/plugin/core/trigger/FlowTest.java index d0f2d3172ae..de15f5149a5 100644 --- a/core/src/test/java/io/kestra/plugin/core/trigger/FlowTest.java +++ b/core/src/test/java/io/kestra/plugin/core/trigger/FlowTest.java @@ -3,6 +3,7 @@ import io.kestra.core.models.Label; import io.kestra.core.models.executions.Execution; import io.kestra.core.models.flows.State; +import io.kestra.core.models.property.Property; import io.kestra.core.runners.RunContextFactory; import io.kestra.plugin.core.debug.Return; import io.kestra.core.utils.IdUtils; @@ -39,7 +40,7 @@ void success() { .tasks(Collections.singletonList(Return.builder() .id("test") .type(Return.class.getName()) - .format("test") + .format(Property.of("test")) .build())) .build(); var execution = Execution.builder() @@ -82,7 +83,7 @@ void withTenant() { .tasks(Collections.singletonList(Return.builder() .id("test") .type(Return.class.getName()) - .format("test") + .format(Property.of("test")) .build())) .build(); var execution = Execution.builder() @@ -124,7 +125,7 @@ void success_withLabels() { .tasks(Collections.singletonList(Return.builder() .id("test") .type(Return.class.getName()) - .format("test") + .format(Property.of("test")) .build())) .build(); var execution = Execution.builder() diff --git a/core/src/test/java/io/kestra/plugin/core/trigger/ScheduleTest.java b/core/src/test/java/io/kestra/plugin/core/trigger/ScheduleTest.java index 5b937f95d8e..cad957b010f 100644 --- a/core/src/test/java/io/kestra/plugin/core/trigger/ScheduleTest.java +++ b/core/src/test/java/io/kestra/plugin/core/trigger/ScheduleTest.java @@ -2,6 +2,7 @@ import io.kestra.core.models.Label; import io.kestra.core.models.conditions.ConditionContext; +import io.kestra.core.models.property.Property; import io.kestra.core.models.triggers.Backfill; import io.kestra.core.runners.DefaultRunContext; import io.kestra.core.runners.RunContextInitializer; @@ -69,7 +70,7 @@ private static TriggerContext triggerContext(ZonedDateTime date, Schedule schedu .tasks(Collections.singletonList(Return.builder() .id("test") .type(Return.class.getName()) - .format("test") + .format(Property.of("test")) .build())) .build(); diff --git a/jdbc/src/test/java/io/kestra/jdbc/runner/JdbcQueueTest.java b/jdbc/src/test/java/io/kestra/jdbc/runner/JdbcQueueTest.java index 1f8132e9caa..a309d9f46f2 100644 --- a/jdbc/src/test/java/io/kestra/jdbc/runner/JdbcQueueTest.java +++ b/jdbc/src/test/java/io/kestra/jdbc/runner/JdbcQueueTest.java @@ -1,6 +1,7 @@ package io.kestra.jdbc.runner; import io.kestra.core.models.flows.FlowWithSource; +import io.kestra.core.models.property.Property; import io.kestra.core.queues.QueueException; import io.kestra.core.queues.QueueFactoryInterface; import io.kestra.core.queues.QueueInterface; @@ -131,7 +132,7 @@ private static FlowWithSource builder(String namespace) { return FlowWithSource.builder() .id(IdUtils.create()) .namespace(namespace == null ? "kestra.test" : namespace) - .tasks(Collections.singletonList(Return.builder().id("test").type(Return.class.getName()).format("test").build())) + .tasks(Collections.singletonList(Return.builder().id("test").type(Return.class.getName()).format(Property.of("test")).build())) .build(); } diff --git a/webserver/src/test/java/io/kestra/webserver/controllers/api/FlowControllerTest.java b/webserver/src/test/java/io/kestra/webserver/controllers/api/FlowControllerTest.java index 7296c8b8dc9..2fdde8b96be 100644 --- a/webserver/src/test/java/io/kestra/webserver/controllers/api/FlowControllerTest.java +++ b/webserver/src/test/java/io/kestra/webserver/controllers/api/FlowControllerTest.java @@ -29,6 +29,7 @@ import io.kestra.core.models.flows.Type; import io.kestra.core.models.flows.input.StringInput; import io.kestra.core.models.hierarchies.FlowGraph; +import io.kestra.core.models.property.Property; import io.kestra.core.models.tasks.Task; import io.kestra.core.models.validations.ValidateConstraintViolation; import io.kestra.core.repositories.LocalFlowRepositoryLoader; @@ -409,7 +410,7 @@ void updateTaskFlow() throws InternalException { ); assertThat(get.getId(), is(flow.getId())); - assertThat(((Return) get.findTaskByTaskId("test2")).getFormat(), is("updated task")); + assertThat(((Return) get.findTaskByTaskId("test2")).getFormat().toString(), is("updated task")); HttpClientResponseException e = assertThrows(HttpClientResponseException.class, () -> { client.toBlocking().retrieve( @@ -949,7 +950,7 @@ private Task generateTask(String id, String format) { return Return.builder() .id(id) .type(Return.class.getName()) - .format(format) + .format(new Property<>(format)) .build(); } diff --git a/webserver/src/test/java/io/kestra/webserver/controllers/api/TemplateControllerTest.java b/webserver/src/test/java/io/kestra/webserver/controllers/api/TemplateControllerTest.java index a5d5eae7616..d17c3c39b87 100644 --- a/webserver/src/test/java/io/kestra/webserver/controllers/api/TemplateControllerTest.java +++ b/webserver/src/test/java/io/kestra/webserver/controllers/api/TemplateControllerTest.java @@ -39,7 +39,7 @@ import org.junit.jupiter.api.Test; @KestraTest -@Property(name = "kestra.templates.enabled", value = StringUtils.TRUE) +@io.micronaut.context.annotation.Property(name = "kestra.templates.enabled", value = StringUtils.TRUE) class TemplateControllerTest { @Inject @Client("/") @@ -55,8 +55,8 @@ protected void init() { } private Template createTemplate() { - Task t1 = Return.builder().id("task-1").type(Return.class.getName()).format("test").build(); - Task t2 = Return.builder().id("task-2").type(Return.class.getName()).format("test").build(); + Task t1 = Return.builder().id("task-1").type(Return.class.getName()).format(io.kestra.core.models.property.Property.of("test")).build(); + Task t2 = Return.builder().id("task-2").type(Return.class.getName()).format(io.kestra.core.models.property.Property.of("test")).build(); return Template.builder() .id(IdUtils.create()) .namespace("kestra.test") @@ -65,8 +65,8 @@ private Template createTemplate() { } private Template createTemplate(String friendlyId, String namespace) { - Task t1 = Return.builder().id("task-1").type(Return.class.getName()).format("test").build(); - Task t2 = Return.builder().id("task-2").type(Return.class.getName()).format("test").build(); + Task t1 = Return.builder().id("task-1").type(Return.class.getName()).format(io.kestra.core.models.property.Property.of("test")).build(); + Task t2 = Return.builder().id("task-2").type(Return.class.getName()).format(io.kestra.core.models.property.Property.of("test")).build(); return Template.builder() .id(friendlyId) .namespace(namespace) @@ -132,7 +132,7 @@ void updateTemplate() { client.toBlocking().retrieve(POST("/api/v1/templates", template), Template.class); Template createdTemplate = client.toBlocking().retrieve(HttpRequest.GET("/api/v1/templates/" + template.getNamespace() + "/" + template.getId()), Template.class); assertThat(template.getTasks().size(), is(2)); - Task t3 = Return.builder().id("task-3").type(Return.class.getName()).format("test").build(); + Task t3 = Return.builder().id("task-3").type(Return.class.getName()).format(io.kestra.core.models.property.Property.of("test")).build(); Template updateTemplate = Template.builder().id(template.getId()).namespace(template.getNamespace()).description("My new template description").tasks(Arrays.asList(t3)).build(); client.toBlocking().retrieve(PUT("/api/v1/templates/" + template.getNamespace() + "/" + template.getId(), updateTemplate), Template.class); Template updatedTemplate = client.toBlocking().retrieve(HttpRequest.GET("/api/v1/templates/" + template.getNamespace() + "/" + template.getId()), Template.class); @@ -149,7 +149,7 @@ void listDistinctNamespace() { Template t1 = Template.builder() .id(IdUtils.create()) .namespace("kestra.template.custom") - .tasks(Arrays.asList(Return.builder().id("task").type(Return.class.getName()).format("test").build())) + .tasks(Arrays.asList(Return.builder().id("task").type(Return.class.getName()).format(io.kestra.core.models.property.Property.of("test")).build())) .build(); client.toBlocking().retrieve(POST("/api/v1/templates", t1), Template.class); client.toBlocking().retrieve(POST("/api/v1/templates", createTemplate()), Template.class); diff --git a/webserver/src/test/java/io/kestra/webserver/controllers/api/TriggerControllerTest.java b/webserver/src/test/java/io/kestra/webserver/controllers/api/TriggerControllerTest.java index 1ae9fc10bbf..876861cf7a3 100644 --- a/webserver/src/test/java/io/kestra/webserver/controllers/api/TriggerControllerTest.java +++ b/webserver/src/test/java/io/kestra/webserver/controllers/api/TriggerControllerTest.java @@ -12,6 +12,7 @@ import io.kestra.core.junit.annotations.KestraTest; import io.kestra.core.models.flows.Flow; +import io.kestra.core.models.property.Property; import io.kestra.core.models.triggers.Trigger; import io.kestra.core.tasks.test.PollingTrigger; import io.kestra.core.utils.Await; @@ -363,7 +364,7 @@ private Flow generateFlow(String flowId) { .tasks(Collections.singletonList(Return.builder() .id("task") .type(Return.class.getName()) - .format("return data") + .format(Property.of("return data")) .build())) .triggers(List.of( Schedule.builder()