From 0d97a835fa2052ded5a31e8921baf641c8e9bb57 Mon Sep 17 00:00:00 2001 From: Kanagaraj Manickam k00365106 Date: Mon, 11 Dec 2017 20:34:44 +0530 Subject: Make Http as separate plugin Issue-ID: CLI-66 Change-Id: I8ad78f417f6dbb00e29effdd3ed8ec1939aee81d Signed-off-by: Kanagaraj Manickam k00365106 --- .../java/org/onap/cli/main/OnapCliMainTest.java | 49 +------- .../org/onap/cli/main/OnapCommandSampleTest.java | 4 +- .../org/onap/cli/main/utils/OnapCliUtilsTest.java | 140 +++++++++++---------- .../META-INF/services/org.onap.cli.fw.OnapCommand | 1 - .../services/org.onap.cli.fw.cmd.OnapCommand | 1 + .../open-cli-schema/sample-create-schema.yaml | 73 ----------- .../open-cli-schema/sample-test-schema.yaml | 88 +++++++++++++ main/src/test/resources/sample-test-schema.yaml | 88 ------------- 8 files changed, 163 insertions(+), 281 deletions(-) delete mode 100644 main/src/test/resources/META-INF/services/org.onap.cli.fw.OnapCommand create mode 100644 main/src/test/resources/META-INF/services/org.onap.cli.fw.cmd.OnapCommand delete mode 100644 main/src/test/resources/open-cli-schema/sample-create-schema.yaml create mode 100644 main/src/test/resources/open-cli-schema/sample-test-schema.yaml delete mode 100644 main/src/test/resources/sample-test-schema.yaml (limited to 'main/src/test') 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 9d3b036c..f7401904 100644 --- a/main/src/test/java/org/onap/cli/main/OnapCliMainTest.java +++ b/main/src/test/java/org/onap/cli/main/OnapCliMainTest.java @@ -18,21 +18,12 @@ package org.onap.cli.main; import static org.junit.Assert.fail; -import java.io.File; import java.io.IOException; -import java.net.URL; -import java.net.URLClassLoader; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import org.junit.Ignore; import org.junit.Test; -import org.onap.cli.fw.OnapCommand; -import org.onap.cli.fw.OnapCommandRegistrar; import org.onap.cli.fw.error.OnapCommandException; import org.onap.cli.fw.error.OnapCommandHelpFailed; -import org.onap.cli.main.utils.OnapCliArgsParser; +import org.onap.cli.fw.registrar.OnapCommandRegistrar; import jline.console.ConsoleReader; import mockit.Invocation; @@ -73,44 +64,6 @@ public class OnapCliMainTest { this.handle(new String[] { "sample-test", "--help" }); } - @Ignore - @Test - public void testHandleProfile() { - this.handle(new String[] { "-c", "test" }); - } - - @Ignore - @Test - public void testAAICustomerList() { - this.handle(new String[] { "customer-list", "-u", "AAI", "-p", "AAI", "-m", "https://192.168.17.12:8443" }); - } - - @Ignore - @Test - public void testAAICloudList() { - this.handle(new String[] { "cloud-list", "-u", "AAI", "-p", "AAI", "-m", "https://192.168.17.12:8443" }); - } - - @Test - public void testHelpSampleCreateCommand() throws OnapCommandException { - ClassLoader cl = ClassLoader.getSystemClassLoader(); - URL[] urls = ((URLClassLoader) cl).getURLs(); - for (URL url : urls) { - if (url.getPath().contains("main/target/test-classes")) { - File file = new File(url.getPath() + "data"); - if (!file.exists()) { - file.mkdirs(); - } - break; - } - } - this.handle(new String[] { "sample-create", "--help" }); - OnapCommand cmd = OnapCommandRegistrar.getRegistrar().get("sample-create"); - List args = new ArrayList<>(Arrays.asList(new String[] { "sample-create", "--service-name", "test-service", "-i", "ip1", "-i", - "ip2", "-o", "port1=value1", "-o", "port2=value2" })); - OnapCliArgsParser.populateParams(cmd.getParameters(), args); - } - @Test public void testHelpSampleCommandShort() { this.handle(new String[] { "sample-test", "-h" }); diff --git a/main/src/test/java/org/onap/cli/main/OnapCommandSampleTest.java b/main/src/test/java/org/onap/cli/main/OnapCommandSampleTest.java index fcaa8236..3ec63ae6 100644 --- a/main/src/test/java/org/onap/cli/main/OnapCommandSampleTest.java +++ b/main/src/test/java/org/onap/cli/main/OnapCommandSampleTest.java @@ -16,9 +16,9 @@ package org.onap.cli.main; -import org.onap.cli.fw.OnapCommand; -import org.onap.cli.fw.OnapCommandSchema; +import org.onap.cli.fw.cmd.OnapCommand; import org.onap.cli.fw.error.OnapCommandException; +import org.onap.cli.fw.schema.OnapCommandSchema; /** * This command helps to test the Command functionalities. 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 ad1a7ccc..eb2ca294 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 @@ -16,19 +16,21 @@ package org.onap.cli.main.utils; +import java.io.File; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + import org.junit.Assert; import org.junit.Test; import org.onap.cli.fw.error.OnapCommandException; import org.onap.cli.fw.input.OnapCommandParameter; -import org.onap.cli.fw.input.ParameterType; +import org.onap.cli.fw.input.OnapCommandParameterType; import org.onap.cli.main.error.OnapCliArgumentValueMissing; import org.onap.cli.main.error.OnapCliInvalidArgument; -import java.io.File; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - public class OnapCliUtilsTest { @Test @@ -36,25 +38,25 @@ public class OnapCliUtilsTest { OnapCommandParameter param1 = new OnapCommandParameter(); param1.setLongOption("host-username"); param1.setName("host-username"); - param1.setParameterType(ParameterType.STRING); + param1.setParameterType(OnapCommandParameterType.STRING); OnapCommandParameter param2 = new OnapCommandParameter(); param2.setLongOption("host-password"); param2.setName("host-password"); - param2.setParameterType(ParameterType.STRING); + param2.setParameterType(OnapCommandParameterType.STRING); OnapCommandParameter param3 = new OnapCommandParameter(); param3.setLongOption("host-url"); param3.setName("host-url"); - param3.setParameterType(ParameterType.STRING); + param3.setParameterType(OnapCommandParameterType.STRING); OnapCommandParameter param4 = new OnapCommandParameter(); param4.setLongOption("string-param"); param4.setName("string-param"); - param4.setParameterType(ParameterType.STRING); + param4.setParameterType(OnapCommandParameterType.STRING); OnapCommandParameter param5 = new OnapCommandParameter(); param5.setLongOption("long-opt"); param5.setName("long-opt"); - param5.setParameterType(ParameterType.STRING); + param5.setParameterType(OnapCommandParameterType.STRING); - List paramslist = new ArrayList<>(); + Set paramslist = new HashSet<>(); paramslist.add(param1); paramslist.add(param2); paramslist.add(param3); @@ -78,13 +80,13 @@ public class OnapCliUtilsTest { public void testpositionalargs() throws OnapCommandException { OnapCommandParameter paramargs = new OnapCommandParameter(); paramargs.setName("http://localhost:8082/file.txt"); - List paramslist = new ArrayList<>(); + Set paramslist = new HashSet<>(); paramslist.add(paramargs); String[] args = new String[] { "positional-args", "http://localhost:8082/file.txt" }; - paramargs.setParameterType(ParameterType.STRING); + paramargs.setParameterType(OnapCommandParameterType.STRING); OnapCliArgsParser.populateParams(paramslist, Arrays.asList(args)); List expectedList = Arrays.asList(args); - Assert.assertEquals("positional-args", expectedList.get(1), paramslist.get(0).getValue()); + Assert.assertEquals("positional-args", expectedList.get(1), paramslist.iterator().next().getValue()); } @Test @@ -92,14 +94,14 @@ public class OnapCliUtilsTest { OnapCommandParameter boolparam = new OnapCommandParameter(); boolparam.setLongOption("bool"); boolparam.setName("bool-param"); - List paramslist = new ArrayList<>(); + Set paramslist = new HashSet<>(); paramslist.add(boolparam); String[] args = new String[] { "sample-create", "--bool" }; - boolparam.setParameterType(ParameterType.BOOL); + boolparam.setParameterType(OnapCommandParameterType.BOOL); OnapCliArgsParser.populateParams(paramslist, Arrays.asList(args)); List expectedList = Arrays.asList(args); - Assert.assertNotNull(expectedList.get(1), paramslist.get(0).getValue()); + Assert.assertNotNull(expectedList.get(1), paramslist.iterator().next().getValue()); } @@ -108,14 +110,14 @@ public class OnapCliUtilsTest { OnapCommandParameter boolparam = new OnapCommandParameter(); boolparam.setShortOption("b"); boolparam.setName("bool-param"); - List paramslist = new ArrayList<>(); + Set paramslist = new HashSet<>(); paramslist.add(boolparam); String[] args = new String[] { "sample-create", "-b", }; - boolparam.setParameterType(ParameterType.BOOL); + boolparam.setParameterType(OnapCommandParameterType.BOOL); OnapCliArgsParser.populateParams(paramslist, Arrays.asList(args)); List expectedList = Arrays.asList(args); - Assert.assertNotNull(expectedList.get(1), paramslist.get(0).getValue()); + Assert.assertNotNull(expectedList.get(1), paramslist.iterator().next().getValue()); } @Test @@ -123,14 +125,14 @@ public class OnapCliUtilsTest { OnapCommandParameter boolparam = new OnapCommandParameter(); boolparam.setLongOption("text-param"); boolparam.setName("text-param"); - List paramslist = new ArrayList<>(); + Set paramslist = new HashSet<>(); paramslist.add(boolparam); String[] args = new String[] { "sample-create", "--text-param" , "text"}; - boolparam.setParameterType(ParameterType.TEXT); + boolparam.setParameterType(OnapCommandParameterType.TEXT); OnapCliArgsParser.populateParams(paramslist, Arrays.asList(args)); List expectedList = Arrays.asList(args); - Assert.assertNotNull(expectedList.get(1), paramslist.get(0).getValue()); + Assert.assertNotNull(expectedList.get(1), paramslist.iterator().next().getValue()); } @@ -139,14 +141,14 @@ public class OnapCliUtilsTest { OnapCommandParameter boolparam = new OnapCommandParameter(); boolparam.setShortOption("e"); boolparam.setName("text-param"); - List paramslist = new ArrayList<>(); + Set paramslist = new HashSet<>(); paramslist.add(boolparam); String[] args = new String[] { "sample-create", "-e" , "text"}; - boolparam.setParameterType(ParameterType.TEXT); + boolparam.setParameterType(OnapCommandParameterType.TEXT); OnapCliArgsParser.populateParams(paramslist, Arrays.asList(args)); List expectedList = Arrays.asList(args); - Assert.assertNotNull(expectedList.get(1), paramslist.get(0).getValue()); + Assert.assertNotNull(expectedList.get(1), paramslist.iterator().next().getValue()); } @Test @@ -154,14 +156,14 @@ public class OnapCliUtilsTest { OnapCommandParameter jsonparam = new OnapCommandParameter(); jsonparam.setShortOption("j"); jsonparam.setName("json-param"); - List paramslist = new ArrayList<>(); + Set paramslist = new HashSet<>(); paramslist.add(jsonparam); File resourcesDirectory = new File("src/test/resources/sampletest.json"); String[] args = new String[] { "sample-create", "-j", "file:" + resourcesDirectory }; - jsonparam.setParameterType(ParameterType.JSON); + jsonparam.setParameterType(OnapCommandParameterType.JSON); OnapCliArgsParser.populateParams(paramslist, Arrays.asList(args)); List expectedList = Arrays.asList(args); - Assert.assertNotNull(expectedList.get(1), paramslist.get(0).getValue()); + Assert.assertNotNull(expectedList.get(1), paramslist.iterator().next().getValue()); } @Test @@ -169,14 +171,14 @@ public class OnapCliUtilsTest { OnapCommandParameter jsonparam = new OnapCommandParameter(); jsonparam.setLongOption("json-param"); jsonparam.setName("json-param"); - List paramslist = new ArrayList<>(); + Set paramslist = new HashSet<>(); paramslist.add(jsonparam); File resourcesDirectory = new File("src/test/resources/sampletest.json"); String[] args = new String[] { "sample-create", "--json-param", "file:" + resourcesDirectory }; - jsonparam.setParameterType(ParameterType.JSON); + jsonparam.setParameterType(OnapCommandParameterType.JSON); OnapCliArgsParser.populateParams(paramslist, Arrays.asList(args)); List expectedList = Arrays.asList(args); - Assert.assertNotNull(expectedList.get(1), paramslist.get(0).getValue()); + Assert.assertNotNull(expectedList.get(1), paramslist.iterator().next().getValue()); } @Test @@ -185,25 +187,25 @@ public class OnapCliUtilsTest { OnapCommandParameter param1 = new OnapCommandParameter(); param1.setShortOption("u"); param1.setName("host-username"); - param1.setParameterType(ParameterType.STRING); + param1.setParameterType(OnapCommandParameterType.STRING); OnapCommandParameter param2 = new OnapCommandParameter(); param2.setShortOption("p"); param2.setName("host-password"); - param2.setParameterType(ParameterType.STRING); + param2.setParameterType(OnapCommandParameterType.STRING); OnapCommandParameter param3 = new OnapCommandParameter(); param3.setShortOption("r"); param3.setName("host-url"); - param3.setParameterType(ParameterType.STRING); + param3.setParameterType(OnapCommandParameterType.STRING); OnapCommandParameter param4 = new OnapCommandParameter(); param4.setShortOption("c"); param4.setName("string-param"); - param4.setParameterType(ParameterType.STRING); + param4.setParameterType(OnapCommandParameterType.STRING); OnapCommandParameter param5 = new OnapCommandParameter(); param5.setShortOption("l"); param5.setName("long-opt"); - param5.setParameterType(ParameterType.STRING); + param5.setParameterType(OnapCommandParameterType.STRING); - List paramslist = new ArrayList<>(); + Set paramslist = new HashSet<>(); paramslist.add(param1); paramslist.add(param2); paramslist.add(param3); @@ -230,14 +232,14 @@ public class OnapCliUtilsTest { arrayval.setName("node-ip"); String[] args = new String[] { "sample-create", "--node-ip", "{}" }; - List paramslist = new ArrayList<>(); + Set paramslist = new HashSet<>(); paramslist.add(arrayval); - arrayval.setParameterType(ParameterType.ARRAY); + arrayval.setParameterType(OnapCommandParameterType.ARRAY); OnapCliArgsParser.populateParams(paramslist, Arrays.asList(args)); List expectedList = Arrays.asList(args); - Assert.assertNotNull(expectedList.get(1), paramslist.get(0).getValue()); + Assert.assertNotNull(expectedList.get(1), paramslist.iterator().next().getValue()); } @Test @@ -245,15 +247,15 @@ public class OnapCliUtilsTest { OnapCommandParameter param1 = new OnapCommandParameter(); param1.setLongOption("map"); param1.setName("MAP"); - param1.setParameterType(ParameterType.MAP); - List paramslist = new ArrayList<>(); + param1.setParameterType(OnapCommandParameterType.MAP); + Set paramslist = new HashSet<>(); paramslist.add(param1); - param1.setParameterType(ParameterType.MAP); + param1.setParameterType(OnapCommandParameterType.MAP); OnapCliArgsParser.populateParams(paramslist, Arrays.asList("show", "--map", "param1=value1", "--map", "param2=value2")); - Assert.assertEquals("{\"param1\":\"value1\",\"param2\":\"value2\"}", paramslist.get(0).getValue().toString()); + Assert.assertEquals("{\"param1\":\"value1\",\"param2\":\"value2\"}", paramslist.iterator().next().getValue().toString()); } @Test(expected = OnapCliInvalidArgument.class) @@ -261,13 +263,13 @@ public class OnapCliUtilsTest { OnapCommandParameter param1 = new OnapCommandParameter(); param1.setLongOption("map"); param1.setName("MAP"); - param1.setParameterType(ParameterType.MAP); - List paramslist = new ArrayList<>(); + param1.setParameterType(OnapCommandParameterType.MAP); + Set paramslist = new HashSet<>(); paramslist.add(param1); - param1.setParameterType(ParameterType.MAP); + param1.setParameterType(OnapCommandParameterType.MAP); OnapCliArgsParser.populateParams(paramslist, Arrays.asList("show", "--map", "param1=value1", "--map", "param2")); - Assert.assertEquals("{\"param1\":\"value1\",\"param2\"}", paramslist.get(0).getValue().toString()); + Assert.assertEquals("{\"param1\":\"value1\",\"param2\"}", paramslist.iterator().next().getValue().toString()); } @Test(expected = OnapCliInvalidArgument.class) @@ -275,26 +277,26 @@ public class OnapCliUtilsTest { OnapCommandParameter param1 = new OnapCommandParameter(); param1.setShortOption("o"); param1.setName("node-port"); - param1.setParameterType(ParameterType.MAP); - List paramslist = new ArrayList<>(); + param1.setParameterType(OnapCommandParameterType.MAP); + Set paramslist = new HashSet<>(); paramslist.add(param1); - param1.setParameterType(ParameterType.MAP); + param1.setParameterType(OnapCommandParameterType.MAP); OnapCliArgsParser.populateParams(paramslist, Arrays.asList("show", "-o", "param1=value1", "-o", "param2")); - Assert.assertEquals("{\"param1\":\"value1\",\"param2\"}", paramslist.get(0).getValue().toString()); + Assert.assertEquals("{\"param1\":\"value1\",\"param2\"}", paramslist.iterator().next().getValue().toString()); } @Test(expected = OnapCliInvalidArgument.class) public void testpositionalargsfails() throws OnapCommandException { OnapCommandParameter paramargs = new OnapCommandParameter(); paramargs.setName("http://localhost:8082/file.txt"); - List paramslist = new ArrayList<>(); + Set paramslist = new HashSet<>(); paramslist.add(paramargs); String[] args = new String[] { "positional-args", "http://localhost:8082/file.txt", "http://localhost:8082/file.txt" }; - paramargs.setParameterType(ParameterType.STRING); + paramargs.setParameterType(OnapCommandParameterType.STRING); OnapCliArgsParser.populateParams(paramslist, Arrays.asList(args)); List expectedList = Arrays.asList(args); - Assert.assertEquals("positional-args", expectedList.get(1), paramslist.get(0).getValue()); + Assert.assertEquals("positional-args", expectedList.get(1), paramslist.iterator().next().getValue()); } @Test(expected = OnapCliInvalidArgument.class) @@ -302,14 +304,14 @@ public class OnapCliUtilsTest { OnapCommandParameter boolparam = new OnapCommandParameter(); boolparam.setShortOption("b"); boolparam.setName("bool-param"); - List paramslist = new ArrayList<>(); + Set paramslist = new HashSet<>(); paramslist.add(boolparam); String[] args = new String[] { "sample-create", "-b", "-b", "-h" }; - boolparam.setParameterType(ParameterType.BOOL); + boolparam.setParameterType(OnapCommandParameterType.BOOL); OnapCliArgsParser.populateParams(paramslist, Arrays.asList(args)); List expectedList = Arrays.asList(args); - Assert.assertEquals("true", paramslist.get(0).getValue()); + Assert.assertEquals("true", paramslist.iterator().next().getValue()); } @Test(expected = OnapCliInvalidArgument.class) @@ -317,14 +319,14 @@ public class OnapCliUtilsTest { OnapCommandParameter boolparam = new OnapCommandParameter(); boolparam.setShortOption("bool"); boolparam.setName("bool-param"); - List paramslist = new ArrayList<>(); + Set paramslist = new HashSet<>(); paramslist.add(boolparam); String[] args = new String[] { "sample-create", "--bool", "--bool", "--help" }; - boolparam.setParameterType(ParameterType.BOOL); + boolparam.setParameterType(OnapCommandParameterType.BOOL); OnapCliArgsParser.populateParams(paramslist, Arrays.asList(args)); List expectedList = Arrays.asList(args); - Assert.assertEquals("true", paramslist.get(0).getValue()); + Assert.assertEquals("true", paramslist.iterator().next().getValue()); } @Test(expected = OnapCliArgumentValueMissing.class) @@ -332,14 +334,14 @@ public class OnapCliUtilsTest { OnapCommandParameter jsonparam = new OnapCommandParameter(); jsonparam.setLongOption("json-param"); jsonparam.setName("json-param"); - List paramslist = new ArrayList<>(); + Set paramslist = new HashSet<>(); paramslist.add(jsonparam); File resourcesDirectory = new File("src/test/resources/sampletest.json"); String[] args = new String[] { "sample-create", "--json-param", "file:" + resourcesDirectory, "--json-param" }; - jsonparam.setParameterType(ParameterType.JSON); + jsonparam.setParameterType(OnapCommandParameterType.JSON); OnapCliArgsParser.populateParams(paramslist, Arrays.asList(args)); List expectedList = Arrays.asList(args); - Assert.assertEquals("--json-param", paramslist.get(0).getValue()); + Assert.assertEquals("--json-param", paramslist.iterator().next().getValue()); } @@ -348,14 +350,14 @@ public class OnapCliUtilsTest { OnapCommandParameter jsonparam = new OnapCommandParameter(); jsonparam.setShortOption("j"); jsonparam.setName("json-param"); - List paramslist = new ArrayList<>(); + Set paramslist = new HashSet<>(); paramslist.add(jsonparam); File resourcesDirectory = new File("src/test/resources/sampletest.json"); String[] args = new String[] { "sample-create", "-j", "file:" + resourcesDirectory, "-j" }; - jsonparam.setParameterType(ParameterType.JSON); + jsonparam.setParameterType(OnapCommandParameterType.JSON); OnapCliArgsParser.populateParams(paramslist, Arrays.asList(args)); List expectedList = Arrays.asList(args); - Assert.assertEquals("--json-param", paramslist.get(0).getValue()); + Assert.assertEquals("--json-param", paramslist.iterator().next().getValue()); } } \ No newline at end of file diff --git a/main/src/test/resources/META-INF/services/org.onap.cli.fw.OnapCommand b/main/src/test/resources/META-INF/services/org.onap.cli.fw.OnapCommand deleted file mode 100644 index 16dd879a..00000000 --- a/main/src/test/resources/META-INF/services/org.onap.cli.fw.OnapCommand +++ /dev/null @@ -1 +0,0 @@ -org.onap.cli.main.OnapCommandSampleTest \ No newline at end of file diff --git a/main/src/test/resources/META-INF/services/org.onap.cli.fw.cmd.OnapCommand b/main/src/test/resources/META-INF/services/org.onap.cli.fw.cmd.OnapCommand new file mode 100644 index 00000000..16dd879a --- /dev/null +++ b/main/src/test/resources/META-INF/services/org.onap.cli.fw.cmd.OnapCommand @@ -0,0 +1 @@ +org.onap.cli.main.OnapCommandSampleTest \ No newline at end of file diff --git a/main/src/test/resources/open-cli-schema/sample-create-schema.yaml b/main/src/test/resources/open-cli-schema/sample-create-schema.yaml deleted file mode 100644 index 05f93cda..00000000 --- a/main/src/test/resources/open-cli-schema/sample-create-schema.yaml +++ /dev/null @@ -1,73 +0,0 @@ -open_cli_schema_version: 1.0 -name: sample-create -description: Sample create into Onap -info: - product: open-cli - service: test - type: cmd - author: Kanagaraj Manickam kanagaraj.manickam@huawei.com - -parameters: - - name: service-name - description: Oclip service name - type: string - short_option: x - long_option: service-name - is_optional: false - - name: node-ip - description: Oclip service running node IP - type: array - short_option: i - long_option: node-ip - - name: node-port - description: Oclip service running node port - type: map - short_option: o - long_option: node-port -results: - direction: portrait - attributes: - - name: name - description: Oclip service name - scope: short - type: string - - name: version - description: Oclip service version - scope: short - type: string - - name: url - description: Oclip service base url - scope: short - type: url - - name: status - description: Oclip service status - scope: short - type: digit - - name: nodes - description: Oclip service running nodes - scope: long - type: string - - name: location - description: Oclip service location - scope: long - type: url -http: - request: - uri: /services - method: POST - body: '{"serviceName":"${service-name}","nodeIp":"${node-ip}","nodePort":"${node-port}"}' - headers: - queries: - success_codes: - - 201 - - 200 - result_map: - name: $b{$.serviceName} - version: $b{$.version} - url: $b{$.url} - status: $b{$.status} - nodes: $b{$.nodes[*].ip}:$b{$.nodes[*].port} - location: $h{Location} - - sample_response: - body: {"serviceName":"test","version":"v1","url":"/api/test/v1","protocol":"REST","visualRange":"1","lb_policy":"hash","nodes":[{"ip":"127.0.0.1","port":"8012","ttl":0,"nodeId":"test_127.0.0.1_8012","expiration":"2017-02-10T05:33:25Z","created_at":"2017-02-10T05:33:25Z","updated_at":"2017-02-10T05:33:25Z"}],"status":"1"} \ No newline at end of file diff --git a/main/src/test/resources/open-cli-schema/sample-test-schema.yaml b/main/src/test/resources/open-cli-schema/sample-test-schema.yaml new file mode 100644 index 00000000..584eec87 --- /dev/null +++ b/main/src/test/resources/open-cli-schema/sample-test-schema.yaml @@ -0,0 +1,88 @@ +open_cli_schema_version: 1.0 +name: sample-test +description: Oclip sample command to test the command features +info: + product: open-cli + service: test + type: cmd + author: Kanagaraj Manickam kanagaraj.manickam@huawei.com + +parameters: + - name: bool-param + type: bool + description: Oclip boolean param, by default its always false. + short_option: b + long_option: bool + is_optional: true + default_value: false + - name: secure-param + type: string + description: Oclip secure param such as password + short_option: x + long_option: secure + is_secured: true + is_optional: true + default_Value: pass123# + - name: string-param + type: string + description: Oclip string param + long_option: string-param + short_option: c + is_optional: true + default_Value: test + - name: yaml-param + type: json + description: Oclip yaml file location param + long_option: yaml-param + short_option: y + is_optional: true + - name: json-param + type: json + description: Oclip json file location param + long_option: json-param + short_option: j + is_optional: true + - name: long-param + type: digit + description: Oclip long param + short_option: l + long_option: long-opt + is_optional: true + default_value: 10 + - name: url-param + type: url + description: Oclip url param + short_option: r + long_option: url + is_optional: true + default_value: http://localhost:8082/file.txt + - name: env-param + type: string + description: Oclip env param. + short_option: z + long_option: env + is_optional: true + default_value: ${ENV_VAR} + default_value: http://localhost:8082/file.txt + - name: positional-args + type: string + description: Oclip positional args, if no short option and no long option given for it + is_optional: true + default_value: http://localhost:8082/file.txt + - name: text-param + type: text + description: Oclip text file location param + long_option: text-param + short_option: e + is_optional: true +results: + direction: portrait + attributes: + - name: output-1 + description: Oclip output attribute marked in short + scope: short + type: string + - name: output-2 + description: Oclip output attribute marked in long + scope: short + type: string \ No newline at end of file diff --git a/main/src/test/resources/sample-test-schema.yaml b/main/src/test/resources/sample-test-schema.yaml deleted file mode 100644 index 584eec87..00000000 --- a/main/src/test/resources/sample-test-schema.yaml +++ /dev/null @@ -1,88 +0,0 @@ -open_cli_schema_version: 1.0 -name: sample-test -description: Oclip sample command to test the command features -info: - product: open-cli - service: test - type: cmd - author: Kanagaraj Manickam kanagaraj.manickam@huawei.com - -parameters: - - name: bool-param - type: bool - description: Oclip boolean param, by default its always false. - short_option: b - long_option: bool - is_optional: true - default_value: false - - name: secure-param - type: string - description: Oclip secure param such as password - short_option: x - long_option: secure - is_secured: true - is_optional: true - default_Value: pass123# - - name: string-param - type: string - description: Oclip string param - long_option: string-param - short_option: c - is_optional: true - default_Value: test - - name: yaml-param - type: json - description: Oclip yaml file location param - long_option: yaml-param - short_option: y - is_optional: true - - name: json-param - type: json - description: Oclip json file location param - long_option: json-param - short_option: j - is_optional: true - - name: long-param - type: digit - description: Oclip long param - short_option: l - long_option: long-opt - is_optional: true - default_value: 10 - - name: url-param - type: url - description: Oclip url param - short_option: r - long_option: url - is_optional: true - default_value: http://localhost:8082/file.txt - - name: env-param - type: string - description: Oclip env param. - short_option: z - long_option: env - is_optional: true - default_value: ${ENV_VAR} - default_value: http://localhost:8082/file.txt - - name: positional-args - type: string - description: Oclip positional args, if no short option and no long option given for it - is_optional: true - default_value: http://localhost:8082/file.txt - - name: text-param - type: text - description: Oclip text file location param - long_option: text-param - short_option: e - is_optional: true -results: - direction: portrait - attributes: - - name: output-1 - description: Oclip output attribute marked in short - scope: short - type: string - - name: output-2 - description: Oclip output attribute marked in long - scope: short - type: string \ No newline at end of file -- cgit 1.2.3-korg