Repository: serverlessworkflow/sdk-java (java)

Issue:
Set should be replacing not merging
Reference implementation needs to be updated to align with latest changes in spec related with Set task [behaviour](https://github.com/serverlessworkflow/specification/issues/1040) 

Pull request description:
[Fix #500] Fixing set behaviour
Fix https://github.com/apache/incubator-kie-kogito-apps/pull/2166

Patch:
diff --git a/impl/core/src/main/java/io/serverlessworkflow/impl/executors/SetExecutor.java b/impl/core/src/main/java/io/serverlessworkflow/impl/executors/SetExecutor.java
index 0f0d999..b06153f 100644
--- a/impl/core/src/main/java/io/serverlessworkflow/impl/executors/SetExecutor.java
+++ b/impl/core/src/main/java/io/serverlessworkflow/impl/executors/SetExecutor.java
@@ -21,7 +21,6 @@ import io.serverlessworkflow.impl.WorkflowContext;
 import io.serverlessworkflow.impl.WorkflowDefinition;
 import io.serverlessworkflow.impl.expressions.ExpressionUtils;
 import io.serverlessworkflow.impl.json.JsonUtils;
-import io.serverlessworkflow.impl.json.MergeUtils;
 import java.util.Map;
 
 public class SetExecutor extends AbstractTaskExecutor<SetTask> {
@@ -38,10 +37,8 @@ public class SetExecutor extends AbstractTaskExecutor<SetTask> {
   @Override
   protected void internalExecute(WorkflowContext workflow, TaskContext<SetTask> taskContext) {
     taskContext.rawOutput(
-        MergeUtils.merge(
-            JsonUtils.fromValue(
-                ExpressionUtils.evaluateExpressionMap(
-                    toBeSet, workflow, taskContext, taskContext.input())),
-            taskContext.input()));
+        JsonUtils.fromValue(
+            ExpressionUtils.evaluateExpressionMap(
+                toBeSet, workflow, taskContext, taskContext.input())));
   }
 }


Test patch:
diff --git a/impl/core/src/test/java/io/serverlessworkflow/impl/WorkflowDefinitionTest.java b/impl/core/src/test/java/io/serverlessworkflow/impl/WorkflowDefinitionTest.java
index e2a1dbf..c97f11e 100644
--- a/impl/core/src/test/java/io/serverlessworkflow/impl/WorkflowDefinitionTest.java
+++ b/impl/core/src/test/java/io/serverlessworkflow/impl/WorkflowDefinitionTest.java
@@ -16,6 +16,7 @@
 package io.serverlessworkflow.impl;
 
 import static io.serverlessworkflow.api.WorkflowReader.readWorkflowFromClasspath;
+import static io.serverlessworkflow.api.WorkflowReader.validation;
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.Assertions.catchThrowableOfType;
 
@@ -52,7 +53,7 @@ public class WorkflowDefinitionTest {
   @MethodSource("provideParameters")
   void testWorkflowExecution(String fileName, Consumer<WorkflowDefinition> assertions)
       throws IOException {
-    assertions.accept(appl.workflowDefinition(readWorkflowFromClasspath(fileName)));
+    assertions.accept(appl.workflowDefinition(readWorkflowFromClasspath(validation(), fileName)));
   }
 
   private static Stream<Arguments> provideParameters() {
@@ -60,39 +61,19 @@ public class WorkflowDefinitionTest {
         args(
             "switch-then-string.yaml",
             Map.of("orderType", "electronic"),
-            o ->
-                assertThat(o.output())
-                    .isEqualTo(
-                        Map.of(
-                            "orderType", "electronic", "validate", true, "status", "fulfilled"))),
+            o -> assertThat(o.output()).isEqualTo(Map.of("validate", true, "status", "fulfilled"))),
         args(
             "switch-then-string.yaml",
             Map.of("orderType", "physical"),
             o ->
                 assertThat(o.output())
-                    .isEqualTo(
-                        Map.of(
-                            "orderType",
-                            "physical",
-                            "inventory",
-                            "clear",
-                            "items",
-                            1,
-                            "address",
-                            "Elmer St"))),
+                    .isEqualTo(Map.of("inventory", "clear", "items", 1, "address", "Elmer St"))),
         args(
             "switch-then-string.yaml",
             Map.of("orderType", "unknown"),
             o ->
                 assertThat(o.output())
-                    .isEqualTo(
-                        Map.of(
-                            "orderType",
-                            "unknown",
-                            "log",
-                            "warn",
-                            "message",
-                            "something's wrong"))),
+                    .isEqualTo(Map.of("log", "warn", "message", "something's wrong"))),
         args(
             "for-sum.yaml",
             Map.of("input", Arrays.asList(1, 2, 3)),
@@ -100,10 +81,7 @@ public class WorkflowDefinitionTest {
         args(
             "for-collect.yaml",
             Map.of("input", Arrays.asList(1, 2, 3)),
-            o ->
-                assertThat(o.output())
-                    .isEqualTo(
-                        Map.of("input", Arrays.asList(1, 2, 3), "output", Arrays.asList(2, 4, 6)))),
+            o -> assertThat(o.output()).isEqualTo(Map.of("output", Arrays.asList(2, 4, 6)))),
         args(
             "simple-expression.yaml",
             Map.of("input", Arrays.asList(1, 2, 3)),
diff --git a/impl/core/src/test/resources/for-collect.yaml b/impl/core/src/test/resources/for-collect.yaml
index 7bcc48c..53dd823 100644
--- a/impl/core/src/test/resources/for-collect.yaml
+++ b/impl/core/src/test/resources/for-collect.yaml
@@ -13,5 +13,5 @@ do:
         from: '{input: .input, output: []}'
       do:
         - sumIndex:
-            output:
-              as: .output+=[$number+$index+1]
\ No newline at end of file
+            set: 
+              output: ${.output+[$number+$index+1]}
\ No newline at end of file
diff --git a/impl/core/src/test/resources/for-sum.yaml b/impl/core/src/test/resources/for-sum.yaml
index e0fe106..6d89d9f 100644
--- a/impl/core/src/test/resources/for-sum.yaml
+++ b/impl/core/src/test/resources/for-sum.yaml
@@ -4,16 +4,13 @@ document:
   name: for-sum-example
   version: '0.1.0'
 do:
-  - initCounter:
-      set:  
-       counter: 0
   - sumAll:
       for:
         each: number
         in: .input
       do:
         - accumulate:
-            output:
-              as: .counter+=$number
-      output: 
-       as: .counter
\ No newline at end of file
+            set:
+              counter: ${.counter+$number}
+      output:
+        as: .counter
diff --git a/impl/core/src/test/resources/switch-then-string.yaml b/impl/core/src/test/resources/switch-then-string.yaml
index a35ebd4..4093a6f 100644
--- a/impl/core/src/test/resources/switch-then-string.yaml
+++ b/impl/core/src/test/resources/switch-then-string.yaml
@@ -15,31 +15,17 @@ do:
         - default:
             then: handleUnknownOrderType
   - processElectronicOrder:
-      do:
-        - validatePayment:
-            set:
-              validate: true
-        - fulfillOrder:
-            set:
-              status: fulfilled
-      then: exit
+     set:
+        validate: true
+        status: fulfilled
+     then: exit
   - processPhysicalOrder:
-      do:
-        - checkInventory:
-            set:
-              inventory: clear
-        - packItems:
-            set:
-              items: 1
-        - scheduleShipping:
-            set:
-              address: Elmer St
+      set:
+        inventory: clear
+        items: 1
+        address: Elmer St
       then: exit
   - handleUnknownOrderType:
-      do:
-        - logWarning:
-            set:
-              log: warn
-        - notifyAdmin:
-            set:
-              message: something's wrong
+      set:
+        log: warn
+        message: something's wrong