From 225400a393da49322bdf500a61ae423ec00efead Mon Sep 17 00:00:00 2001 From: subhash kumar singh Date: Fri, 23 Feb 2018 06:05:28 +0000 Subject: Make default value type object Enhance default value type from String to Object so that it will directly support different type (BOOL, Array, Map). Issue-ID: CLI-74 Change-Id: Iaca438e58150c80047340acba92917ecae685242 Signed-off-by: subhash kumar singh --- .../org/onap/cli/main/utils/OnapCliUtilsTest.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'main/src/test') 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 eb2ca294..c3627ca2 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 @@ -21,6 +21,8 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; import java.util.List; +import java.util.Map; +import java.util.Optional; import java.util.Set; import org.junit.Assert; @@ -255,7 +257,7 @@ public class OnapCliUtilsTest { OnapCliArgsParser.populateParams(paramslist, Arrays.asList("show", "--map", "param1=value1", "--map", "param2=value2")); - Assert.assertEquals("{\"param1\":\"value1\",\"param2\":\"value2\"}", paramslist.iterator().next().getValue().toString()); + Assert.assertEquals("{param1=value1, param2=value2}", paramslist.iterator().next().getValue().toString()); } @Test(expected = OnapCliInvalidArgument.class) @@ -360,4 +362,19 @@ public class OnapCliUtilsTest { Assert.assertEquals("--json-param", paramslist.iterator().next().getValue()); } + + @Test + public void testArrayCommandArg() throws OnapCommandException { + OnapCommandParameter arrParam = new OnapCommandParameter(); + arrParam.setShortOption("q"); + arrParam.setParameterType(OnapCommandParameterType.ARRAY); + arrParam.setName("array-param"); + Set paramslist = new HashSet<>(); + paramslist.add(arrParam); + String[] args = new String[] { "sample-create", "-q", "test1", "-q", "test2" }; + + OnapCliArgsParser.populateParams(paramslist, Arrays.asList(args)); + Assert.assertTrue(((List) arrParam.getValue()) + .containsAll(Arrays.asList("test1", "test2"))); + } } \ No newline at end of file -- cgit 1.2.3-korg