From 827b80dae1c543fbcd884b5d24563f35c5c668e9 Mon Sep 17 00:00:00 2001 From: fjtirado Date: Thu, 9 Oct 2025 13:13:20 +0200 Subject: [PATCH] [Fix #867] Adding MapSetTaskConfiguration to pass a Map directly to Set Signed-off-by: fjtirado --- .../serverless/workflow/impl/ModelTest.java | 6 ++-- .../types/func/MapSetTaskConfiguration.java | 32 +++++++++++++++++++ 2 files changed, 35 insertions(+), 3 deletions(-) create mode 100644 experimental/types/src/main/java/io/serverlessworkflow/api/types/func/MapSetTaskConfiguration.java diff --git a/experimental/lambda/src/test/java/io/serverless/workflow/impl/ModelTest.java b/experimental/lambda/src/test/java/io/serverless/workflow/impl/ModelTest.java index 1c521d88..2a7c26f5 100644 --- a/experimental/lambda/src/test/java/io/serverless/workflow/impl/ModelTest.java +++ b/experimental/lambda/src/test/java/io/serverless/workflow/impl/ModelTest.java @@ -22,12 +22,12 @@ import io.serverlessworkflow.api.types.Output; import io.serverlessworkflow.api.types.Set; import io.serverlessworkflow.api.types.SetTask; -import io.serverlessworkflow.api.types.SetTaskConfiguration; import io.serverlessworkflow.api.types.Task; import io.serverlessworkflow.api.types.TaskItem; import io.serverlessworkflow.api.types.TimeoutAfter; import io.serverlessworkflow.api.types.WaitTask; import io.serverlessworkflow.api.types.Workflow; +import io.serverlessworkflow.api.types.func.MapSetTaskConfiguration; import io.serverlessworkflow.api.types.func.OutputAsFunction; import io.serverlessworkflow.impl.WorkflowApplication; import io.serverlessworkflow.impl.WorkflowInstance; @@ -89,8 +89,8 @@ void testMapExpression() throws InterruptedException, ExecutionException { .withSet( new Set() .withSetTaskConfiguration( - new SetTaskConfiguration() - .withAdditionalProperty("name", "Francisco"))) + new MapSetTaskConfiguration( + Map.of("name", "Francisco")))) .withOutput( new Output() .withAs( diff --git a/experimental/types/src/main/java/io/serverlessworkflow/api/types/func/MapSetTaskConfiguration.java b/experimental/types/src/main/java/io/serverlessworkflow/api/types/func/MapSetTaskConfiguration.java new file mode 100644 index 00000000..a68fb780 --- /dev/null +++ b/experimental/types/src/main/java/io/serverlessworkflow/api/types/func/MapSetTaskConfiguration.java @@ -0,0 +1,32 @@ +/* + * Copyright 2020-Present The Serverless Workflow Specification Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package io.serverlessworkflow.api.types.func; + +import io.serverlessworkflow.api.types.SetTaskConfiguration; +import java.util.Map; + +public class MapSetTaskConfiguration extends SetTaskConfiguration { + + private static final long serialVersionUID = 1L; + + public MapSetTaskConfiguration(Map map) { + map.forEach(this::processItem); + } + + private void processItem(String key, Object value) { + withAdditionalProperty(key, value); + } +}