From dfeb8e23c04bc94050f95c95458605fb4c3cb6d5 Mon Sep 17 00:00:00 2001 From: Kanagaraj Manickam k00365106 Date: Mon, 18 Sep 2017 11:38:10 +0530 Subject: Improve the UT of profile CLI-43 Change-Id: If2f1040a93d18d8f4375c459db3e7250f4dba99f Signed-off-by: Kanagaraj Manickam k00365106 --- main/src/main/java/org/onap/cli/main/OnapCli.java | 2 +- .../test/java/org/onap/cli/main/OnapCliMainTest.java | 19 +++++++++++++++++++ main/src/test/resources/sample-test-schema.yaml | 18 +++++++++--------- 3 files changed, 29 insertions(+), 10 deletions(-) (limited to 'main/src') 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 e33e54ac..9255da20 100644 --- a/main/src/main/java/org/onap/cli/main/OnapCli.java +++ b/main/src/main/java/org/onap/cli/main/OnapCli.java @@ -74,7 +74,7 @@ public class OnapCli { throwable.printStackTrace(); // NOSONAR } } catch (OnapCommandException e) { - this.print(e.getCause()); + System.out.println(e); } } diff --git a/main/src/test/java/org/onap/cli/main/OnapCliMainTest.java b/main/src/test/java/org/onap/cli/main/OnapCliMainTest.java index 0a84d268..f052cbd1 100644 --- a/main/src/test/java/org/onap/cli/main/OnapCliMainTest.java +++ b/main/src/test/java/org/onap/cli/main/OnapCliMainTest.java @@ -128,6 +128,25 @@ public class OnapCliMainTest { this.handle(new String[] { "sample-test", "-h" }); } + @Test + public void testVersionSampleCommandShort() { + this.handle(new String[] { "sample-test", "-v" }); + } + + @Test + public void testHandleSampleCommandSet() throws OnapCommandException { + OnapCommandRegistrar.getRegistrar().addParamCache("sample:string-param", "paramValue"); + OnapCommandRegistrar.getRegistrar().addParamCache("onap-username", "paramValue"); + OnapCommandRegistrar.getRegistrar().addParamCache("onap-password", "paramValue"); + OnapCommandRegistrar.getRegistrar().addParamCache("host-url", "paramValue"); + this.handle(new String[] { "sample-test", "--string-param", "test"}); + } + + @Test + public void testHandleSampleCommandFailure() throws OnapCommandException { + this.handle(new String[] { "sample-test", "--string-param"}); + } + @Test public void interactiveTest() { cli = new OnapCli(new String[] {}); diff --git a/main/src/test/resources/sample-test-schema.yaml b/main/src/test/resources/sample-test-schema.yaml index ac601c86..36edc7de 100644 --- a/main/src/test/resources/sample-test-schema.yaml +++ b/main/src/test/resources/sample-test-schema.yaml @@ -19,60 +19,60 @@ parameters: short_option: x long_option: secure is_secured: true - is_optional: false + is_optional: true default_Value: pass123# - name: string-param type: string description: Onap string param long_option: string-param short_option: c - is_optional: false + is_optional: true default_Value: test - name: yaml-param type: json description: Onap yaml file location param long_option: yaml-param short_option: y - is_optional: false + is_optional: true - name: json-param type: json description: Onap json file location param long_option: json-param short_option: j - is_optional: false + is_optional: true - name: long-param type: digit description: Onap long param short_option: l long_option: long-opt - is_optional: false + is_optional: true default_value: 10 - name: url-param type: url description: Onap url param short_option: r long_option: url - is_optional: false + is_optional: true default_value: http://localhost:8082/file.txt - name: env-param type: string description: Onap env param. short_option: z long_option: env - is_optional: false + is_optional: true default_value: ${ENV_VAR} default_value: http://localhost:8082/file.txt - name: positional-args type: string description: Onap positional args, if no short option and no long option given for it - is_optional: false + is_optional: true default_value: http://localhost:8082/file.txt - name: text-param type: text description: Onap text file location param long_option: text-param short_option: e - is_optional: false + is_optional: true results: direction: portrait attributes: -- cgit 1.2.3-korg