aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'main/src/test')
-rw-r--r--main/src/test/java/org/onap/cli/main/OnapCliMainTest.java26
-rw-r--r--main/src/test/java/org/onap/cli/main/utils/OnapCliUtilsTest.java19
-rw-r--r--main/src/test/resources/schema-validate-param-file.yaml3
3 files changed, 39 insertions, 9 deletions
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 f7401904..6d7dbdd2 100644
--- a/main/src/test/java/org/onap/cli/main/OnapCliMainTest.java
+++ b/main/src/test/java/org/onap/cli/main/OnapCliMainTest.java
@@ -16,19 +16,22 @@
package org.onap.cli.main;
-import static org.junit.Assert.fail;
-
-import java.io.IOException;
-
+import jline.console.ConsoleReader;
+import mockit.Invocation;
+import mockit.Mock;
+import mockit.MockUp;
import org.junit.Test;
+import org.onap.cli.fw.cmd.OnapCommand;
import org.onap.cli.fw.error.OnapCommandException;
import org.onap.cli.fw.error.OnapCommandHelpFailed;
import org.onap.cli.fw.registrar.OnapCommandRegistrar;
+import org.onap.cli.fw.schema.OnapCommandSchemaLoader;
-import jline.console.ConsoleReader;
-import mockit.Invocation;
-import mockit.Mock;
-import mockit.MockUp;
+import java.io.IOException;
+import java.util.List;
+
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
public class OnapCliMainTest {
@@ -152,6 +155,13 @@ public class OnapCliMainTest {
}
cli = new OnapCli(new String[] {});
+ mockConsole("profile");
+ try {
+ cli.handleInteractive();
+ } catch (Exception e) {
+ }
+
+ cli = new OnapCli(new String[] {});
mockConsole("version");
try {
cli.handleInteractive();
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<OnapCommandParameter> 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<String>) arrParam.getValue())
+ .containsAll(Arrays.asList("test1", "test2")));
+ }
} \ No newline at end of file
diff --git a/main/src/test/resources/schema-validate-param-file.yaml b/main/src/test/resources/schema-validate-param-file.yaml
new file mode 100644
index 00000000..0da20116
--- /dev/null
+++ b/main/src/test/resources/schema-validate-param-file.yaml
@@ -0,0 +1,3 @@
+one:
+ - internal-schema: true
+ - schema-location: catalog.yaml \ No newline at end of file