Repository: kestra-io/kestra (java)

Issue:
Rename VariableCondition to ExpressionCondition or just Condition/Expression
### Issue description

we used to call Pebble expressions "Variables" but we no longer do it. Given we do the entire renaming in 0.17, worth renaming this one too https://develop.kestra.io/plugins/core/conditions/condition/io.kestra.plugin.core.condition.variablecondition 

Current:

```yaml
- conditions:
    - type: io.kestra.plugin.core.condition.VariableCondition
      expression: {{ unknown is defined }}
```

Perhaps we can do this instead?

```yaml
- conditions:
    - type: io.kestra.plugin.core.condition.Expression
      expression: {{ unknown is defined }}
```

Pull request:
feat(core): rename VariableCondition to ExpressionCondition
Fixes #3790

Patch:
diff --git a/core/src/main/java/io/kestra/core/topologies/FlowTopologyService.java b/core/src/main/java/io/kestra/core/topologies/FlowTopologyService.java
index 47fdef2cb..c020bdee7 100644
--- a/core/src/main/java/io/kestra/core/topologies/FlowTopologyService.java
+++ b/core/src/main/java/io/kestra/core/topologies/FlowTopologyService.java
@@ -223,7 +223,7 @@ public class FlowTopologyService {
     protected boolean isMandatoryMultipleCondition(Condition condition) {
         return Stream
             .of(
-                VariableCondition.class
+                ExpressionCondition.class
             )
             .anyMatch(aClass -> condition.getClass().isAssignableFrom(aClass));
     }
diff --git a/core/src/main/java/io/kestra/plugin/core/condition/VariableCondition.java b/core/src/main/java/io/kestra/plugin/core/condition/ExpressionCondition.java
similarity index 91%
rename from core/src/main/java/io/kestra/plugin/core/condition/VariableCondition.java
rename to core/src/main/java/io/kestra/plugin/core/condition/ExpressionCondition.java
index 5f9ebd94d..5bb40a8a5 100644
--- a/core/src/main/java/io/kestra/plugin/core/condition/VariableCondition.java
+++ b/core/src/main/java/io/kestra/plugin/core/condition/ExpressionCondition.java
@@ -33,14 +33,14 @@ import jakarta.validation.constraints.NotNull;
             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
diff --git a/core/src/main/java/io/kestra/plugin/core/execution/Labels.java b/core/src/main/java/io/kestra/plugin/core/execution/Labels.java
index f6394630a..b356bbfb7 100644
--- a/core/src/main/java/io/kestra/plugin/core/execution/Labels.java
+++ b/core/src/main/java/io/kestra/plugin/core/execution/Labels.java
@@ -62,7 +62,7 @@ import static io.kestra.core.utils.Rethrow.throwFunction;
                 "    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 }}\""
             }
         )


Test patch:
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 add95057d..b1bf81b1f 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,7 +2,7 @@ package io.kestra.core.models.flows;
 
 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;
@@ -102,7 +102,7 @@ class FlowWithSourceTest {
             ))
             .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(
diff --git a/core/src/test/java/io/kestra/core/schedulers/SchedulerPollingTriggerTest.java b/core/src/test/java/io/kestra/core/schedulers/SchedulerPollingTriggerTest.java
index ff9b5ee75..a6b3072ff 100644
--- a/core/src/test/java/io/kestra/core/schedulers/SchedulerPollingTriggerTest.java
+++ b/core/src/test/java/io/kestra/core/schedulers/SchedulerPollingTriggerTest.java
@@ -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;
@@ -133,8 +133,8 @@ public class SchedulerPollingTriggerTest extends AbstractSchedulerTest {
         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()
                 ))
diff --git a/core/src/test/java/io/kestra/core/schedulers/SchedulerScheduleTest.java b/core/src/test/java/io/kestra/core/schedulers/SchedulerScheduleTest.java
index 1b5e8f622..10e9dcb09 100644
--- a/core/src/test/java/io/kestra/core/schedulers/SchedulerScheduleTest.java
+++ b/core/src/test/java/io/kestra/core/schedulers/SchedulerScheduleTest.java
@@ -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;
@@ -463,8 +463,8 @@ public class SchedulerScheduleTest extends AbstractSchedulerTest {
         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()
                 )
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 6af619b69..7b3db8dad 100644
--- a/core/src/test/java/io/kestra/core/services/FlowTopologyServiceTest.java
+++ b/core/src/test/java/io/kestra/core/services/FlowTopologyServiceTest.java
@@ -3,7 +3,7 @@ package io.kestra.core.services;
 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;
@@ -156,7 +156,7 @@ class FlowTopologyServiceTest {
                                 "filtered", ExecutionStatusCondition.builder()
                                     .in(List.of(State.Type.SUCCESS))
                                     .build(),
-                                "variables", VariableCondition.builder()
+                                "variables", ExpressionCondition.builder()
                                     .expression("{{ true }}")
                                     .build()
                             ))
diff --git a/core/src/test/java/io/kestra/core/services/PluginDefaultServiceTest.java b/core/src/test/java/io/kestra/core/services/PluginDefaultServiceTest.java
index 7fd1aa64a..b380e6652 100644
--- a/core/src/test/java/io/kestra/core/services/PluginDefaultServiceTest.java
+++ b/core/src/test/java/io/kestra/core/services/PluginDefaultServiceTest.java
@@ -4,7 +4,7 @@ import com.google.common.collect.ImmutableMap;
 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;
@@ -53,8 +53,8 @@ class PluginDefaultServiceTest {
                 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()
@@ -69,7 +69,7 @@ class PluginDefaultServiceTest {
                 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 }}"
                 ))
             ))
@@ -87,7 +87,7 @@ class PluginDefaultServiceTest {
         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
@@ -133,8 +133,8 @@ class PluginDefaultServiceTest {
                 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()
diff --git a/core/src/test/java/io/kestra/plugin/core/condition/VariableConditionTest.java b/core/src/test/java/io/kestra/plugin/core/condition/ExpressionConditionTest.java
similarity index 88%
rename from core/src/test/java/io/kestra/plugin/core/condition/VariableConditionTest.java
rename to core/src/test/java/io/kestra/plugin/core/condition/ExpressionConditionTest.java
index c080a2c9e..a552fa8d9 100644
--- a/core/src/test/java/io/kestra/plugin/core/condition/VariableConditionTest.java
+++ b/core/src/test/java/io/kestra/plugin/core/condition/ExpressionConditionTest.java
@@ -14,7 +14,7 @@ import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.is;
 
 @MicronautTest
-class VariableConditionTest {
+class ExpressionConditionTest {
     @Inject
     ConditionService conditionService;
 
@@ -23,7 +23,7 @@ class VariableConditionTest {
         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();
 
@@ -37,7 +37,7 @@ class VariableConditionTest {
         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();
 
diff --git a/core/src/test/java/io/kestra/plugin/core/condition/MultipleConditionTest.java b/core/src/test/java/io/kestra/plugin/core/condition/MultipleConditionTest.java
index 31e1a1b0e..b7e187ec7 100644
--- a/core/src/test/java/io/kestra/plugin/core/condition/MultipleConditionTest.java
+++ b/core/src/test/java/io/kestra/plugin/core/condition/MultipleConditionTest.java
@@ -31,7 +31,7 @@ class MultipleConditionTest {
                 "first", ExecutionStatusCondition.builder()
                     .in(Collections.singletonList(State.Type.SUCCESS))
                     .build(),
-                "second", VariableCondition.builder()
+                "second", ExpressionCondition.builder()
                     .expression("{{ flow.id }}")
                     .build()
             ))
diff --git a/core/src/test/resources/flows/valids/webhook-with-condition.yaml b/core/src/test/resources/flows/valids/webhook-with-condition.yaml
index 37735207d..45aaf9667 100644
--- a/core/src/test/resources/flows/valids/webhook-with-condition.yaml
+++ b/core/src/test/resources/flows/valids/webhook-with-condition.yaml
@@ -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'}}"
\ No newline at end of file