Skip to content

Commit

Permalink
feat(core): rename VariableCondition to ExpressionCondition
Browse files Browse the repository at this point in the history
Fixes #3790
  • Loading branch information
loicmathieu committed May 21, 2024
1 parent 6aa1a22 commit 472feea
Show file tree
Hide file tree
Showing 11 changed files with 26 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ protected boolean validateCondition(Condition condition, Flow child, Execution e
protected boolean isMandatoryMultipleCondition(Condition condition) {
return Stream
.of(
VariableCondition.class
ExpressionCondition.class
)
.anyMatch(aClass -> condition.getClass().isAssignableFrom(aClass));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@
full = true,
code = {
"- conditions:",
" - type: io.kestra.plugin.core.condition.VariableCondition",
" - type: io.kestra.plugin.core.condition.ExpressionCondition",
" expression: {{ unknown is defined }}",
}
)
},
aliases = "io.kestra.core.models.conditions.types.VariableCondition"
)
public class VariableCondition extends Condition implements ScheduleCondition {
public class ExpressionCondition extends Condition implements ScheduleCondition {
@NotNull
@NotEmpty
@PluginProperty
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
" key: order-webhook",
" type: io.kestra.plugin.core.trigger.Webhook",
" conditions:",
" - type: io.kestra.plugin.core.condition.VariableCondition",
" - type: io.kestra.plugin.core.condition.ExpressionCondition",
" expression: \"{{ trigger.body.customerId is defined and trigger.body.orderId is defined and trigger.body.orderType is defined }}\""
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.fasterxml.jackson.core.JsonProcessingException;
import io.kestra.core.models.Label;
import io.kestra.plugin.core.condition.VariableCondition;
import io.kestra.plugin.core.condition.ExpressionCondition;
import io.kestra.core.models.flows.input.StringInput;
import io.kestra.core.models.listeners.Listener;
import io.kestra.plugin.core.trigger.Schedule;
Expand Down Expand Up @@ -102,7 +102,7 @@ void of() {
))
.listeners(List.of(
Listener.builder()
.conditions(List.of(VariableCondition.builder().expression("true").build()))
.conditions(List.of(ExpressionCondition.builder().expression("true").build()))
.build()
))
.triggers(List.of(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.kestra.core.schedulers;

import io.kestra.plugin.core.condition.VariableCondition;
import io.kestra.plugin.core.condition.ExpressionCondition;
import io.kestra.core.models.executions.Execution;
import io.kestra.core.models.flows.Flow;
import io.kestra.core.models.flows.State;
Expand Down Expand Up @@ -133,8 +133,8 @@ void failedEvaluationTest() throws Exception {
PollingTrigger pollingTrigger = createPollingTrigger(null)
.conditions(
List.of(
VariableCondition.builder()
.type(VariableCondition.class.getName())
ExpressionCondition.builder()
.type(ExpressionCondition.class.getName())
.expression("{{ trigger.date | date() < now() }}")
.build()
))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.kestra.core.schedulers;

import io.kestra.plugin.core.condition.VariableCondition;
import io.kestra.plugin.core.condition.ExpressionCondition;
import io.kestra.core.models.executions.Execution;
import io.kestra.core.models.executions.LogEntry;
import io.kestra.core.models.flows.Flow;
Expand Down Expand Up @@ -463,8 +463,8 @@ void failedEvaluationTest() {
Schedule schedule = createScheduleTrigger("Europe/Paris", "* * * * *", "failedEvaluation", false)
.conditions(
List.of(
VariableCondition.builder()
.type(VariableCondition.class.getName())
ExpressionCondition.builder()
.type(ExpressionCondition.class.getName())
.expression("{{ trigger.date | date() < now() }}")
.build()
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import io.kestra.plugin.core.condition.ExecutionFlowCondition;
import io.kestra.plugin.core.condition.ExecutionStatusCondition;
import io.kestra.plugin.core.condition.MultipleCondition;
import io.kestra.plugin.core.condition.VariableCondition;
import io.kestra.plugin.core.condition.ExpressionCondition;
import io.kestra.core.models.flows.Flow;
import io.kestra.core.models.flows.State;
import io.kestra.core.models.topologies.FlowRelation;
Expand Down Expand Up @@ -156,7 +156,7 @@ public void multipleCondition() {
"filtered", ExecutionStatusCondition.builder()
.in(List.of(State.Type.SUCCESS))
.build(),
"variables", VariableCondition.builder()
"variables", ExpressionCondition.builder()
.expression("{{ true }}")
.build()
))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import io.kestra.core.models.annotations.Plugin;
import io.kestra.core.models.conditions.ConditionContext;
import io.kestra.core.models.flows.PluginDefault;
import io.kestra.plugin.core.condition.VariableCondition;
import io.kestra.plugin.core.condition.ExpressionCondition;
import io.kestra.core.models.executions.Execution;
import io.kestra.core.models.flows.Flow;
import io.kestra.core.models.tasks.RunnableTask;
Expand Down Expand Up @@ -53,8 +53,8 @@ public void injectFlowAndGlobals() {
DefaultTriggerTester.builder()
.id("trigger")
.type(DefaultTriggerTester.class.getName())
.conditions(List.of(VariableCondition.builder()
.type(VariableCondition.class.getName())
.conditions(List.of(ExpressionCondition.builder()
.type(ExpressionCondition.class.getName())
.build())
)
.build()
Expand All @@ -69,7 +69,7 @@ public void injectFlowAndGlobals() {
new PluginDefault(DefaultTriggerTester.class.getName(), false, ImmutableMap.of(
"set", 123
)),
new PluginDefault(VariableCondition.class.getName(), false, ImmutableMap.of(
new PluginDefault(ExpressionCondition.class.getName(), false, ImmutableMap.of(
"expression", "{{ test }}"
))
))
Expand All @@ -87,7 +87,7 @@ public void injectFlowAndGlobals() {
assertThat(((DefaultTester) injected.getTasks().get(0)).getProperty().getLists().get(0).getVal().size(), is(1));
assertThat(((DefaultTester) injected.getTasks().get(0)).getProperty().getLists().get(0).getVal().get("key"), is("test"));
assertThat(((DefaultTriggerTester) injected.getTriggers().get(0)).getSet(), is(123));
assertThat(((VariableCondition) injected.getTriggers().get(0).getConditions().get(0)).getExpression(), is("{{ test }}"));
assertThat(((ExpressionCondition) injected.getTriggers().get(0).getConditions().get(0)).getExpression(), is("{{ test }}"));
}

@Test
Expand Down Expand Up @@ -133,8 +133,8 @@ public void prefix() {
DefaultTriggerTester.builder()
.id("trigger")
.type(DefaultTriggerTester.class.getName())
.conditions(List.of(VariableCondition.builder()
.type(VariableCondition.class.getName())
.conditions(List.of(ExpressionCondition.builder()
.type(ExpressionCondition.class.getName())
.build())
)
.build()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import static org.hamcrest.Matchers.is;

@MicronautTest
class VariableConditionTest {
class ExpressionConditionTest {
@Inject
ConditionService conditionService;

Expand All @@ -23,7 +23,7 @@ void valid() {
Flow flow = TestsUtils.mockFlow();
Execution execution = TestsUtils.mockExecution(flow, ImmutableMap.of("test", "value"));

VariableCondition build = VariableCondition.builder()
ExpressionCondition build = ExpressionCondition.builder()
.expression("{{ flow.id }}")
.build();

Expand All @@ -37,7 +37,7 @@ void invalid() {
Flow flow = TestsUtils.mockFlow();
Execution execution = TestsUtils.mockExecution(flow, ImmutableMap.of("test", "value"));

VariableCondition build = VariableCondition.builder()
ExpressionCondition build = ExpressionCondition.builder()
.expression("{{ unknown is defined }}")
.build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ void simple() {
"first", ExecutionStatusCondition.builder()
.in(Collections.singletonList(State.Type.SUCCESS))
.build(),
"second", VariableCondition.builder()
"second", ExpressionCondition.builder()
.expression("{{ flow.id }}")
.build()
))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ triggers:
type: io.kestra.plugin.core.trigger.Webhook
key: webhookKey
conditions:
- type: io.kestra.plugin.core.condition.VariableCondition
- type: io.kestra.plugin.core.condition.ExpressionCondition
expression: "{{trigger.body.hello == 'world'}}"

0 comments on commit 472feea

Please sign in to comment.