summaryrefslogtreecommitdiffstats
path: root/main
diff options
context:
space:
mode:
authorKanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>2017-09-18 10:07:17 +0530
committerKanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>2017-09-18 10:08:04 +0530
commit1a4b4030e10b53ffc80d977908cd6097d843f7a8 (patch)
treeb441fe2781e685264cab85e9dd376741cfd6af4b /main
parent81d56617f980394d45be5fee716c507eeea739f2 (diff)
Add exception for profile persist layer
CLI-43 Change-Id: I6b2b969cc3a56dbee60d2b9056a6a7f8f793a8b4 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.java2
-rw-r--r--main/src/test/java/org/onap/cli/main/utils/OnapCliUtilsTest.java31
-rw-r--r--main/src/test/resources/sample-test-schema.yaml6
3 files changed, 38 insertions, 1 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 57e39f20..e33e54ac 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) {
- // pass // NOSONAR
+ this.print(e.getCause());
}
}
diff --git a/main/src/test/java/org/onap/cli/main/utils/OnapCliUtilsTest.java b/main/src/test/java/org/onap/cli/main/utils/OnapCliUtilsTest.java
index 8870029b..622cea5f 100644
--- a/main/src/test/java/org/onap/cli/main/utils/OnapCliUtilsTest.java
+++ b/main/src/test/java/org/onap/cli/main/utils/OnapCliUtilsTest.java
@@ -119,6 +119,37 @@ public class OnapCliUtilsTest {
}
@Test
+ public void testTextparamslong() throws OnapCommandException {
+ OnapCommandParameter boolparam = new OnapCommandParameter();
+ boolparam.setLongOption("text-param");
+ boolparam.setName("text-param");
+ List<OnapCommandParameter> paramslist = new ArrayList<>();
+ paramslist.add(boolparam);
+ String[] args = new String[] { "sample-create", "--text-param" , "text"};
+
+ boolparam.setParameterType(ParameterType.TEXT);
+ OnapCliUtils.populateParams(paramslist, Arrays.asList(args));
+ List<String> expectedList = Arrays.asList(args);
+ Assert.assertNotNull(expectedList.get(1), paramslist.get(0).getValue());
+
+ }
+
+ @Test
+ public void testTextparamsshort() throws OnapCommandException {
+ OnapCommandParameter boolparam = new OnapCommandParameter();
+ boolparam.setShortOption("e");
+ boolparam.setName("text-param");
+ List<OnapCommandParameter> paramslist = new ArrayList<>();
+ paramslist.add(boolparam);
+ String[] args = new String[] { "sample-create", "-e" , "text"};
+
+ boolparam.setParameterType(ParameterType.TEXT);
+ OnapCliUtils.populateParams(paramslist, Arrays.asList(args));
+ List<String> expectedList = Arrays.asList(args);
+ Assert.assertNotNull(expectedList.get(1), paramslist.get(0).getValue());
+ }
+
+ @Test
public void testjsonparamsshort() throws OnapCommandException {
OnapCommandParameter jsonparam = new OnapCommandParameter();
jsonparam.setShortOption("j");
diff --git a/main/src/test/resources/sample-test-schema.yaml b/main/src/test/resources/sample-test-schema.yaml
index a4fd8563..ac601c86 100644
--- a/main/src/test/resources/sample-test-schema.yaml
+++ b/main/src/test/resources/sample-test-schema.yaml
@@ -67,6 +67,12 @@ parameters:
description: Onap positional args, if no short option and no long option given for it
is_optional: false
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
results:
direction: portrait
attributes: