From 92075994f7a2a399f2dced6fb207ebb4e717d8f0 Mon Sep 17 00:00:00 2001 From: Kanagaraj Manickam k00365106 Date: Mon, 25 Sep 2017 21:05:58 +0530 Subject: Make input parameter available in output value Issue-Id: CLI-66 Change-Id: Ib7dc22352932294b485b1239dbb56e4092ef6644 Signed-off-by: Kanagaraj Manickam k00365106 --- .../java/org/onap/cli/fw/cmd/OnapHttpCommand.java | 1 + .../org/onap/cli/fw/utils/OnapCommandUtils.java | 37 ++++++++++++++++++++++ 2 files changed, 38 insertions(+) (limited to 'framework/src') 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> 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 @@ -1584,6 +1584,43 @@ public class OnapCommandUtils { return resultsProcessed; } + /** + * Populate result from input parameters. + * + * @param resultMap + * map + * @param params + * Map + * @return map + * @throws OnapCommandHttpHeaderNotFound + * header not found exception + * @throws OnapCommandHttpInvalidResponseBody + * invalid response body exception + * @throws OnapCommandResultMapProcessingFailed + * map processing failed exception + */ + public static Map> populateOutputsFromInputParameters( + Map> resultMap, + Map params) + throws OnapCommandException { + Map> resultsProcessed = new HashMap<>(); + + for (Entry> 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. * -- cgit 1.2.3-korg