diff options
Diffstat (limited to 'framework/src/main/java/org')
-rw-r--r-- | framework/src/main/java/org/onap/cli/fw/cmd/OnapHttpCommand.java | 1 | ||||
-rw-r--r-- | framework/src/main/java/org/onap/cli/fw/utils/OnapCommandUtils.java | 37 |
2 files changed, 38 insertions, 0 deletions
diff --git a/framework/src/main/java/org/onap/cli/fw/cmd/OnapHttpCommand.java b/framework/src/main/java/org/onap/cli/fw/cmd/OnapHttpCommand.java index 90ac961e..9f4840cc 100644 --- a/framework/src/main/java/org/onap/cli/fw/cmd/OnapHttpCommand.java +++ b/framework/src/main/java/org/onap/cli/fw/cmd/OnapHttpCommand.java @@ -95,6 +95,7 @@ public class OnapHttpCommand extends OnapCommand { } Map<String, ArrayList<String>> results = OnapCommandUtils.populateOutputs(this.getResultMap(), output); + results = OnapCommandUtils.populateOutputsFromInputParameters(results, this.getParametersMap()); for (OnapCommandResultAttribute attr : this.getResult().getRecords()) { attr.setValues(results.get(attr.getName())); diff --git a/framework/src/main/java/org/onap/cli/fw/utils/OnapCommandUtils.java b/framework/src/main/java/org/onap/cli/fw/utils/OnapCommandUtils.java index 9c4306c1..131b5209 100644 --- a/framework/src/main/java/org/onap/cli/fw/utils/OnapCommandUtils.java +++ b/framework/src/main/java/org/onap/cli/fw/utils/OnapCommandUtils.java @@ -1585,6 +1585,43 @@ public class OnapCommandUtils { } /** + * Populate result from input parameters. + * + * @param resultMap + * map + * @param params + * Map<String, OnapCommandParameter> + * @return map + * @throws OnapCommandHttpHeaderNotFound + * header not found exception + * @throws OnapCommandHttpInvalidResponseBody + * invalid response body exception + * @throws OnapCommandResultMapProcessingFailed + * map processing failed exception + */ + public static Map<String, ArrayList<String>> populateOutputsFromInputParameters( + Map<String, ArrayList<String>> resultMap, + Map<String, OnapCommandParameter> params) + throws OnapCommandException { + Map<String, ArrayList<String>> resultsProcessed = new HashMap<>(); + + for (Entry<String, ArrayList<String>> entry : resultMap.entrySet()) { + String key = entry.getKey(); + resultsProcessed.put(key, new ArrayList<>()); + for (String value: entry.getValue()) { + try { + value = replaceLineFromInputParameters(value, params); + } catch(OnapCommandResultEmpty e) { + // pass // NOSONAR + } + resultsProcessed.get(key).add(value); + } + } + + return resultsProcessed; + } + + /** * Find external schema files. * * @return list ExternalSchema |