diff options
author | Kanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com> | 2017-09-25 21:05:58 +0530 |
---|---|---|
committer | Kanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com> | 2017-11-14 14:38:03 +0530 |
commit | 92075994f7a2a399f2dced6fb207ebb4e717d8f0 (patch) | |
tree | 771e213ceeb2342138287879cfed442df9fd1aaf | |
parent | 4b04eaa325a972ec38a7d317a60faff1664c8d39 (diff) |
Make input parameter available in output value
Issue-Id: CLI-66
Change-Id: Ib7dc22352932294b485b1239dbb56e4092ef6644
Signed-off-by: Kanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>
3 files changed, 58 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 diff --git a/plugins/msb/src/test/resources/onap-cli-sample/msb-create-service-sample-1.1.yaml b/plugins/msb/src/test/resources/onap-cli-sample/msb-create-service-sample-1.1.yaml new file mode 100644 index 00000000..d316f388 --- /dev/null +++ b/plugins/msb/src/test/resources/onap-cli-sample/msb-create-service-sample-1.1.yaml @@ -0,0 +1,20 @@ +onap_cli_sample_version: 1.0 + +name: microservice-create +version: onap-1.1 +samples: + sample1: + name: Create a service + input: --service-name test-service --service-version v1 --service-url /api/test/v1 --host-url http://192.168.17.23:80 23.14.15.156 80 + output: | + +----------+------------------------------------+ + |property |value | + +----------+------------------------------------+ + |name |test-service | + +----------+------------------------------------+ + |version |v1 | + +----------+------------------------------------+ + |url |/api/test/v1 | + +----------+------------------------------------+ + |status |1 | + +----------+------------------------------------+
\ No newline at end of file |