diff options
author | Kanagaraj Manickam <mkr1481@gmail.com> | 2019-08-29 15:41:53 +0530 |
---|---|---|
committer | Kanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com> | 2019-08-29 15:41:53 +0530 |
commit | 70dac125e796d52b874f4e7f3839f9cf042e0f98 (patch) | |
tree | 9382129179acf1a0b0e82c5051a0f287f000c0e1 /main | |
parent | 02b61c5a78448d2c01ce15adecb6df99f1b6b8c8 (diff) |
Minor issues fix
Issue-ID: CLI-166
Change-Id: I97bd303b4e636bfc53e24732c7c6e4062037909b
Signed-off-by: Kanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>
Diffstat (limited to 'main')
-rw-r--r-- | main/src/main/java/org/onap/cli/main/OnapCli.java | 43 |
1 files changed, 32 insertions, 11 deletions
diff --git a/main/src/main/java/org/onap/cli/main/OnapCli.java b/main/src/main/java/org/onap/cli/main/OnapCli.java index 0c7082f8..268b23cf 100644 --- a/main/src/main/java/org/onap/cli/main/OnapCli.java +++ b/main/src/main/java/org/onap/cli/main/OnapCli.java @@ -161,6 +161,10 @@ public class OnapCli { System.out.println(msg); } + protected void printerr(String msg) { + System.err.println(msg); + } + private void print(Throwable throwable) { String error = throwable.getMessage() != null ? throwable.getMessage() : ""; this.print(error); @@ -349,7 +353,7 @@ public class OnapCli { } else { resultAtt.getValues().add(OnapCommandConstants.VERIFY_RESULT_FAIL); } - this.print(testResult.getDebugInfo()); + this.printerr(testResult.getDebugInfo()); this.print("\n***************Expected Output: \n" + expectedOutput); this.print("\n***************Actual Output: \n" + actualOutput); } @@ -509,20 +513,28 @@ public class OnapCli { } //refer params from profile - if (this.profile != null) + if (this.profile != null) { + + Map<String, String> paramCache = new HashMap<>(); + if (this.product == null) + paramCache = OnapCommandRegistrar.getRegistrar().getParamCache(); + else + paramCache = OnapCommandRegistrar.getRegistrar().getParamCache(this.product); + for (OnapCommandParameter param: cmd.getParameters()) { - if (OnapCommandRegistrar.getRegistrar().getParamCache().containsKey( + if (paramCache.containsKey( cmd.getInfo().getService() + ":" + cmd.getName() + ":" + param.getLongOption())) { - param.setValue(OnapCommandRegistrar.getRegistrar().getParamCache().get( + param.setValue(paramCache.get( cmd.getInfo().getService() + ":" + cmd.getName() + ":" + param.getLongOption())); - } else if (OnapCommandRegistrar.getRegistrar().getParamCache().containsKey( + } else if (paramCache.containsKey( cmd.getInfo().getService() + ":" + param.getLongOption())) { - param.setValue(OnapCommandRegistrar.getRegistrar().getParamCache().get( + param.setValue(paramCache.get( cmd.getInfo().getService() + ":" + param.getLongOption())); - } else if (OnapCommandRegistrar.getRegistrar().getParamCache().containsKey(param.getLongOption())) { - param.setValue(OnapCommandRegistrar.getRegistrar().getParamCache().get(param.getLongOption())); + } else if (paramCache.containsKey(param.getLongOption())) { + param.setValue(paramCache.get(param.getLongOption())); } } + } //load the parameters value from the map read from param-file if (!this.argsParamFile.isEmpty()) { @@ -558,8 +570,17 @@ public class OnapCli { this.exitFailure(); } } catch (OnapCommandWarning w) { + if (cmd.getExecutionContext() != null) { + OnapCommandExecutionStore.getStore().storeExectutionEnd( + cmd.getExecutionContext(), + w.getMessage(), + null, + cmd.getResult().getDebugInfo(), + cmd.getResult().isPassed()); + } + this.print(w); - this.print(cmd.getResult().getDebugInfo()); + this.printerr(cmd.getResult().getDebugInfo()); this.exitSuccessfully(); } catch (Exception e) { if (executionStoreContext != null) { @@ -572,7 +593,7 @@ public class OnapCli { } this.print(e); - this.print(cmd.getResult().getDebugInfo()); + this.printerr(cmd.getResult().getDebugInfo()); this.exitFailure(); } } @@ -580,7 +601,7 @@ public class OnapCli { public void handleTracking(OnapCommand cmd) throws OnapCommandException { if (cmd.getResult().isDebug()) - this.print(cmd.getResult().getDebugInfo()); + this.printerr(cmd.getResult().getDebugInfo()); String printOut = cmd.getResult().print(); this.print(printOut); |