diff --git a/cloudslang-runtime/src/main/java/io/cloudslang/lang/runtime/bindings/InputsBinding.java b/cloudslang-runtime/src/main/java/io/cloudslang/lang/runtime/bindings/InputsBinding.java index 2dd9468d6..26ecdcc7c 100644 --- a/cloudslang-runtime/src/main/java/io/cloudslang/lang/runtime/bindings/InputsBinding.java +++ b/cloudslang-runtime/src/main/java/io/cloudslang/lang/runtime/bindings/InputsBinding.java @@ -57,7 +57,8 @@ public Map bindInputs(List inputs, Set systemProperties, List missingInputs, boolean useEmptyValuesForPrompts, - Map prompts) { + Map prompts, + boolean isCslangPromptEnabled) { Map resultContext = new LinkedHashMap<>(); // we do not want to change original context map @@ -70,7 +71,7 @@ public Map bindInputs(List inputs, input = overridePromptSettingIfExists(prompts, input); bindInput(input, srcContext, actualPromptContext, resultContext, - systemProperties, missingInputs, useEmptyValuesForPrompts); + systemProperties, missingInputs, useEmptyValuesForPrompts, isCslangPromptEnabled); } return resultContext; @@ -79,7 +80,7 @@ public Map bindInputs(List inputs, private void bindInput(Input input, Map context, Map promptContext, Map targetContext, Set systemProperties, List missingInputs, - boolean useEmptyValuesForPrompts) { + boolean useEmptyValuesForPrompts, boolean isCslangPromptEnabled) { Value value; String inputName = input.getName(); @@ -104,15 +105,26 @@ private void bindInput(Input input, Map context, } if (input.hasPrompt()) { - if (useEmptyValuesForPrompts) { - if (isNull(value)) { - value = createEmptyValue(input); + if (!isCslangPromptEnabled) { + if (isNull(value) || isEmpty(value)) { + if (useEmptyValuesForPrompts) { + value = createEmptyValue(input); + } else if (isNull(promptValue)) { + resolvePromptExpressions(input, context, targetContext, systemProperties); + missingInputs.add(createMissingInput(input, value)); + return; + } + } + } else { + if (useEmptyValuesForPrompts) { + if (isNull(value)) { + value = createEmptyValue(input); + } + } else if (isNull(promptValue)) { + resolvePromptExpressions(input, context, targetContext, systemProperties); + missingInputs.add(createMissingInput(input, value)); + return; } - } else if (isNull(promptValue)) { - resolvePromptExpressions(input, context, targetContext, systemProperties); - - missingInputs.add(createMissingInput(input, value)); - return; } } else if (input.isRequired() && isEmpty(value)) { missingInputs.add(input); diff --git a/cloudslang-runtime/src/main/java/io/cloudslang/lang/runtime/steps/ExecutableExecutionData.java b/cloudslang-runtime/src/main/java/io/cloudslang/lang/runtime/steps/ExecutableExecutionData.java index a30f15c6e..238441287 100644 --- a/cloudslang-runtime/src/main/java/io/cloudslang/lang/runtime/steps/ExecutableExecutionData.java +++ b/cloudslang-runtime/src/main/java/io/cloudslang/lang/runtime/steps/ExecutableExecutionData.java @@ -185,6 +185,7 @@ public void startExecutable(@Param(ScoreLangConstants.EXECUTABLE_INPUTS_KEY) Lis Map magicVariables = magicVariableHelper.getGlobalContext(executionRuntimeServices); List missingInputs = new ArrayList<>(); ReadOnlyContextAccessor context = new ReadOnlyContextAccessor(callArguments, magicVariables); + boolean isCslangPromptEnabled = executionRuntimeServices.getCslangPromptsEnabledFlag(); Map boundInputValues = inputsBinding.bindInputs( newExecutableInputs, context.getMergedContexts(), @@ -192,7 +193,8 @@ public void startExecutable(@Param(ScoreLangConstants.EXECUTABLE_INPUTS_KEY) Lis runEnv.getSystemProperties(), missingInputs, isTrue(useEmptyValuesForPrompts), - promptArguments); + promptArguments, + isCslangPromptEnabled); boolean continueToNext = true; if (systemContext.containsKey(ScoreLangConstants.USER_INTERRUPT)) { diff --git a/cloudslang-runtime/src/test/java/io/cloudslang/lang/runtime/bindings/InputsBindingTest.java b/cloudslang-runtime/src/test/java/io/cloudslang/lang/runtime/bindings/InputsBindingTest.java index 48d8b56f1..7e2012546 100644 --- a/cloudslang-runtime/src/test/java/io/cloudslang/lang/runtime/bindings/InputsBindingTest.java +++ b/cloudslang-runtime/src/test/java/io/cloudslang/lang/runtime/bindings/InputsBindingTest.java @@ -515,7 +515,7 @@ private Map bindInputs(List inputs, Map con Map promptArgs, Set systemProperties, List missingInputs) { return inputsBinding.bindInputs(inputs, context, promptArgs, systemProperties, missingInputs, - false, new HashMap<>()); + false, new HashMap<>(), true); } private Map bindInputs(List inputs, Map context) { diff --git a/cloudslang-runtime/src/test/java/io/cloudslang/lang/runtime/steps/ExecutableStepsTest.java b/cloudslang-runtime/src/test/java/io/cloudslang/lang/runtime/steps/ExecutableStepsTest.java index 2a2f32b96..1649e9546 100644 --- a/cloudslang-runtime/src/test/java/io/cloudslang/lang/runtime/steps/ExecutableStepsTest.java +++ b/cloudslang-runtime/src/test/java/io/cloudslang/lang/runtime/steps/ExecutableStepsTest.java @@ -138,9 +138,11 @@ public void testStartWithInput() { Map resultMap = new HashMap<>(); resultMap.put("input1", ValueFactory.create(5)); - when(inputsBinding.bindInputs(eq(inputs), anyMap(), anyMap(), anySet(), anyList(), anyBoolean(), anyMap())) + when(inputsBinding + .bindInputs(eq(inputs), anyMap(), anyMap(), anySet(), anyList(), anyBoolean(), anyMap(), anyBoolean())) .thenReturn(resultMap); - executableSteps.startExecutable(inputs, runEnv, new HashMap(), + executableSteps + .startExecutable(inputs, runEnv, new HashMap(), new ExecutionRuntimeServices(), "", 2L, ExecutableType.FLOW, new SystemContext(), false); Map opVars = runEnv.getStack().popContext().getImmutableViewOfVariables(); @@ -168,7 +170,8 @@ public void testBoundInputEvent() { resultMap.put("input1", ValueFactory.create(inputs.get(0).getValue())); resultMap.put("input2", ValueFactory.create(inputs.get(1).getValue())); - when(inputsBinding.bindInputs(eq(inputs), anyMap(), anyMap(), anySet(), anyList(), anyBoolean(), anyMap())) + when(inputsBinding + .bindInputs(eq(inputs), anyMap(), anyMap(), anySet(), anyList(), anyBoolean(), anyMap(), anyBoolean())) .thenReturn(resultMap); executableSteps.startExecutable(inputs, runEnv, new HashMap(), runtimeServices, "dockerizeStep", 2L, ExecutableType.FLOW, new SystemContext(), false);