Skip to content

Commit

Permalink
Changed prompts arg container to LinkedHashMap to preserve order
Browse files Browse the repository at this point in the history
  • Loading branch information
Vitalii Shevchuk committed Aug 27, 2020
1 parent 28f1433 commit b625653
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -78,7 +79,7 @@ public RunEnvironment(Set<SystemProperty> systemProperties) {
serializableDataMap = new HashMap<>();
statefulSessionStack = new StatefulSessionStack();
this.systemProperties = systemProperties;
promptArguments = new HashMap<>();
promptArguments = new LinkedHashMap<>();
promptedValues = new HashMap<>();
}

Expand Down Expand Up @@ -114,7 +115,7 @@ public Map<String, Prompt> getPromptArguments() {

public Map<String, Prompt> removePromptArguments() {
Map<String, Prompt> promptArguments = this.promptArguments;
this.promptArguments = new HashMap<>();
this.promptArguments = new LinkedHashMap<>();
return promptArguments;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
Expand All @@ -50,9 +51,9 @@
import static io.cloudslang.score.api.execution.ExecutionParametersConsts.EXECUTION_RUNTIME_SERVICES;
import static io.cloudslang.score.api.execution.ExecutionParametersConsts.SYSTEM_CONTEXT;
import static java.lang.String.valueOf;
import static java.util.stream.Collectors.toCollection;
import static java.util.stream.Collectors.toList;
import static java.util.stream.Collectors.toMap;
import static java.util.stream.Collectors.toSet;
import static org.apache.commons.lang3.BooleanUtils.isTrue;
import static org.apache.commons.lang3.StringUtils.isEmpty;

Expand Down Expand Up @@ -382,7 +383,7 @@ private ReturnValues buildReturnValues(RunEnvironment runEnvironment, Executable
private List<Input> extractUserDefinedStepInputs(List<Input> inputs,
Map<String, Prompt> prompts,
Map<String, Value> callArguments) {
Set<String> inputNames = inputs.stream().map(Input::getName).collect(toSet());
Set<String> inputNames = inputs.stream().map(Input::getName).collect(toCollection(LinkedHashSet::new));
Set<String> promptInputNames = prompts.keySet();

return Sets
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@

import java.io.Serializable;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
Expand Down Expand Up @@ -407,7 +408,7 @@ private Map<String, Prompt> createPrompts(List<Argument> stepInputs) {
return stepInputs
.stream()
.filter(Argument::hasPrompt)
.collect(toMap(InOutParam::getName, Argument::getPrompt));
.collect(toMap(InOutParam::getName, Argument::getPrompt, (x, y) -> y, LinkedHashMap::new));
}


Expand Down

0 comments on commit b625653

Please sign in to comment.