summaryrefslogtreecommitdiffstats
path: root/framework/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'framework/src/test')
-rw-r--r--framework/src/test/java/org/onap/cli/cmd/sample/OnapCommandSample.java4
-rw-r--r--framework/src/test/java/org/onap/cli/cmd/sample/OnapCommandSampleTest.java69
-rw-r--r--framework/src/test/java/org/onap/cli/fw/ad/OnapAuthClientCommandBasedTest.java134
-rw-r--r--framework/src/test/java/org/onap/cli/fw/ad/OnapServiceTest.java38
-rw-r--r--framework/src/test/java/org/onap/cli/fw/cmd/OnapHttpCommandTest.java81
-rw-r--r--framework/src/test/java/org/onap/cli/fw/cmd/OnapSchemaValidateCommandTest.java3
-rw-r--r--framework/src/test/java/org/onap/cli/fw/conf/OnapCommandConfgTest.java22
-rw-r--r--framework/src/test/java/org/onap/cli/fw/error/OnapCommandErrorTest.java54
-rw-r--r--framework/src/test/java/org/onap/cli/fw/http/HttpInputOutputTest.java67
-rw-r--r--framework/src/test/java/org/onap/cli/fw/http/OnapHttpConnectionTest.java205
-rw-r--r--framework/src/test/java/org/onap/cli/fw/input/OnapCommandParameterTest.java16
-rw-r--r--framework/src/test/java/org/onap/cli/fw/input/ParameterTypeTest.java22
-rw-r--r--framework/src/test/java/org/onap/cli/fw/output/OnapCommandResultAttributeScopeTest.java6
-rw-r--r--framework/src/test/java/org/onap/cli/fw/output/OnapCommandResultTest.java44
-rw-r--r--framework/src/test/java/org/onap/cli/fw/output/PrintDirectionTest.java6
-rw-r--r--framework/src/test/java/org/onap/cli/fw/output/ResultTypeTest.java10
-rw-r--r--framework/src/test/java/org/onap/cli/fw/output/print/OnapCommandPrintTest.java10
-rw-r--r--framework/src/test/java/org/onap/cli/fw/registrar/OnapCommandRegistrarTest.java (renamed from framework/src/test/java/org/onap/cli/fw/OnapCommandRegistrarTest.java)15
-rw-r--r--framework/src/test/java/org/onap/cli/fw/schema/ValidateSchemaTest.java39
-rw-r--r--framework/src/test/java/org/onap/cli/fw/utils/OnapCommandUtilsTest.java214
-rw-r--r--framework/src/test/java/org/onap/cli/fw/utils/OpenCommandRegistrarTest.java41
-rw-r--r--framework/src/test/resources/META-INF/services/org.onap.cli.fw.cmd.OnapCommand (renamed from framework/src/test/resources/META-INF/services/org.onap.cli.fw.OnapCommand)0
-rw-r--r--framework/src/test/resources/open-cli-schema/sample-test1-schema-http.yaml95
-rw-r--r--framework/src/test/resources/open-cli-schema/testauth-login.yaml28
-rw-r--r--framework/src/test/resources/open-cli-schema/testauth-logout.yaml19
-rw-r--r--framework/src/test/resources/open-cli.properties39
-rw-r--r--framework/src/test/resources/sample-test-schema-auth-required.yaml16
-rw-r--r--framework/src/test/resources/sample-test-schema-http.yaml92
-rw-r--r--framework/src/test/resources/sample-test-schema-no-auth-no-catalog.yaml26
-rw-r--r--framework/src/test/resources/sample-test-schema-no-auth-yes-catalog.yaml28
-rw-r--r--framework/src/test/resources/sample-test-schema-swagger.yaml28
-rw-r--r--framework/src/test/resources/sample-test-schema-yes-auth-no-catalog.yaml26
-rw-r--r--framework/src/test/resources/sample-test-schema-yes-auth-with-additional-params-no-catalog.yaml28
-rw-r--r--framework/src/test/resources/sample-test-schema-yes-auth-yes-catalog.yaml28
-rw-r--r--framework/src/test/resources/schema-validate-http.yaml98
35 files changed, 129 insertions, 1522 deletions
diff --git a/framework/src/test/java/org/onap/cli/cmd/sample/OnapCommandSample.java b/framework/src/test/java/org/onap/cli/cmd/sample/OnapCommandSample.java
index c76df290..b225a3a0 100644
--- a/framework/src/test/java/org/onap/cli/cmd/sample/OnapCommandSample.java
+++ b/framework/src/test/java/org/onap/cli/cmd/sample/OnapCommandSample.java
@@ -16,10 +16,10 @@
package org.onap.cli.cmd.sample;
-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.error.OnapCommandExecutionFailed;
+import org.onap.cli.fw.schema.OnapCommandSchema;
/**
* This command helps to test the Command functionalities.
diff --git a/framework/src/test/java/org/onap/cli/cmd/sample/OnapCommandSampleTest.java b/framework/src/test/java/org/onap/cli/cmd/sample/OnapCommandSampleTest.java
index 51ed776f..a83cda52 100644
--- a/framework/src/test/java/org/onap/cli/cmd/sample/OnapCommandSampleTest.java
+++ b/framework/src/test/java/org/onap/cli/cmd/sample/OnapCommandSampleTest.java
@@ -19,20 +19,20 @@ package org.onap.cli.cmd.sample;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
-import java.util.ArrayList;
-import java.util.List;
+import java.util.HashSet;
+import java.util.Set;
import java.util.UUID;
import org.junit.Test;
-import org.onap.cli.fw.OnapCommand;
-import org.onap.cli.fw.OnapCommandRegistrar;
-import org.onap.cli.fw.conf.Constants;
+import org.onap.cli.fw.cmd.OnapCommand;
+import org.onap.cli.fw.conf.OnapCommandConstants;
import org.onap.cli.fw.error.OnapCommandException;
import org.onap.cli.fw.error.OnapCommandExecutionFailed;
import org.onap.cli.fw.error.OnapCommandNotInitialized;
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.fw.output.OnapCommandResultAttribute;
+import org.onap.cli.fw.registrar.OnapCommandRegistrar;
public class OnapCommandSampleTest {
@Test
@@ -42,13 +42,13 @@ public class OnapCommandSampleTest {
OnapCommand sample = OnapCommandRegistrar.getRegistrar().get("sample-test");
- List<OnapCommandParameter> parameters = new ArrayList();
+ Set<OnapCommandParameter> parameters = new HashSet();
OnapCommandParameter v = new OnapCommandParameter();
- v.setName(Constants.DEFAULT_PARAMETER_VERSION);
+ v.setName(OnapCommandConstants.DEFAULT_PARAMETER_VERSION);
v.setValue("true");
parameters.add(v);
OnapCommandParameter h = new OnapCommandParameter();
- h.setName(Constants.DEFAULT_PARAMETER_HELP);
+ h.setName(OnapCommandConstants.DEFAULT_PARAMETER_HELP);
h.setValue("false");
parameters.add(h);
sample.setParameters(parameters);
@@ -61,11 +61,11 @@ public class OnapCommandSampleTest {
public void sampleTestHelp() {
OnapCommandSample sample = new OnapCommandSample();
try {
- List<OnapCommandParameter> parameters = new ArrayList();
+ Set<OnapCommandParameter> parameters = new HashSet();
OnapCommandParameter v = new OnapCommandParameter();
- v.setName(Constants.DEFAULT_PARAMETER_HELP);
+ v.setName(OnapCommandConstants.DEFAULT_PARAMETER_HELP);
v.setValue("true");
- v.setParameterType(ParameterType.BOOL);
+ v.setParameterType(OnapCommandParameterType.BOOL);
parameters.add(v);
sample.setParameters(parameters);
sample.execute();
@@ -78,39 +78,32 @@ public class OnapCommandSampleTest {
try {
OnapCommand sample = OnapCommandRegistrar.getRegistrar().get("sample-test");
- List<OnapCommandParameter> parameters = new ArrayList();
+ Set<OnapCommandParameter> parameters = new HashSet();
OnapCommandParameter v = new OnapCommandParameter();
- v.setName(Constants.DEFAULT_PARAMETER_VERSION);
+ v.setName(OnapCommandConstants.DEFAULT_PARAMETER_VERSION);
v.setValue("false");
parameters.add(v);
OnapCommandParameter h = new OnapCommandParameter();
- h.setName(Constants.DEFAULT_PARAMETER_HELP);
+ h.setName(OnapCommandConstants.DEFAULT_PARAMETER_HELP);
h.setValue("false");
parameters.add(h);
OnapCommandParameter f = new OnapCommandParameter();
- f.setName(Constants.DEFAULT_PARAMETER_OUTPUT_FORMAT);
+ f.setName(OnapCommandConstants.DEFAULT_PARAMETER_OUTPUT_FORMAT);
f.setValue("table");
parameters.add(f);
OnapCommandParameter l = new OnapCommandParameter();
- l.setName(Constants.DEFAULT_PARAMETER_OUTPUT_ATTR_LONG);
+ l.setName(OnapCommandConstants.DEFAULT_PARAMETER_OUTPUT_ATTR_LONG);
l.setValue("true");
parameters.add(l);
OnapCommandParameter t = new OnapCommandParameter();
- t.setName(Constants.DEFAULT_PARAMETER_OUTPUT_NO_TITLE);
+ t.setName(OnapCommandConstants.DEFAULT_PARAMETER_OUTPUT_NO_TITLE);
t.setValue("true");
parameters.add(t);
- OnapCommandParameter a = new OnapCommandParameter();
- a.setName(Constants.DEFAULT_PARAMETER_NO_AUTH);
- a.setValue("true");
- parameters.add(a);
OnapCommandParameter d = new OnapCommandParameter();
- d.setName(Constants.DEFAULT_PARAMETER_DEBUG);
+ d.setName(OnapCommandConstants.DEFAULT_PARAMETER_DEBUG);
d.setValue("true");
parameters.add(d);
- OnapCommandParameter m = new OnapCommandParameter();
- m.setName(Constants.DEAFULT_PARAMETER_HOST_URL);
- m.setValue("http://localhost");
- parameters.add(m);
+
sample.setParameters(parameters);
sample.execute();
@@ -132,39 +125,31 @@ public class OnapCommandSampleTest {
OnapCommandSample sample = new OnapCommandSample();
sample.failCase = true;
- List<OnapCommandParameter> parameters = new ArrayList();
+ Set<OnapCommandParameter> parameters = new HashSet();
OnapCommandParameter v = new OnapCommandParameter();
- v.setName(Constants.DEFAULT_PARAMETER_VERSION);
+ v.setName(OnapCommandConstants.DEFAULT_PARAMETER_VERSION);
v.setValue("false");
parameters.add(v);
OnapCommandParameter h = new OnapCommandParameter();
- h.setName(Constants.DEFAULT_PARAMETER_HELP);
+ h.setName(OnapCommandConstants.DEFAULT_PARAMETER_HELP);
h.setValue("false");
parameters.add(h);
OnapCommandParameter f = new OnapCommandParameter();
- f.setName(Constants.DEFAULT_PARAMETER_OUTPUT_FORMAT);
+ f.setName(OnapCommandConstants.DEFAULT_PARAMETER_OUTPUT_FORMAT);
f.setValue("table");
parameters.add(f);
OnapCommandParameter l = new OnapCommandParameter();
- l.setName(Constants.DEFAULT_PARAMETER_OUTPUT_ATTR_LONG);
+ l.setName(OnapCommandConstants.DEFAULT_PARAMETER_OUTPUT_ATTR_LONG);
l.setValue("true");
parameters.add(l);
OnapCommandParameter t = new OnapCommandParameter();
- t.setName(Constants.DEFAULT_PARAMETER_OUTPUT_NO_TITLE);
+ t.setName(OnapCommandConstants.DEFAULT_PARAMETER_OUTPUT_NO_TITLE);
t.setValue("true");
parameters.add(t);
- OnapCommandParameter a = new OnapCommandParameter();
- a.setName(Constants.DEFAULT_PARAMETER_NO_AUTH);
- a.setValue("true");
- parameters.add(a);
OnapCommandParameter d = new OnapCommandParameter();
- d.setName(Constants.DEFAULT_PARAMETER_DEBUG);
+ d.setName(OnapCommandConstants.DEFAULT_PARAMETER_DEBUG);
d.setValue("true");
parameters.add(d);
- OnapCommandParameter m = new OnapCommandParameter();
- m.setName(Constants.DEAFULT_PARAMETER_HOST_URL);
- m.setValue("http://localhost");
- parameters.add(m);
sample.setParameters(parameters);
sample.execute();
}
diff --git a/framework/src/test/java/org/onap/cli/fw/ad/OnapAuthClientCommandBasedTest.java b/framework/src/test/java/org/onap/cli/fw/ad/OnapAuthClientCommandBasedTest.java
deleted file mode 100644
index 58b44f4a..00000000
--- a/framework/src/test/java/org/onap/cli/fw/ad/OnapAuthClientCommandBasedTest.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * Copyright 2017 Huawei Technologies Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onap.cli.fw.ad;
-
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.onap.cli.fw.OnapCommand;
-import org.onap.cli.fw.OnapCommandRegistrar;
-import org.onap.cli.fw.cmd.OnapHttpCommand;
-import org.onap.cli.fw.conf.Constants;
-import org.onap.cli.fw.conf.OnapCommandConfg;
-import org.onap.cli.fw.error.OnapCommandException;
-import org.onap.cli.fw.error.OnapCommandProductVersionInvalid;
-
-public class OnapAuthClientCommandBasedTest {
-
- @Before
- public void setup() throws OnapCommandProductVersionInvalid, OnapCommandException {
- OnapCommandRegistrar.getRegistrar().setEnabledProductVersion(OnapCommandConfg.getProductName());
- }
-
- @Test
- public void internalCommandTest() {
- try {
- OnapCommand cmd = OnapCommandRegistrar.getRegistrar().get("sample-test");
- cmd.getInfo().setService(OnapCommandConfg.getProductName());
-
- cmd.execute();
- } catch (OnapCommandException e) {
- fail("Internal command failed to run");
- e.printStackTrace(System.out);
- }
- }
-
- @Test
- public void yesCatalogYesAuthTest() throws OnapCommandException {
- try {
- OnapHttpCommand cmd = getCommand("sample-test-schema-yes-auth-yes-catalog.yaml");
- cmd.getParametersMap().get(Constants.DEAFULT_PARAMETER_HOST_URL).setValue("http://localhost:8080");
- cmd.getParametersMap().get(Constants.DEAFULT_PARAMETER_USERNAME).setValue("test");
- cmd.getParametersMap().get(Constants.DEAFULT_PARAMETER_PASSWORD).setValue("password");
-
- cmd.execute();
- } catch (OnapCommandException e) {
- fail("External command Yes Auth Yes Catalog failed to run");
- e.printStackTrace(System.out);
- }
- }
-
- @Test
- public void yesCatalogNoAuthTest() throws OnapCommandException {
- try {
- OnapHttpCommand cmd = getCommand("sample-test-schema-no-auth-yes-catalog.yaml");
- cmd.getParametersMap().get(Constants.DEAFULT_PARAMETER_HOST_URL).setValue("http://localhost:8080");
-
- cmd.execute();
- } catch (OnapCommandException e) {
- fail("External command Yes Auth No Catalog failed to run " + e.getMessage());
- e.printStackTrace(System.out);
- }
- }
-
- @Test
- public void noCatalogYesAuthTest() throws OnapCommandException {
- try {
- OnapHttpCommand cmd = getCommand("sample-test-schema-yes-auth-no-catalog.yaml");
- cmd.getParametersMap().get(Constants.DEAFULT_PARAMETER_HOST_URL).setValue("http://localhost:8080");
- cmd.getParametersMap().get(Constants.DEAFULT_PARAMETER_USERNAME).setValue("test");
- cmd.getParametersMap().get(Constants.DEAFULT_PARAMETER_PASSWORD).setValue("password");
-
- cmd.execute();
- } catch (OnapCommandException e) {
- fail("External command Yes Auth No Catalog failed to run");
- e.printStackTrace(System.out);
- }
- }
-
- @Test
- public void noCatalogYesAuthWithAdditionalParamsTest() throws OnapCommandException {
- try {
- OnapHttpCommand cmd = getCommand("sample-test-schema-yes-auth-with-additional-params-no-catalog.yaml");
- assertTrue(cmd.getParametersMap().containsKey("string-param"));
- } catch (OnapCommandException e) {
- fail("External command Yes Auth No Catalog failed to run");
- e.printStackTrace(System.out);
- }
- }
-
- @Test
- public void noCatalogNoAuthTest() throws OnapCommandException {
- try {
- OnapHttpCommand cmd = getCommand("sample-test-schema-no-auth-no-catalog.yaml");
- cmd.getParametersMap().get(Constants.DEAFULT_PARAMETER_HOST_URL).setValue("http://localhost:8080");
-
- cmd.execute();
- } catch (OnapCommandException e) {
- fail("External command No Auth No Catalog failed to run");
- e.printStackTrace(System.out);
- }
- }
-
- private OnapHttpCommand getCommand(String yaml) throws OnapCommandException {
- OnapHttpCommand cmd = new OnapHttpCommand() {
- @Override
- protected void processRequest() throws OnapCommandException {
- if (!this.getService().isModeDirect()) {
- String url = this.authClient.getServiceUrl();
- assert url.equals(this.getParametersMap().get(Constants.DEAFULT_PARAMETER_HOST_URL).getValue() + "/");
- }
- }
- };
-
- cmd.initializeSchema(yaml);
-
- return cmd;
- }
- }
diff --git a/framework/src/test/java/org/onap/cli/fw/ad/OnapServiceTest.java b/framework/src/test/java/org/onap/cli/fw/ad/OnapServiceTest.java
deleted file mode 100644
index 9ceba67d..00000000
--- a/framework/src/test/java/org/onap/cli/fw/ad/OnapServiceTest.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright 2017 Huawei Technologies Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onap.cli.fw.ad;
-
-import static org.junit.Assert.assertTrue;
-
-import org.junit.Test;
-import org.onap.cli.fw.conf.Constants;
-
-public class OnapServiceTest {
-
- @Test
- public void serviceTest() {
- OnapService ser = new OnapService();
- ser.setName("name");
- ser.setVersion("1.0");
- ser.setBasePath("basePath");
- ser.setAuthType(Constants.AUTH_NONE);
- assertTrue(ser.getName().equals("name") && ser.getVersion().equals("1.0")
- && ser.getBasePath().equals("basePath") && ser.isNoAuth());
-
- }
-
-}
diff --git a/framework/src/test/java/org/onap/cli/fw/cmd/OnapHttpCommandTest.java b/framework/src/test/java/org/onap/cli/fw/cmd/OnapHttpCommandTest.java
deleted file mode 100644
index 3fced8ab..00000000
--- a/framework/src/test/java/org/onap/cli/fw/cmd/OnapHttpCommandTest.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright 2017 Huawei Technologies Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onap.cli.fw.cmd;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-
-import org.junit.Ignore;
-import org.junit.Test;
-import org.onap.cli.fw.error.OnapCommandException;
-import org.onap.cli.fw.http.HttpInput;
-import org.onap.cli.fw.input.OnapCommandParameter;
-import org.onap.cli.fw.input.ParameterType;
-
-public class OnapHttpCommandTest {
-
- @Ignore
- @Test(expected = OnapCommandException.class)
- public void runTest() throws OnapCommandException {
- OnapCommandParameter param1 = new OnapCommandParameter();
- param1.setLongOption("host-username");
- param1.setName("host-username");
- param1.setParameterType(ParameterType.STRING);
- OnapCommandParameter param2 = new OnapCommandParameter();
- param2.setLongOption("host-password");
- param2.setName("host-password");
- param2.setParameterType(ParameterType.STRING);
- OnapCommandParameter param3 = new OnapCommandParameter();
- param3.setLongOption("host-url");
- param3.setName("host-url");
- param3.setParameterType(ParameterType.STRING);
- OnapCommandParameter param4 = new OnapCommandParameter();
- param4.setLongOption("string-param");
- param4.setName("string-param");
- param4.setParameterType(ParameterType.STRING);
- OnapCommandParameter param5 = new OnapCommandParameter();
- param5.setLongOption("long-opt");
- param5.setName("long-opt");
- param5.setParameterType(ParameterType.STRING);
-
- List<OnapCommandParameter> paramslist = new ArrayList<>();
- paramslist.add(param1);
- paramslist.add(param2);
- paramslist.add(param3);
- paramslist.add(param4);
- paramslist.add(param5);
-
- HttpInput inp = new HttpInput();
- inp.setBody("body");
- inp.setMethod("method");
- inp.setReqCookies(new HashMap<String, String>());
- inp.setReqHeaders(new HashMap<String, String>());
- inp.setReqQueries(new HashMap<String, String>());
- inp.setUri("uri");
-
- OnapHttpCommand com = new OnapHttpCommand();
- com.setParameters(paramslist);
- com.getParameters();
- com.getParametersMap();
- com.setInput(inp);
- com.initializeSchema("sample-test-schema.yaml");
- com.execute();
-
- }
-
-}
diff --git a/framework/src/test/java/org/onap/cli/fw/cmd/OnapSchemaValidateCommandTest.java b/framework/src/test/java/org/onap/cli/fw/cmd/OnapSchemaValidateCommandTest.java
index 8d8de2f7..f094203b 100644
--- a/framework/src/test/java/org/onap/cli/fw/cmd/OnapSchemaValidateCommandTest.java
+++ b/framework/src/test/java/org/onap/cli/fw/cmd/OnapSchemaValidateCommandTest.java
@@ -18,9 +18,8 @@ package org.onap.cli.fw.cmd;
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.registrar.OnapCommandRegistrar;
import org.onap.cli.fw.schema.ValidateSchemaTest;
diff --git a/framework/src/test/java/org/onap/cli/fw/conf/OnapCommandConfgTest.java b/framework/src/test/java/org/onap/cli/fw/conf/OnapCommandConfgTest.java
index 2c25991b..d6ef3a34 100644
--- a/framework/src/test/java/org/onap/cli/fw/conf/OnapCommandConfgTest.java
+++ b/framework/src/test/java/org/onap/cli/fw/conf/OnapCommandConfgTest.java
@@ -16,28 +16,6 @@
package org.onap.cli.fw.conf;
-import java.io.IOException;
-import java.util.Properties;
-
-import org.junit.Assert;
-import org.junit.Test;
-
public class OnapCommandConfgTest {
- @Test
- public void versionTest() {
- String str = OnapCommandConfg.getVersion();
- Assert.assertTrue(str != null);
- }
-
- @Test
- public void isAuthIgnoredTest() throws IOException {
- Properties prps = new Properties();
- prps.load(OnapCommandConfg.class.getClassLoader().getResourceAsStream("open-cli.properties"));
- boolean auth = OnapCommandConfg.isAuthIgnored();
- Assert.assertTrue(auth == Boolean.valueOf(prps.getProperty("cli.ignore_auth")));
- Assert.assertTrue(OnapCommandConfg.isCookiesBasedAuth() == Boolean
- .valueOf(prps.getProperty("cli.http.api_key_use_cookies")));
- }
-
}
diff --git a/framework/src/test/java/org/onap/cli/fw/error/OnapCommandErrorTest.java b/framework/src/test/java/org/onap/cli/fw/error/OnapCommandErrorTest.java
index 899f2e3b..58c0f432 100644
--- a/framework/src/test/java/org/onap/cli/fw/error/OnapCommandErrorTest.java
+++ b/framework/src/test/java/org/onap/cli/fw/error/OnapCommandErrorTest.java
@@ -45,12 +45,6 @@ public class OnapCommandErrorTest {
}
@Test
- public void oclipCommandHttpHeaderNotFoundTest() {
- OnapCommandHttpHeaderNotFound failed = new OnapCommandHttpHeaderNotFound("name");
- assertEquals("0x3003::Http header name is not returned from the service", failed.getMessage());
- }
-
- @Test
public void oclipCommandClientInitialzationFailedTest() {
OnapCommandClientInitialzationFailed failed = new OnapCommandClientInitialzationFailed("Test",
new Exception("Test Command Failed"));
@@ -107,22 +101,6 @@ public class OnapCommandErrorTest {
}
@Test
- public void oclipCommandHttpFailureTest1() {
- OnapCommandHttpFailure failed = new OnapCommandHttpFailure("Failed");
- assertEquals("0x3001::Failed", failed.getMessage());
-
- failed = new OnapCommandHttpFailure(new Exception("failed"), 201);
- assertEquals("201::0x3001::failed", failed.getMessage());
- }
-
- @Test
- public void oclipCommandHttpFailureTest2() {
- OnapCommandHttpFailure failed = new OnapCommandHttpFailure("Failed", 203);
-
- assertEquals("203::0x3001::Failed", failed.getMessage());
- }
-
- @Test
public void oclipCommandInvalidParameterTypeTest() {
OnapCommandInvalidParameterType failed = new OnapCommandInvalidParameterType("Failed");
@@ -141,7 +119,7 @@ public class OnapCommandErrorTest {
OnapCommandInvalidRegistration failed = new OnapCommandInvalidRegistration(OnapCommandErrorTest.class);
assertEquals("0x2001::Invalid commad class org.onap.cli.fw.error.OnapCommandErrorTest registration, "
- + "it should be derived from org.onap.cli.fw.OnapCommand", failed.getMessage());
+ + "it should be derived from org.onap.cli.fw.cmd.OnapCommand", failed.getMessage());
}
@Test
@@ -166,29 +144,6 @@ public class OnapCommandErrorTest {
}
@Test
- public void oclipCommandLoginFailedTest1() {
- OnapCommandLoginFailed failed = new OnapCommandLoginFailed(new Exception("Failed"));
-
- assertEquals("0x4001::Login failed, Failed", failed.getMessage());
- }
-
- @Test
- public void oclipCommandLoginFailedTest2() {
- OnapCommandLoginFailed failed = new OnapCommandLoginFailed("Failed", 201);
-
- assertEquals("201::0x4001::Login failed, Failed", failed.getMessage());
- }
-
- @Test
- public void oclipCommandLogoutFailedTest() {
- OnapCommandLogoutFailed failed = new OnapCommandLogoutFailed(new Exception("Failed"));
- assertEquals("0x4002::Logout failed, Failed", failed.getMessage());
-
- failed = new OnapCommandLogoutFailed(200);
- assertEquals("200::0x4002::Logout failed", failed.getMessage());
- }
-
- @Test
public void oclipCommandNotFoundTest() {
OnapCommandNotFound failed = new OnapCommandNotFound("Test", "1.0");
@@ -254,13 +209,6 @@ public class OnapCommandErrorTest {
}
@Test
- public void oclipCommandServiceNotFoundTest() {
- OnapCommandServiceNotFound failed = new OnapCommandServiceNotFound("Service");
-
- assertEquals("0xd001::Service Service is not found in MSB", failed.getMessage());
- }
-
- @Test
public void oclipCommandOutputFormatNotsupportedTest() {
OnapCommandOutputFormatNotsupported failed = new OnapCommandOutputFormatNotsupported("Format");
diff --git a/framework/src/test/java/org/onap/cli/fw/http/HttpInputOutputTest.java b/framework/src/test/java/org/onap/cli/fw/http/HttpInputOutputTest.java
deleted file mode 100644
index 0a3a817e..00000000
--- a/framework/src/test/java/org/onap/cli/fw/http/HttpInputOutputTest.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright 2016-17 Huawei Technologies Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onap.cli.fw.http;
-
-import static org.junit.Assert.assertTrue;
-
-import java.util.HashMap;
-
-import org.junit.Test;
-
-public class HttpInputOutputTest {
-
- @Test
- public void httpInputTest() {
- HttpInput inp = new HttpInput();
- inp.setBody("body");
- inp.setMethod("method");
- inp.setReqCookies(null);
- inp.setReqHeaders(null);
- inp.setReqQueries(null);
- inp.setUri("uri");
-
- assertTrue("body".equals(inp.getBody()) && "method".equals(inp.getMethod()) && null == inp.getReqCookies()
- && inp.getReqHeaders().isEmpty() && inp.getReqQueries().isEmpty() && "uri".equals(inp.getUri()));
-
- inp.setReqCookies(new HashMap<String, String>());
- inp.setReqHeaders(new HashMap<String, String>());
- inp.setReqQueries(new HashMap<String, String>());
-
- assertTrue(
- "\nURL: uri\nMethod: method\nRequest Queries: {}\nRequest Body: body\nRequest Headers: {}\nRequest Cookies: {}\nbinaryData=false"
- .equals(inp.toString()));
- }
-
- @Test
- public void httpResultTest() {
- HttpResult out = new HttpResult();
- out.setBody("body");
- out.setRespCookies(null);
- out.setRespHeaders(null);
- out.setStatus(205);
-
- assertTrue("body".equals(out.getBody()) && null == out.getRespCookies() && null == out.getRespHeaders()
- && 205 == out.getStatus());
-
- out.setRespCookies(new HashMap<String, String>());
- out.setRespHeaders(new HashMap<String, String>());
- out.setStatus(200);
- assertTrue("\nHTTP Status: 200\nResponse Body: body\nResponse Headers: {}\nResponse Cookies: {}"
- .equals(out.toString()));
- }
-
-}
diff --git a/framework/src/test/java/org/onap/cli/fw/http/OnapHttpConnectionTest.java b/framework/src/test/java/org/onap/cli/fw/http/OnapHttpConnectionTest.java
deleted file mode 100644
index 785092c2..00000000
--- a/framework/src/test/java/org/onap/cli/fw/http/OnapHttpConnectionTest.java
+++ /dev/null
@@ -1,205 +0,0 @@
-/*
- * Copyright 2017 Huawei Technologies Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onap.cli.fw.http;
-
-import static org.junit.Assert.assertEquals;
-
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.http.client.ClientProtocolException;
-import org.apache.http.client.methods.CloseableHttpResponse;
-import org.apache.http.client.methods.HttpUriRequest;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.protocol.HttpContext;
-import org.junit.Before;
-import org.junit.Test;
-import org.onap.cli.fw.error.OnapCommandHttpFailure;
-
-import mockit.Invocation;
-import mockit.Mock;
-import mockit.MockUp;
-
-public class OnapHttpConnectionTest {
- HttpInput inp = null;
- OnapHttpConnection con = null;
-
- @Before
- public void setup() {
- mockHttpRequest(null);
- inp = new HttpInput();
- inp.setMethod("get");
- inp.setBody("body");
- Map<String, String> map1 = new HashMap<>();
- map1.put("header1", "value1");
- inp.setReqHeaders(map1);
- Map<String, String> map2 = new HashMap<>();
- map2.put("query1", "value1");
- inp.setReqQueries(map2);
- Map<String, String> map = new HashMap<>();
- map.put("cookie1", "value1");
- inp.setReqCookies(map);
- inp.setUri("http://192.168.99.10:80");
- }
-
- @Test(expected = OnapCommandHttpFailure.class)
- public void httpUnSecuredGetExceptionTest() throws OnapCommandHttpFailure {
- new MockUp<CloseableHttpClient>() {
- @Mock
- public CloseableHttpResponse execute(HttpUriRequest request, HttpContext context)
- throws IOException, ClientProtocolException {
-
- throw new IOException("IO Exception");
- }
- };
- inp.setMethod("get");
- con = new OnapHttpConnection(true);
- con.getDebugInfo();
- con.get(inp);
-
- }
-
- @Test(expected = OnapCommandHttpFailure.class)
- public void httpUnSecuredPostExceptionTest() throws OnapCommandHttpFailure {
- new MockUp<CloseableHttpClient>() {
- @Mock
- public CloseableHttpResponse execute(HttpUriRequest request, HttpContext context)
- throws IOException, ClientProtocolException {
-
- throw new IOException("IO Exception");
- }
- };
-
- inp.setMethod("post");
- con = new OnapHttpConnection(true);
- con.post(inp);
- }
-
-
- @Test(expected = OnapCommandHttpFailure.class)
- public void httpUnSecuredPostExceptionTest1() throws OnapCommandHttpFailure {
- new MockUp<CloseableHttpClient>() {
- @Mock
- public CloseableHttpResponse execute(HttpUriRequest request, HttpContext context)
- throws IOException, ClientProtocolException {
-
- throw new IOException("IO Exception");
- }
- };
-
- inp.setMethod("post");
- inp.setBinaryData(true);
- con = new OnapHttpConnection(true);
- con.post(inp);
- }
-
- @Test(expected = OnapCommandHttpFailure.class)
- public void httpUnSecuredPutExceptionTest() throws OnapCommandHttpFailure {
- new MockUp<CloseableHttpClient>() {
- @Mock
- public CloseableHttpResponse execute(HttpUriRequest request, HttpContext context)
- throws IOException, ClientProtocolException {
-
- throw new IOException("IO Exception");
- }
- };
- inp.setMethod("put");
- con = new OnapHttpConnection(true);
- con.put(inp);
- }
-
- @Test(expected = OnapCommandHttpFailure.class)
- public void httpUnSecuredDeleteExceptionTest() throws OnapCommandHttpFailure {
- new MockUp<CloseableHttpClient>() {
- @Mock
- public CloseableHttpResponse execute(HttpUriRequest request, HttpContext context)
- throws IOException, ClientProtocolException {
-
- throw new IOException("IO Exception");
- }
- };
- inp.setMethod("delete");
- con = new OnapHttpConnection(true);
- con.delete(inp);
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void httpUnSecuredOtherExceptionTest() throws OnapCommandHttpFailure {
- new MockUp<CloseableHttpClient>() {
- @Mock
- public CloseableHttpResponse execute(HttpUriRequest request, HttpContext context)
- throws IOException, ClientProtocolException {
-
- throw new IOException("IO Exception");
- }
- };
- inp.setMethod("other");
- con = new OnapHttpConnection(true);
- con.request(inp);
- }
-
- @Test()
- public void httpUnSecuredCloseExceptionTest() throws OnapCommandHttpFailure {
- inp.setMethod("other");
- con = new OnapHttpConnection(true);
- con.close();
- }
-
- @Test
- public void httpSecuredGetExceptionTest() {
-
- // ProtocolVersion p = new ProtocolVersion("http",1,0);
- // HttpResponse hr = DefaultHttpResponseFactory.INSTANCE.newHttpResponse(p, 200 , null) ;
-
- new MockUp<CloseableHttpClient>() {
- @Mock
- public CloseableHttpResponse execute(HttpUriRequest request, HttpContext context)
- throws IOException, ClientProtocolException {
-
- throw new IOException("IO Exception");
- }
- };
- try {
- HttpInput inp = new HttpInput();
- inp.setMethod("get");
- inp.setBody("body");
- inp.setReqHeaders(new HashMap<String, String>());
- inp.setReqQueries(new HashMap<String, String>());
- inp.setUri("https://192.168.99.10:80");
- OnapHttpConnection con = new OnapHttpConnection(false);
- con.get(inp);
- } catch (OnapCommandHttpFailure e) {
- assertEquals("0x3001::IO Exception", e.getMessage());
- }
- }
-
- private static void mockHttpRequest(HttpResult result) {
- new MockUp<OnapHttpConnection>() {
- boolean isMock = false;
-
- @Mock
- public HttpResult request(Invocation inv, HttpInput input) throws OnapCommandHttpFailure {
- if (isMock) {
- return result;
- } else {
- return inv.proceed(input);
- }
- }
- };
- }
-}
diff --git a/framework/src/test/java/org/onap/cli/fw/input/OnapCommandParameterTest.java b/framework/src/test/java/org/onap/cli/fw/input/OnapCommandParameterTest.java
index 44656f9f..82781b43 100644
--- a/framework/src/test/java/org/onap/cli/fw/input/OnapCommandParameterTest.java
+++ b/framework/src/test/java/org/onap/cli/fw/input/OnapCommandParameterTest.java
@@ -36,7 +36,7 @@ public class OnapCommandParameterTest {
param.setLongOption("longOption");
param.setName("name");
param.setOptional(true);
- param.setParameterType(ParameterType.JSON);
+ param.setParameterType(OnapCommandParameterType.JSON);
param.setSecured(false);
param.setShortOption("shortOption");
param.setValue("value");
@@ -44,15 +44,15 @@ public class OnapCommandParameterTest {
assertTrue(param.getDefaultValue().equals("defaultValue") && param.getDescription().equals("description")
&& param.getLongOption().equals("longOption") && param.getName().equals("name")
&& param.getShortOption().equals("shortOption") && param.getValue().equals("value")
- && param.isOptional() && !param.isSecured() && param.getParameterType().equals(ParameterType.JSON));
+ && param.isOptional() && !param.isSecured() && param.getParameterType().equals(OnapCommandParameterType.JSON));
assertTrue("value".equals(param.getValue()));
- param.setParameterType(ParameterType.ARRAY);
+ param.setParameterType(OnapCommandParameterType.ARRAY);
param.setValue(Arrays.asList("1", "2", "3"));
assertTrue("[\"1\",\"2\",\"3\"]".equals(param.getValue()));
- param.setParameterType(ParameterType.MAP);
+ param.setParameterType(OnapCommandParameterType.MAP);
Map<String, String> map = new HashMap<>();
map.put("One", "1");
map.put("Two", "2");
@@ -82,7 +82,7 @@ public class OnapCommandParameterTest {
param.setOptional(false);
param.setValue("");
param.setDefaultValue("");
- param.setParameterType(ParameterType.STRING);
+ param.setParameterType(OnapCommandParameterType.STRING);
try {
param.validate();
} catch (OnapCommandException e) {
@@ -94,7 +94,7 @@ public class OnapCommandParameterTest {
public void oclipCommandInvalidParameterValueArrayExeceptionTest() throws OnapCommandInvalidParameterValue {
OnapCommandParameter param = new OnapCommandParameter();
param.setName("name");
- param.setParameterType(ParameterType.ARRAY);
+ param.setParameterType(OnapCommandParameterType.ARRAY);
param.setValue("value");
assertTrue("[\"1\",\"2\",\"3\"]".equals(param.getValue()));
@@ -104,7 +104,7 @@ public class OnapCommandParameterTest {
public void oclipCommandInvalidParameterValueMapExeceptionTest() throws OnapCommandInvalidParameterValue {
OnapCommandParameter param = new OnapCommandParameter();
param.setName("name");
- param.setParameterType(ParameterType.MAP);
+ param.setParameterType(OnapCommandParameterType.MAP);
param.setValue("value");
assertTrue("{\"One\":\"1\",\"Two\":\"2\",\"Three\":\"3\"}".equals(param.getValue()));
}
@@ -113,7 +113,7 @@ public class OnapCommandParameterTest {
public void oclipCommandInvalidParameterValueBinaryExeceptionTest() throws OnapCommandException {
OnapCommandParameter param = new OnapCommandParameter();
param.setName("name");
- param.setParameterType(ParameterType.BINARY);
+ param.setParameterType(OnapCommandParameterType.BINARY);
param.setValue("value");
param.validate();
}
diff --git a/framework/src/test/java/org/onap/cli/fw/input/ParameterTypeTest.java b/framework/src/test/java/org/onap/cli/fw/input/ParameterTypeTest.java
index 877f08f5..a42b9120 100644
--- a/framework/src/test/java/org/onap/cli/fw/input/ParameterTypeTest.java
+++ b/framework/src/test/java/org/onap/cli/fw/input/ParameterTypeTest.java
@@ -27,22 +27,22 @@ public class ParameterTypeTest {
public void paramTypeGetTest() {
try {
- assertTrue(ParameterType.JSON.equals(ParameterType.get("json"))
- && ParameterType.YAML.equals(ParameterType.get("yaml"))
- && ParameterType.STRING.equals(ParameterType.get("string"))
- && ParameterType.DIGIT.equals(ParameterType.get("digit"))
- && ParameterType.URL.equals(ParameterType.get("url"))
- && ParameterType.BOOL.equals(ParameterType.get("bool"))
- && ParameterType.MAP.equals(ParameterType.get("map"))
- && ParameterType.BINARY.equals(ParameterType.get("binary"))
- && ParameterType.TEXT.equals(ParameterType.get("text"))
- && ParameterType.ARRAY.equals(ParameterType.get("array")));
+ assertTrue(OnapCommandParameterType.JSON.equals(OnapCommandParameterType.get("json"))
+ && OnapCommandParameterType.YAML.equals(OnapCommandParameterType.get("yaml"))
+ && OnapCommandParameterType.STRING.equals(OnapCommandParameterType.get("string"))
+ && OnapCommandParameterType.DIGIT.equals(OnapCommandParameterType.get("digit"))
+ && OnapCommandParameterType.URL.equals(OnapCommandParameterType.get("url"))
+ && OnapCommandParameterType.BOOL.equals(OnapCommandParameterType.get("bool"))
+ && OnapCommandParameterType.MAP.equals(OnapCommandParameterType.get("map"))
+ && OnapCommandParameterType.BINARY.equals(OnapCommandParameterType.get("binary"))
+ && OnapCommandParameterType.TEXT.equals(OnapCommandParameterType.get("text"))
+ && OnapCommandParameterType.ARRAY.equals(OnapCommandParameterType.get("array")));
} catch (OnapCommandInvalidParameterType e) {
fail("Shouldn't have thrown this exception : " + e.getMessage());
}
try {
- ParameterType.get("name");
+ OnapCommandParameterType.get("name");
} catch (OnapCommandInvalidParameterType e) {
assertTrue("0x7001::Parameter type name is invalid".equals(e.getMessage()));
}
diff --git a/framework/src/test/java/org/onap/cli/fw/output/OnapCommandResultAttributeScopeTest.java b/framework/src/test/java/org/onap/cli/fw/output/OnapCommandResultAttributeScopeTest.java
index 7ab3fe52..8f5f861a 100644
--- a/framework/src/test/java/org/onap/cli/fw/output/OnapCommandResultAttributeScopeTest.java
+++ b/framework/src/test/java/org/onap/cli/fw/output/OnapCommandResultAttributeScopeTest.java
@@ -21,7 +21,7 @@ import static org.junit.Assert.assertTrue;
import java.util.Collections;
import org.junit.Test;
-import org.onap.cli.fw.input.ParameterType;
+import org.onap.cli.fw.input.OnapCommandParameterType;
public class OnapCommandResultAttributeScopeTest {
@Test
@@ -31,11 +31,11 @@ public class OnapCommandResultAttributeScopeTest {
att.setName("name");
att.setScope(OnapCommandResultAttributeScope.LONG);
att.setSecured(true);
- att.setType(ParameterType.DIGIT);
+ att.setType(OnapCommandParameterType.DIGIT);
att.setValues(Collections.emptyList());
assertTrue("description".equals(att.getDescription()) && "name".equals(att.getName())
&& OnapCommandResultAttributeScope.LONG.equals(att.getScope())
- && ParameterType.DIGIT.equals(att.getType()) && att.getValues().isEmpty());
+ && OnapCommandParameterType.DIGIT.equals(att.getType()) && att.getValues().isEmpty());
}
}
diff --git a/framework/src/test/java/org/onap/cli/fw/output/OnapCommandResultTest.java b/framework/src/test/java/org/onap/cli/fw/output/OnapCommandResultTest.java
index 9c832c24..667ed02a 100644
--- a/framework/src/test/java/org/onap/cli/fw/output/OnapCommandResultTest.java
+++ b/framework/src/test/java/org/onap/cli/fw/output/OnapCommandResultTest.java
@@ -26,7 +26,7 @@ import java.util.List;
import org.junit.Ignore;
import org.junit.Test;
import org.onap.cli.fw.error.OnapCommandException;
-import org.onap.cli.fw.input.ParameterType;
+import org.onap.cli.fw.input.OnapCommandParameterType;
public class OnapCommandResultTest {
@@ -37,16 +37,16 @@ public class OnapCommandResultTest {
res.setIncludeSeparator(true);
res.setIncludeTitle(true);
res.setOutput("Output");
- res.setPrintDirection(PrintDirection.LANDSCAPE);
+ res.setPrintDirection(OnapCommandPrintDirection.LANDSCAPE);
res.setRecords(new ArrayList<OnapCommandResultAttribute>());
res.setScope(OnapCommandResultAttributeScope.LONG);
- res.setType(ResultType.TABLE);
+ res.setType(OnapCommandResultType.TABLE);
res.setDebug(true);
assertTrue("debugInfo".equals(res.getDebugInfo()) && res.isIncludeSeparator()
- && "Output".equals(res.getOutput()) && PrintDirection.LANDSCAPE.equals(res.getPrintDirection())
+ && "Output".equals(res.getOutput()) && OnapCommandPrintDirection.LANDSCAPE.equals(res.getPrintDirection())
&& res.getRecords().isEmpty() && OnapCommandResultAttributeScope.LONG.equals(res.getScope())
- && ResultType.TABLE.equals(res.getType()));
+ && OnapCommandResultType.TABLE.equals(res.getType()));
String help = res.print();
@@ -61,18 +61,18 @@ public class OnapCommandResultTest {
res.setIncludeSeparator(true);
res.setIncludeTitle(true);
res.setOutput("Output");
- res.setPrintDirection(PrintDirection.LANDSCAPE);
+ res.setPrintDirection(OnapCommandPrintDirection.LANDSCAPE);
OnapCommandResultAttribute att = new OnapCommandResultAttribute();
att.setName("param");
att.setDescription("description");
- att.setType(ParameterType.STRING);
+ att.setType(OnapCommandParameterType.STRING);
att.setValues(new ArrayList<String>(Arrays.asList(new String[] { "value" })));
List<OnapCommandResultAttribute> list = new ArrayList<OnapCommandResultAttribute>();
list.add(att);
res.setRecords(list);
res.setScope(OnapCommandResultAttributeScope.LONG);
- res.setType(ResultType.TABLE);
+ res.setType(OnapCommandResultType.TABLE);
res.getRecordsMap();
String expRes = "+--------+\n|param |\n+--------+\n|value |\n+--------+\n";
String result = res.print();
@@ -88,19 +88,19 @@ public class OnapCommandResultTest {
res.setIncludeSeparator(true);
res.setIncludeTitle(true);
res.setOutput("Output");
- res.setPrintDirection(PrintDirection.LANDSCAPE);
+ res.setPrintDirection(OnapCommandPrintDirection.LANDSCAPE);
OnapCommandResultAttribute att = new OnapCommandResultAttribute();
att.setName("param");
att.setDescription("description");
- att.setType(ParameterType.JSON);
+ att.setType(OnapCommandParameterType.JSON);
att.setValues(
new ArrayList<String>(Arrays.asList(new String[] { "{\"id\": \"0001\",\"value\": \"result\"}" })));
List<OnapCommandResultAttribute> list = new ArrayList<OnapCommandResultAttribute>();
list.add(att);
res.setRecords(list);
res.setScope(OnapCommandResultAttributeScope.LONG);
- res.setType(ResultType.JSON);
+ res.setType(OnapCommandResultType.JSON);
// Will be handled after the json print is implemented
String result = res.print();
@@ -118,25 +118,25 @@ public class OnapCommandResultTest {
res.setIncludeSeparator(true);
res.setIncludeTitle(true);
res.setOutput("Output");
- res.setPrintDirection(PrintDirection.LANDSCAPE);
+ res.setPrintDirection(OnapCommandPrintDirection.LANDSCAPE);
OnapCommandResultAttribute att = new OnapCommandResultAttribute();
att.setName("param");
att.setDescription("description");
- att.setType(ParameterType.STRING);
+ att.setType(OnapCommandParameterType.STRING);
att.setValues(new ArrayList<String>(Arrays.asList(new String[] { "value" })));
List<OnapCommandResultAttribute> list = new ArrayList<OnapCommandResultAttribute>();
list.add(att);
OnapCommandResultAttribute a1 = new OnapCommandResultAttribute();
a1.setName("param1");
a1.setDescription("description1");
- a1.setType(ParameterType.STRING);
+ a1.setType(OnapCommandParameterType.STRING);
a1.setValues(new ArrayList<String>(Arrays.asList(new String[] { "value1" })));
list.add(a1);
res.setRecords(list);
res.setScope(OnapCommandResultAttributeScope.LONG);
- res.setType(ResultType.CSV);
+ res.setType(OnapCommandResultType.CSV);
String expRes = "param,param1\r\n";
String result = res.print();
@@ -152,25 +152,25 @@ public class OnapCommandResultTest {
res.setIncludeSeparator(true);
res.setIncludeTitle(true);
res.setOutput("Output");
- res.setPrintDirection(PrintDirection.PORTRAIT);
+ res.setPrintDirection(OnapCommandPrintDirection.PORTRAIT);
OnapCommandResultAttribute att = new OnapCommandResultAttribute();
att.setName("param");
att.setDescription("description");
- att.setType(ParameterType.STRING);
+ att.setType(OnapCommandParameterType.STRING);
att.setValues(new ArrayList<String>(Arrays.asList(new String[] { "value" })));
List<OnapCommandResultAttribute> list = new ArrayList<OnapCommandResultAttribute>();
list.add(att);
OnapCommandResultAttribute a1 = new OnapCommandResultAttribute();
a1.setName("param1");
a1.setDescription("description1");
- a1.setType(ParameterType.STRING);
+ a1.setType(OnapCommandParameterType.STRING);
a1.setValues(new ArrayList<String>(Arrays.asList(new String[] { "value1" })));
list.add(a1);
res.setRecords(list);
res.setScope(OnapCommandResultAttributeScope.LONG);
- res.setType(ResultType.CSV);
+ res.setType(OnapCommandResultType.CSV);
String expRes = "property,value\r\nparam,value\r\n";
String result = res.print();
assertEquals(expRes, result);
@@ -183,19 +183,19 @@ public class OnapCommandResultTest {
res.setIncludeSeparator(true);
res.setIncludeTitle(true);
res.setOutput("Output");
- res.setPrintDirection(PrintDirection.PORTRAIT);
+ res.setPrintDirection(OnapCommandPrintDirection.PORTRAIT);
OnapCommandResultAttribute att = new OnapCommandResultAttribute();
att.setName("param");
att.setDescription("description");
- att.setType(ParameterType.STRING);
+ att.setType(OnapCommandParameterType.STRING);
att.setValues(new ArrayList<String>(Arrays.asList(new String[] { "value" })));
List<OnapCommandResultAttribute> list = new ArrayList<OnapCommandResultAttribute>();
list.add(att);
res.setRecords(list);
res.setScope(OnapCommandResultAttributeScope.LONG);
- res.setType(ResultType.TABLE);
+ res.setType(OnapCommandResultType.TABLE);
String expRes = "+----------+--------+\n|property |value |\n+----------+--------+"
+ "\n|param |value |\n+----------+--------+\n";
diff --git a/framework/src/test/java/org/onap/cli/fw/output/PrintDirectionTest.java b/framework/src/test/java/org/onap/cli/fw/output/PrintDirectionTest.java
index d1ad7950..ae8dd2e1 100644
--- a/framework/src/test/java/org/onap/cli/fw/output/PrintDirectionTest.java
+++ b/framework/src/test/java/org/onap/cli/fw/output/PrintDirectionTest.java
@@ -27,14 +27,14 @@ public class PrintDirectionTest {
public void printDirectionGetTest() {
try {
- assertTrue(PrintDirection.LANDSCAPE.equals(PrintDirection.get("landscape"))
- && PrintDirection.PORTRAIT.equals(PrintDirection.get("portrait")));
+ assertTrue(OnapCommandPrintDirection.LANDSCAPE.equals(OnapCommandPrintDirection.get("landscape"))
+ && OnapCommandPrintDirection.PORTRAIT.equals(OnapCommandPrintDirection.get("portrait")));
} catch (OnapCommandInvalidPrintDirection e) {
fail("Shouldn't have thrown this exception : " + e.getMessage());
}
try {
- PrintDirection.get("name");
+ OnapCommandPrintDirection.get("name");
} catch (OnapCommandInvalidPrintDirection e) {
assertTrue("0x8003::Print direction name is invalid".equals(e.getMessage()));
}
diff --git a/framework/src/test/java/org/onap/cli/fw/output/ResultTypeTest.java b/framework/src/test/java/org/onap/cli/fw/output/ResultTypeTest.java
index 3c4c5665..a6590b3d 100644
--- a/framework/src/test/java/org/onap/cli/fw/output/ResultTypeTest.java
+++ b/framework/src/test/java/org/onap/cli/fw/output/ResultTypeTest.java
@@ -24,19 +24,19 @@ import org.junit.Test;
public class ResultTypeTest {
@Test
public void resultTypeGetTest() {
- assertTrue(ResultType.TABLE.equals(ResultType.get("table")) && ResultType.CSV.equals(ResultType.get("csv"))
- && ResultType.JSON.equals(ResultType.get("json")) && ResultType.YAML.equals(ResultType.get("yaml"))
- && ResultType.TEXT.equals(ResultType.get("text")));
+ assertTrue(OnapCommandResultType.TABLE.equals(OnapCommandResultType.get("table")) && OnapCommandResultType.CSV.equals(OnapCommandResultType.get("csv"))
+ && OnapCommandResultType.JSON.equals(OnapCommandResultType.get("json")) && OnapCommandResultType.YAML.equals(OnapCommandResultType.get("yaml"))
+ && OnapCommandResultType.TEXT.equals(OnapCommandResultType.get("text")));
}
@Test
public void isTabularFormTest() {
- assertTrue(ResultType.isTabularForm("table"));
+ assertTrue(OnapCommandResultType.isTabularForm("table"));
}
@Test
public void isTabularFormNotTest() {
- assertFalse(ResultType.isTabularForm("text"));
+ assertFalse(OnapCommandResultType.isTabularForm("text"));
}
}
diff --git a/framework/src/test/java/org/onap/cli/fw/output/print/OnapCommandPrintTest.java b/framework/src/test/java/org/onap/cli/fw/output/print/OnapCommandPrintTest.java
index 84c868b3..812e58e2 100644
--- a/framework/src/test/java/org/onap/cli/fw/output/print/OnapCommandPrintTest.java
+++ b/framework/src/test/java/org/onap/cli/fw/output/print/OnapCommandPrintTest.java
@@ -25,7 +25,7 @@ import java.util.List;
import org.junit.Ignore;
import org.junit.Test;
import org.onap.cli.fw.error.OnapCommandOutputPrintingFailed;
-import org.onap.cli.fw.output.PrintDirection;
+import org.onap.cli.fw.output.OnapCommandPrintDirection;
public class OnapCommandPrintTest {
@@ -33,7 +33,7 @@ public class OnapCommandPrintTest {
@Ignore
public void printCsvTest() throws OnapCommandOutputPrintingFailed {
OnapCommandPrint pr = new OnapCommandPrint();
- pr.setDirection(PrintDirection.LANDSCAPE);
+ pr.setDirection(OnapCommandPrintDirection.LANDSCAPE);
pr.setPrintTitle(true);
pr.addColumn("name1", new ArrayList<String>(Arrays.asList(new String[] { "value1" })));
String exp = "name1\r\n";
@@ -45,7 +45,7 @@ public class OnapCommandPrintTest {
public void printTableTest() throws OnapCommandOutputPrintingFailed {
OnapCommandPrint pr = new OnapCommandPrint();
List<String> getColumnsData = new ArrayList<String>();
- pr.setDirection(PrintDirection.LANDSCAPE);
+ pr.setDirection(OnapCommandPrintDirection.LANDSCAPE);
pr.setPrintTitle(true);
pr.addColumn("name2", new ArrayList<String>(Arrays.asList(new String[] { "value2" })));
String exp = "+--------+\n|name2 |\n+--------+\n|value2 |\n+--------+\n";
@@ -58,7 +58,7 @@ public class OnapCommandPrintTest {
public void printTableNullColumnHeaderTest() throws OnapCommandOutputPrintingFailed {
OnapCommandPrint pr = new OnapCommandPrint();
List<String> getColumnsData = new ArrayList<String>();
- pr.setDirection(PrintDirection.LANDSCAPE);
+ pr.setDirection(OnapCommandPrintDirection.LANDSCAPE);
pr.setPrintTitle(true);
pr.addColumn("name2", new ArrayList<String>(Arrays.asList(new String[] { "value2" })));
String exp = "+--------+\n|name2 |\n+--------+\n|value2 |\n+--------+\n";
@@ -71,7 +71,7 @@ public class OnapCommandPrintTest {
public void printTableEmptyColumnValuesTest() throws OnapCommandOutputPrintingFailed {
OnapCommandPrint pr = new OnapCommandPrint();
List<String> getColumnsData = new ArrayList<String>();
- pr.setDirection(PrintDirection.LANDSCAPE);
+ pr.setDirection(OnapCommandPrintDirection.LANDSCAPE);
pr.setPrintTitle(true);
pr.addColumn("name2", new ArrayList<String>(Arrays.asList(new String[] { "" })));
String exp = "+--------+\n|name2 |\n+--------+\n| |\n+--------+\n";
diff --git a/framework/src/test/java/org/onap/cli/fw/OnapCommandRegistrarTest.java b/framework/src/test/java/org/onap/cli/fw/registrar/OnapCommandRegistrarTest.java
index 3f9f780d..539ec245 100644
--- a/framework/src/test/java/org/onap/cli/fw/OnapCommandRegistrarTest.java
+++ b/framework/src/test/java/org/onap/cli/fw/registrar/OnapCommandRegistrarTest.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.onap.cli.fw;
+package org.onap.cli.fw.registrar;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
@@ -26,9 +26,11 @@ import java.net.URL;
import org.junit.Before;
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.error.OnapCommandNotFound;
+import org.onap.cli.fw.schema.OnapCommandSchema;
public class OnapCommandRegistrarTest {
@@ -99,13 +101,22 @@ public class OnapCommandRegistrarTest {
OnapCommandRegistrar.getRegistrar().setEnabledProductVersion("open-cli");
assertEquals("open-cli", OnapCommandRegistrar.getRegistrar().getEnabledProductVersion());
OnapCommandRegistrar.getRegistrar().getAvailableProductVersions();
- assertTrue(OnapCommandRegistrar.getRegistrar().listCommandsForEnabledProductVersion().contains("schema-refresh"));
+ assertTrue(OnapCommandRegistrar.getRegistrar().listCommandsForEnabledProductVersion().contains("sample-test"));
assertTrue(OnapCommandRegistrar.getRegistrar().listCommandInfo().size() > 2);
} catch (Exception e) {
fail("failed to test the profile");
}
}
+
+
+ @Test
+ public void test() throws OnapCommandException {
+ OnapCommandRegistrar registrar = OnapCommandRegistrar.getRegistrar();
+ OnapCommand cmd = registrar.get("sample-test");
+ cmd.printVersion();
+ registrar.listCommands();
+ }
}
@OnapCommandSchema(schema = "sample-test-schema.yaml")
diff --git a/framework/src/test/java/org/onap/cli/fw/schema/ValidateSchemaTest.java b/framework/src/test/java/org/onap/cli/fw/schema/ValidateSchemaTest.java
index a900fe6d..8153b6db 100644
--- a/framework/src/test/java/org/onap/cli/fw/schema/ValidateSchemaTest.java
+++ b/framework/src/test/java/org/onap/cli/fw/schema/ValidateSchemaTest.java
@@ -21,11 +21,9 @@ import static org.junit.Assert.assertTrue;
import java.util.List;
import org.junit.Test;
-import org.onap.cli.fw.OnapCommand;
-import org.onap.cli.fw.cmd.OnapHttpCommand;
+import org.onap.cli.fw.cmd.OnapCommand;
import org.onap.cli.fw.error.OnapCommandException;
import org.onap.cli.fw.error.OnapCommandInvalidSchema;
-import org.onap.cli.fw.utils.OnapCommandSchemaLoaderUtils;
public class ValidateSchemaTest {
@@ -36,7 +34,7 @@ public class ValidateSchemaTest {
@Override
protected void run() throws OnapCommandException {}
};
- OnapCommandSchemaLoaderUtils.loadSchema(cmd, "fdsfds.yaml", true, true);
+ OnapCommandSchemaLoader.loadSchema(cmd, "fdsfds.yaml", true, true);
}
@Test(expected = OnapCommandInvalidSchema.class)
@@ -45,7 +43,7 @@ public class ValidateSchemaTest {
@Override
protected void run() throws OnapCommandException {}
};
- OnapCommandSchemaLoaderUtils.loadSchema(cmd, "fdsfds", true, true);
+ OnapCommandSchemaLoader.loadSchema(cmd, "fdsfds", true, true);
}
@Test(expected = OnapCommandInvalidSchema.class)
@@ -54,7 +52,7 @@ public class ValidateSchemaTest {
@Override
protected void run() throws OnapCommandException {}
};
- OnapCommandSchemaLoaderUtils.loadSchema(cmd,
+ OnapCommandSchemaLoader.loadSchema(cmd,
ValidateSchemaTest.class.getClassLoader().getResource("open-cli.properties").getFile(),
true, true);
}
@@ -65,7 +63,7 @@ public class ValidateSchemaTest {
@Override
protected void run() throws OnapCommandException {}
};
- OnapCommandSchemaLoaderUtils.loadSchema(cmd, "schema-invalid-file-null.yaml", true, true);
+ OnapCommandSchemaLoader.loadSchema(cmd, "schema-invalid-file-null.yaml", true, true);
}
@Test
@@ -74,7 +72,7 @@ public class ValidateSchemaTest {
@Override
protected void run() throws OnapCommandException {}
};
- OnapCommandSchemaLoaderUtils.loadSchema(cmd, "schema-validate-pass.yaml", true, true);
+ OnapCommandSchemaLoader.loadSchema(cmd, "schema-validate-pass.yaml", true, true);
}
@@ -84,49 +82,32 @@ public class ValidateSchemaTest {
@Override
protected void run() throws OnapCommandException {}
};
- OnapCommandSchemaLoaderUtils.loadSchema(cmd, "schema-invalid-file.yaml", true, true);
+ OnapCommandSchemaLoader.loadSchema(cmd, "schema-invalid-file.yaml", true, true);
}
@Test
public void validateTest() throws OnapCommandException {
- OnapCommand cmd1 = new OnapCommand() {
- @Override
- protected void run() throws OnapCommandException {}
- };
- List<String> errorList1 = OnapCommandSchemaLoaderUtils.loadSchema(cmd1, "schema-validate-http.yaml", true, true);
- assertTrue(errorList1.size() > 0);
-
OnapCommand cmd2 = new OnapCommand() {
@Override
protected void run() throws OnapCommandException {}
};
- List<String> errorList2 = OnapCommandSchemaLoaderUtils.loadSchema(cmd2, "schema-validate-basic.yaml", true, true);
+ List<String> errorList2 = OnapCommandSchemaLoader.loadSchema(cmd2, "schema-validate-basic.yaml", true, true);
assertTrue(errorList2.size() > 0);
OnapCommand cmd3 = new OnapCommand() {
@Override
protected void run() throws OnapCommandException {}
};
- List<String> errorList3 = OnapCommandSchemaLoaderUtils.loadSchema(cmd2, "schema-validate-invalidschematype.yaml", true, true);
+ List<String> errorList3 = OnapCommandSchemaLoader.loadSchema(cmd2, "schema-validate-invalidschematype.yaml", true, true);
assertTrue(errorList3.size() > 0);
- OnapCommand cmd4 = new OnapCommand() {
- @Override
- protected void run() throws OnapCommandException {}
- };
- List<String> errorList4 = OnapCommandSchemaLoaderUtils.loadSchema(cmd2, "schema-validate-invalid.yaml", true, true);
-
- OnapHttpCommand oclipHttpCommand = new OnapHttpCommand();
- errorList4.addAll(OnapCommandSchemaLoaderUtils.loadHttpSchema(oclipHttpCommand,
- "schema-validate-invalid.yaml", true, true));
- assertTrue(errorList4.size() > 0);
OnapCommand cmd5 = new OnapCommand() {
@Override
protected void run() throws OnapCommandException {}
};
- List<String> errorList5 = OnapCommandSchemaLoaderUtils.loadSchema(cmd5, "schema-validate-pass.yaml", true, true);
+ List<String> errorList5 = OnapCommandSchemaLoader.loadSchema(cmd5, "schema-validate-pass.yaml", true, true);
assertTrue(errorList5.size() == 0);
}
diff --git a/framework/src/test/java/org/onap/cli/fw/utils/OnapCommandUtilsTest.java b/framework/src/test/java/org/onap/cli/fw/utils/OnapCommandUtilsTest.java
index 8cac03bf..317920f8 100644
--- a/framework/src/test/java/org/onap/cli/fw/utils/OnapCommandUtilsTest.java
+++ b/framework/src/test/java/org/onap/cli/fw/utils/OnapCommandUtilsTest.java
@@ -23,9 +23,7 @@ import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.io.IOException;
-import java.util.ArrayList;
import java.util.Arrays;
-import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
@@ -35,29 +33,20 @@ import org.junit.FixMethodOrder;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runners.MethodSorters;
-import org.onap.cli.fw.OnapCommand;
-import org.onap.cli.fw.OnapCommandSchema;
-import org.onap.cli.fw.cmd.OnapHttpCommand;
+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.error.OnapCommandHttpHeaderNotFound;
-import org.onap.cli.fw.error.OnapCommandHttpInvalidResponseBody;
-import org.onap.cli.fw.error.OnapCommandInvalidParameterType;
-import org.onap.cli.fw.error.OnapCommandInvalidPrintDirection;
-import org.onap.cli.fw.error.OnapCommandInvalidResultAttributeScope;
import org.onap.cli.fw.error.OnapCommandInvalidSchema;
import org.onap.cli.fw.error.OnapCommandInvalidSchemaVersion;
import org.onap.cli.fw.error.OnapCommandParameterNameConflict;
-import org.onap.cli.fw.error.OnapCommandParameterNotFound;
import org.onap.cli.fw.error.OnapCommandParameterOptionConflict;
import org.onap.cli.fw.error.OnapCommandSchemaNotFound;
-import org.onap.cli.fw.http.HttpInput;
-import org.onap.cli.fw.http.HttpResult;
import org.onap.cli.fw.info.OnapCommandInfo;
import org.onap.cli.fw.input.OnapCommandParameter;
-import org.onap.cli.fw.input.ParameterType;
import org.onap.cli.fw.output.OnapCommandResult;
-import org.springframework.core.io.Resource;
+import org.onap.cli.fw.schema.OnapCommandSchema;
+import org.onap.cli.fw.schema.OnapCommandSchemaInfo;
+import org.onap.cli.fw.schema.OnapCommandSchemaLoader;
import mockit.Invocation;
import mockit.Mock;
@@ -65,21 +54,9 @@ import mockit.MockUp;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class OnapCommandUtilsTest {
-
- @Test(expected = OnapCommandInvalidSchema.class)
- public void oclipCommandUtilsInputStreamNullTest() throws OnapCommandException {
- OnapCommandSchemaLoaderUtils.validateSchemaVersion("sample-test1-schema-http1.yaml", "1.0");
- }
-
- @Test
- public void oclipCommandUtilsInputStreamNotNullTest() throws OnapCommandException {
- Map<String, ?> map = OnapCommandSchemaLoaderUtils.validateSchemaVersion("sample-test1-schema-http.yaml", "1.0");
- assertTrue(map != null);
- }
-
@Test
public void externalSchemaTest() {
- SchemaInfo schema = new SchemaInfo();
+ OnapCommandSchemaInfo schema = new OnapCommandSchemaInfo();
schema.setCmdName("cmdName");
schema.setSchemaName("schemaName");
schema.setVersion("version");
@@ -91,7 +68,7 @@ public class OnapCommandUtilsTest {
@Test
public void schemaFileNotFoundTest() throws OnapCommandException {
- Map<String, ?> map = OnapCommandSchemaLoaderUtils.validateSchemaVersion("sample-test-schema.yaml", "1.0");
+ Map<String, ?> map = OnapCommandSchemaLoader.validateSchemaVersion("sample-test-schema.yaml", "1.0");
assertTrue(map.size() > 0);
}
@@ -100,7 +77,7 @@ public class OnapCommandUtilsTest {
public void invalidSchemaFileTest() throws OnapCommandException {
Map<String, ?> map = null;
try {
- map = OnapCommandSchemaLoaderUtils.validateSchemaVersion("sample-test-schema1.yaml", "1.0");
+ map = OnapCommandSchemaLoader.validateSchemaVersion("sample-test-schema1.yaml", "1.0");
} catch (OnapCommandInvalidSchemaVersion e) {
fail("Test should not have thrown this exception : " + e.getMessage());
} catch (OnapCommandInvalidSchema e) {
@@ -114,7 +91,7 @@ public class OnapCommandUtilsTest {
public void validateWrongSchemaVersionTest() throws OnapCommandException {
Map<String, ?> map = null;
try {
- map = OnapCommandSchemaLoaderUtils.validateSchemaVersion("sample-test-invalid-schema.yaml", "1.0");
+ map = OnapCommandSchemaLoader.validateSchemaVersion("sample-test-invalid-schema.yaml", "1.0");
} catch (OnapCommandInvalidSchemaVersion e) {
fail("Test should not have thrown this exception : " + e.getMessage());
} catch (OnapCommandInvalidSchema e) {
@@ -128,7 +105,7 @@ public class OnapCommandUtilsTest {
public void validateSchemaVersionTest() throws OnapCommandException {
Map<String, ?> map = null;
try {
- map = OnapCommandSchemaLoaderUtils.validateSchemaVersion("sample-test-schema.yaml", "1.1");
+ map = OnapCommandSchemaLoader.validateSchemaVersion("sample-test-schema.yaml", "1.1");
} catch (OnapCommandInvalidSchemaVersion e) {
assertEquals("0xb003::Command schema open_cli_schema_version 1.0 is invalid or missing", e.getMessage());
} catch (OnapCommandInvalidSchema e) {
@@ -141,32 +118,32 @@ public class OnapCommandUtilsTest {
@Test
public void loadOnapCommandSchemaWithOutDefaultTest() throws OnapCommandException {
OnapCommand cmd = new OnapCommandSample();
- OnapCommandSchemaLoaderUtils.loadSchema(cmd, "sample-test-schema.yaml", false, false);
+ OnapCommandSchemaLoader.loadSchema(cmd, "sample-test-schema.yaml", false, false);
assertTrue("sample-test".equals(cmd.getName()) && cmd.getParameters().size() == 9);
}
@Test(expected = OnapCommandParameterNameConflict.class)
public void loadOnapCommandSchemaWithDuplicateNameTest() throws OnapCommandException {
OnapCommand cmd = new OnapCommandSample();
- OnapCommandSchemaLoaderUtils.loadSchema(cmd, "sample-test-invalid-schema-duplicate-name.yaml", false, false);
+ OnapCommandSchemaLoader.loadSchema(cmd, "sample-test-invalid-schema-duplicate-name.yaml", false, false);
}
@Test(expected = OnapCommandParameterOptionConflict.class)
public void loadOnapCommandSchemaWithDuplicateShortOptionTest() throws OnapCommandException {
OnapCommand cmd = new OnapCommandSample();
- OnapCommandSchemaLoaderUtils.loadSchema(cmd, "sample-test-invalid-schema-duplicate-shortoption.yaml", false, false);
+ OnapCommandSchemaLoader.loadSchema(cmd, "sample-test-invalid-schema-duplicate-shortoption.yaml", false, false);
}
@Test(expected = OnapCommandParameterOptionConflict.class)
public void loadOnapCommandSchemaWithDuplicateLongOptionTest() throws OnapCommandException {
OnapCommand cmd = new OnapCommandSample();
- OnapCommandSchemaLoaderUtils.loadSchema(cmd, "sample-test-invalid-schema-duplicate-longoption.yaml", false, false);
+ OnapCommandSchemaLoader.loadSchema(cmd, "sample-test-invalid-schema-duplicate-longoption.yaml", false, false);
}
@Test
public void loadOnapCommandSchemaWithDefaultTest() throws OnapCommandException {
OnapCommand cmd = new OnapCommandSample();
- OnapCommandSchemaLoaderUtils.loadSchema(cmd, "sample-test-schema.yaml", true, false);
+ OnapCommandSchemaLoader.loadSchema(cmd, "sample-test-schema.yaml", true, false);
assertTrue("sample-test".equals(cmd.getName()) && cmd.getParameters().size() > 9);
for (OnapCommandParameter com : cmd.getParameters()) {
@@ -177,49 +154,11 @@ public class OnapCommandUtilsTest {
assertTrue(map.size() == 15);
}
- @Test
- public void loadOnapCommandSchemaAuthRequiredTest() throws OnapCommandException {
- OnapCommand cmd = new OnapCommandSample();
- OnapCommandSchemaLoaderUtils.loadSchema(cmd, "sample-test-schema-auth-required.yaml", true, false);
- assertTrue("sample-test".equals(cmd.getName()));
-
- Map<String, OnapCommandParameter> map = OnapCommandUtils.getInputMap(cmd.getParameters());
- assertTrue(map.size() == 7);
- }
-
- @Test
- public void loadHttpBasedSchemaExceptionTest() throws OnapCommandException {
- OnapHttpCommand cmd = new OnapHttpCommandSample();
- cmd.setName("sample-test-http");
- try {
- OnapCommandSchemaLoaderUtils.loadHttpSchema(cmd, "sample-test-schema.yaml", true, false);
- } catch (OnapCommandParameterNameConflict | OnapCommandParameterOptionConflict
- | OnapCommandInvalidParameterType | OnapCommandInvalidPrintDirection
- | OnapCommandInvalidResultAttributeScope | OnapCommandSchemaNotFound | OnapCommandInvalidSchema
- | OnapCommandInvalidSchemaVersion e) {
- assertTrue(e.getMessage().contains("0xb001::Command schema sample-test-schema.yaml is invalid"));
- }
- }
-
- @Test
- public void loadHttpBasedSchemaTest() throws OnapCommandException {
- OnapHttpCommand cmd = new OnapHttpCommandSample();
- cmd.setName("sample-create-http");
- try {
- OnapCommandSchemaLoaderUtils.loadHttpSchema(cmd, "sample-test-schema-http.yaml", true, true);
- assertTrue(cmd.getSuccessStatusCodes().size() == 2);
- } catch (OnapCommandParameterNameConflict | OnapCommandParameterOptionConflict
- | OnapCommandInvalidParameterType | OnapCommandInvalidPrintDirection
- | OnapCommandInvalidResultAttributeScope | OnapCommandSchemaNotFound | OnapCommandInvalidSchema
- | OnapCommandInvalidSchemaVersion e) {
- fail("Test should not have thrown this exception : " + e.getMessage());
- }
- }
@Test
public void helpCommandTest() throws IOException, OnapCommandException {
OnapCommand cmd = new OnapCommandSample();
- OnapCommandSchemaLoaderUtils.loadSchema(cmd, "sample-test-schema.yaml", true, false);
+ OnapCommandSchemaLoader.loadSchema(cmd, "sample-test-schema.yaml", true, false);
String actualResult = OnapCommandHelperUtils.help(cmd);
@@ -231,7 +170,7 @@ public class OnapCommandUtilsTest {
@Test
public void findOnapCommandsTest() {
List<Class<OnapCommand>> cmds = OnapCommandDiscoveryUtils.discoverCommandPlugins();
- assertTrue(cmds.size() == 7);
+ assertTrue(cmds.size() == 3);
}
@Test
@@ -264,105 +203,12 @@ public class OnapCommandUtilsTest {
}
- @Test
- public void formMethodNameFromAttributeTest() {
-
- String str = "";
- String name = OnapCommandUtils.formMethodNameFromAttributeName(str, "test");
-
- assertEquals("", name);
-
- str = null;
- name = OnapCommandUtils.formMethodNameFromAttributeName(str, "test");
-
- assertEquals(null, name);
-
- str = "test-get";
- name = OnapCommandUtils.formMethodNameFromAttributeName(str, "");
- assertEquals("TestGet", name);
-
- }
-
- @Test
- public void populateParametersTest() throws OnapCommandException {
-
- HttpInput input = new HttpInput();
- input.setBody("body");
- input.setMethod("method");
- Map<String, String> mapHead = new HashMap<>();
- mapHead.put("key2", "${value2}");
- input.setReqHeaders(mapHead);
- Map<String, String> query = new HashMap<>();
- query.put("key3", "{${value3}}");
- input.setReqQueries(query);
- input.setUri("uri");
-
- Map<String, OnapCommandParameter> params = new HashMap<>();
- OnapCommandParameter param = new OnapCommandParameter();
- param.setDefaultValue("defaultValue2");
- param.setParameterType(ParameterType.STRING);
- params.put("value2", param);
- OnapCommandParameter param1 = new OnapCommandParameter();
- param1.setDefaultValue("{\"defaultValue3\"}");
- param1.setParameterType(ParameterType.JSON);
- params.put("value3", param1);
-
- HttpInput input1 = OnapCommandUtils.populateParameters(params, input);
- String expected = "\nURL: uri\nMethod: method\nRequest Queries: {key3={\"defaultValue3\"}}\n"
- + "Request Body: body\nRequest Headers: {key2=defaultValue2}\nRequest Cookies: {}\nbinaryData=false";
- assertEquals(expected, input1.toString());
-
- input.setBody("${body}");
-
- HttpInput input2 = null;
- try {
- input2 = OnapCommandUtils.populateParameters(params, input);
- } catch (OnapCommandParameterNotFound e) {
- assertEquals("0x7005::Command input parameter body is not valid", e.getMessage());
- }
-
- }
-
- @Test(expected = OnapCommandHttpHeaderNotFound.class)
- public void populateOutputsTest() throws OnapCommandException {
- HttpResult output = new HttpResult();
- output.setBody(
- "{\"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\"}");
- Map<String, String> mapHead = new HashMap<>();
- mapHead.put("head1", "value1");
- output.setRespHeaders(mapHead);
- output.setStatus(0);
-
- Map<String, String> params = new HashMap<>();
- params.put("head", "$h{head1}");
- params.put("body", "$b{$.serviceName}");
- params.put("key", "value");
-
- Map<String, ArrayList<String>> input1 = OnapCommandUtils.populateOutputs(params, output);
- assertEquals("{head=[value1], body=[test], key=[value]}", input1.toString());
-
- params.put("body", "$b{{$.serviceName}");
- try {
- input1 = OnapCommandUtils.populateOutputs(params, output);
- } catch (OnapCommandHttpInvalidResponseBody e) {
- assertEquals(
- "0x3004::Http response body does not have json entry {$.serviceName, Missing property in path $['{$']",
- e.getMessage());
- }
- output.setBody("{}");
- input1 = OnapCommandUtils.populateOutputs(params, output);
- params.put("head", "$h{head2}");
- output.setBody("{\"test\"}");
- input1 = OnapCommandUtils.populateOutputs(params, output);
- }
-
-
@Test(expected = OnapCommandHelpFailed.class)
public void zendExceptionHelpTest1() throws OnapCommandException {
mockPrintMethodException();
OnapCommand cmd = new OnapCommandSample();
- OnapCommandSchemaLoaderUtils.loadSchema(cmd, "sample-test-schema.yaml", true, false);
+ OnapCommandSchemaLoader.loadSchema(cmd, "sample-test-schema.yaml", true, false);
OnapCommandHelperUtils.help(cmd);
@@ -372,7 +218,7 @@ public class OnapCommandUtilsTest {
@Test
public void test() throws OnapCommandException {
OnapCommandSampleInfo cmd = new OnapCommandSampleInfo();
- OnapCommandSchemaLoaderUtils.loadSchema(cmd, "sample-test-info.yaml", true, false);
+ OnapCommandSchemaLoader.loadSchema(cmd, "sample-test-info.yaml", true, false);
OnapCommandInfo info = cmd.getInfo();
assert info != null;
}
@@ -391,30 +237,6 @@ public class OnapCommandUtilsTest {
}
}
- @OnapCommandSchema(schema = "sample-test-schema-http.yaml")
- class OnapHttpCommandSample extends OnapHttpCommand {
-
- @Override
- protected void run() throws OnapCommandException {
- }
- }
-
- private void mockExternalResources() {
- new MockUp<OnapCommandUtils>() {
- boolean isMock = true;
-
- @Mock
- public Resource[] getExternalResources(Invocation inv, String pattern) throws IOException {
- if (isMock) {
- isMock = false;
- throw new IOException();
- } else {
- return inv.proceed(pattern);
- }
- }
- };
- }
-
private void mockPrintMethodException() {
new MockUp<OnapCommandResult>() {
boolean isMock = true;
diff --git a/framework/src/test/java/org/onap/cli/fw/utils/OpenCommandRegistrarTest.java b/framework/src/test/java/org/onap/cli/fw/utils/OpenCommandRegistrarTest.java
deleted file mode 100644
index 648746ca..00000000
--- a/framework/src/test/java/org/onap/cli/fw/utils/OpenCommandRegistrarTest.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright 2017 Huawei Technologies Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onap.cli.fw.utils;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.onap.cli.fw.OnapCommand;
-import org.onap.cli.fw.OnapCommandRegistrar;
-import org.onap.cli.fw.error.OnapCommandException;
-
-
-public class OpenCommandRegistrarTest {
-
- @Before
- public void setUp() throws Exception {
-
- }
-
- @Test
- public void test() throws OnapCommandException {
- OnapCommandRegistrar registrar = OnapCommandRegistrar.getRegistrar();
- OnapCommand cmd = registrar.get("sample-test");
- cmd.printVersion();
- registrar.listCommands();
- }
-
-}
diff --git a/framework/src/test/resources/META-INF/services/org.onap.cli.fw.OnapCommand b/framework/src/test/resources/META-INF/services/org.onap.cli.fw.cmd.OnapCommand
index a01b9d53..a01b9d53 100644
--- a/framework/src/test/resources/META-INF/services/org.onap.cli.fw.OnapCommand
+++ b/framework/src/test/resources/META-INF/services/org.onap.cli.fw.cmd.OnapCommand
diff --git a/framework/src/test/resources/open-cli-schema/sample-test1-schema-http.yaml b/framework/src/test/resources/open-cli-schema/sample-test1-schema-http.yaml
deleted file mode 100644
index f162231f..00000000
--- a/framework/src/test/resources/open-cli-schema/sample-test1-schema-http.yaml
+++ /dev/null
@@ -1,95 +0,0 @@
-open_cli_schema_version: 1.0
-name: sample-test1
-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: false
- default_Value: pass123#
- - name: string-param
- type: string
- description: Oclip string param
- long_option: string-param
- short_option: c
- is_optional: false
- default_Value: test
- - name: yaml-param
- type: json
- description: Oclip yaml file location param
- long_option: yaml-param
- short_option: y
- is_optional: false
- - name: json-param
- type: json
- description: Oclip json file location param
- long_option: json-param
- short_option: j
- is_optional: false
- - name: long-param
- type: digit
- description: Oclip long param
- short_option: l
- long_option: long-opt
- is_optional: false
- default_value: 10
- - name: url-param
- type: url
- description: Oclip url param
- short_option: r
- long_option: url
- is_optional: false
- default_value: http://localhost:8082/file.txt
- - name: env-param
- type: string
- description: Oclip env param.
- short_option: z
- long_option: env
- is_optional: false
- default_value: ${ENV_VAR}
- - name: positional-args
- type: string
- description: Oclip positional args, if no short option and no long option given for it
- is_optional: false
- default_value: http://localhost:8082/file.txt
-http:
- request:
- uri: /vims
- method: POST
- body: '{"name":"${name}","vendor":"${vendor}","version":"${vim-version}","description":"${description}","type":"${type}","url":"${url}","userName":"${username}","password":"${password}","domain":"${domain}","tenant":"${tenant}"}'
- headers:
- success_codes:
- - 201
- - 200
- result_map:
- id: $b{$.vimId}
- name: $b{$.name}
- vendor: $b{$.vendor}
- type: $b{$.type}
- version: $b{$.version}
- url: $b{$.url}
- description: $b{$.description}
- username: $b{$.userName}
- password: $b{$.password}
- domain: $b{$.domain}
- tenant: $b{$.tenant}
- create-time: $b{$.createTime}
- sample_response:
- body:'{"id":"string","name":"string","vendor":"string","version":"string","description":"string","type":"string","createTime":"string","url":"string","userName":"string","password":"string","domain":"string","tenant":"string"}' \ No newline at end of file
diff --git a/framework/src/test/resources/open-cli-schema/testauth-login.yaml b/framework/src/test/resources/open-cli-schema/testauth-login.yaml
deleted file mode 100644
index 3e9211ef..00000000
--- a/framework/src/test/resources/open-cli-schema/testauth-login.yaml
+++ /dev/null
@@ -1,28 +0,0 @@
-open_cli_schema_version: 1.0
-
-name: testauth-login
-
-description: basic login auth command
-
-info:
- product: open-cli
- service: test
- type: auth
- author: Kanagaraj Manickam kanagaraj.manickam@huawei.com
-
-parameters:
- - name: string-param
- type: string
- description: Oclip string param
- long_option: string-param
- short_option: c
- is_optional: false
- default_Value: test
-
-# followings are dummy simulator for http command
-http:
- request:
- uri: /
- method: GET
- success_codes:
- - 200
diff --git a/framework/src/test/resources/open-cli-schema/testauth-logout.yaml b/framework/src/test/resources/open-cli-schema/testauth-logout.yaml
deleted file mode 100644
index dfe33638..00000000
--- a/framework/src/test/resources/open-cli-schema/testauth-logout.yaml
+++ /dev/null
@@ -1,19 +0,0 @@
-open_cli_schema_version: 1.0
-
-name: testauth-logout
-
-description: basic logout auth command
-
-info:
- product: open-cli
- service: test
- type: auth
- author: Kanagaraj Manickam kanagaraj.manickam@huawei.com
-
-# followings are dummy simulator for http command
-http:
- request:
- uri: /
- method: GET
- success_codes:
- - 200 \ No newline at end of file
diff --git a/framework/src/test/resources/open-cli.properties b/framework/src/test/resources/open-cli.properties
deleted file mode 100644
index 23ba7800..00000000
--- a/framework/src/test/resources/open-cli.properties
+++ /dev/null
@@ -1,39 +0,0 @@
-cli.ignore_auth=false
-cli.http.api_key_use_cookies=true
-cli.discover_always=true
-cli.product_name=open-cli
-cli.version=1.0
-
-#schema validation
-cli.schema.top_level_params_list=open_cli_schema_version,name,description,parameters,results,http,info
-cli.schema.top_level_mandatory_list=open_cli_schema_version
-
-cli.schema.info_params_list=product,service,type,author,ignore
-cli.schema.info_params_mandatory_list=product,service
-
-cli.schema.input_params_list=name,description,type,short_option,long_option, is_optional,default_value,is_secured,is_include
-cli.schema.input_params_mandatory_list=name,description,type
-
-cli.schema.result_params_list=name,description,scope,type,is_secured, default_value
-cli.schema.result_params_mandatory_list=name, description, type, scope
-
-#http
-cli.schema.http_sections=request,service,success_codes,result_map,sample_response
-cli.schema.http_mandatory_sections=request, success_codes
-
-cli.schema.http_request_params=uri,method,body,headers,queries,multipart_entity_name
-cli.schema.http_request_mandatory_params=uri,method
-
-cli.schema.service_params_list=name,version,auth,mode
-cli.schema.service_params_mandatory_list=auth,mode
-
-cli.schema.http_methods=post,get,delete,put,head
-
-cli.schema.boolean_values=true,false
-cli.schema.auth_values=none,basic
-cli.schema.mode_values=direct,catalog
-cli.command.type=cmd,auth,catalog
-
-# mrkanag Move this to db, once exteranl command registration is supported in place of discovery
-cli.schema.type.supported=http
-
diff --git a/framework/src/test/resources/sample-test-schema-auth-required.yaml b/framework/src/test/resources/sample-test-schema-auth-required.yaml
deleted file mode 100644
index bb919d9a..00000000
--- a/framework/src/test/resources/sample-test-schema-auth-required.yaml
+++ /dev/null
@@ -1,16 +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 \ No newline at end of file
diff --git a/framework/src/test/resources/sample-test-schema-http.yaml b/framework/src/test/resources/sample-test-schema-http.yaml
deleted file mode 100644
index 4ae6e9e0..00000000
--- a/framework/src/test/resources/sample-test-schema-http.yaml
+++ /dev/null
@@ -1,92 +0,0 @@
-open_cli_schema_version: 1.0
-name: sample-create-http
-description: Register microservice 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: service-version
- description: Oclip service version
- type: string
- short_option: y
- long_option: service-version
- is_optional: false
- - name: service-url
- description: Oclip service base url
- type: url
- short_option: r
- long_option: service-url
- is_optional: false
- - name: status
- description: Oclip service status
- type: digit
- short_option: z
- long_option: service-status
- is_optional: true
- default_value: 1
- - name: node-ip
- description: Oclip service running node IP
- type: string
- - name: node-port
- description: Oclip service running node port
- type: string
- - name: create-or-update
- description: Oclip service create or update
- type: bool
- default_value: true
-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}","version":"${service-version}","url":"${service-url}","protocol":"REST","visualRange":"1","lb_policy":"hash","nodes":[{"ip":"${node-ip}","port":"${node-port}","ttl":0}]}'
- headers:
- queries:
- createOrUpdate: ${create-or-update}
- 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/framework/src/test/resources/sample-test-schema-no-auth-no-catalog.yaml b/framework/src/test/resources/sample-test-schema-no-auth-no-catalog.yaml
deleted file mode 100644
index 2629a2f9..00000000
--- a/framework/src/test/resources/sample-test-schema-no-auth-no-catalog.yaml
+++ /dev/null
@@ -1,26 +0,0 @@
-open_cli_schema_version: 1.0
-
-name: sample-cmd-no-auth-no-catalog
-
-description: sample
-
-info:
- product: open-cli
- service: test
- type: cmd
- author: Kanagaraj Manickam kanagaraj.manickam@huawei.com
-
-http:
-
- service:
- name: sample
- version: v1
- auth: none
- mode: direct
- request:
- uri: /test
- method: GET
- success_codes:
- - 200
- result_map:
- name: ${name}
diff --git a/framework/src/test/resources/sample-test-schema-no-auth-yes-catalog.yaml b/framework/src/test/resources/sample-test-schema-no-auth-yes-catalog.yaml
deleted file mode 100644
index 15b5bf0c..00000000
--- a/framework/src/test/resources/sample-test-schema-no-auth-yes-catalog.yaml
+++ /dev/null
@@ -1,28 +0,0 @@
-open_cli_schema_version: 1.0
-
-name: sample-cmd-no-auth-no-catalog
-
-description: sample
-
-
-info:
- product: open-cli
- service: test
- type: cmd
- author: Kanagaraj Manickam kanagaraj.manickam@huawei.com
-
-http:
-
- service:
- name: sample
- version: v1
- auth: none
- mode: catalog
-
- request:
- uri: /test
- method: GET
- success_codes:
- - 200
- result_map:
- name: ${name}
diff --git a/framework/src/test/resources/sample-test-schema-swagger.yaml b/framework/src/test/resources/sample-test-schema-swagger.yaml
deleted file mode 100644
index 4108d4e6..00000000
--- a/framework/src/test/resources/sample-test-schema-swagger.yaml
+++ /dev/null
@@ -1,28 +0,0 @@
-open_cli_schema_version: 1.0
-name: sample-test-swagger
-description: Sample swagger command test.
-info:
- product: open-cli
- service: test
- type: cmd
- author: Kanagaraj Manickam kanagaraj.manickam@huawei.com
-parameters:
- - name: user
- type: string
- description: Oclip user
- short_option: n
- long_option: username
- is_optional: false
-results:
- direction: portrait
- attributes:
- - name: name
- description: Oclip user
- scope: short
- type: string
-exec:
- api: org.onap.common_services.auth.auth_service.client.api.DefaultApi
- client: org.onap.common_services.auth.auth_service.client.invoker.ApiClient
- entity: org.onap.common_services.auth.auth_service.client.model.User, username(userName), password, description
- method: create
- exception: org.onap.common_services.auth.auth_service.client.invoker.ApiException \ No newline at end of file
diff --git a/framework/src/test/resources/sample-test-schema-yes-auth-no-catalog.yaml b/framework/src/test/resources/sample-test-schema-yes-auth-no-catalog.yaml
deleted file mode 100644
index bb0ae46b..00000000
--- a/framework/src/test/resources/sample-test-schema-yes-auth-no-catalog.yaml
+++ /dev/null
@@ -1,26 +0,0 @@
-open_cli_schema_version: 1.0
-
-name: sample-cmd-yes-auth-no-catalog
-
-description: sample
-
-info:
- product: open-cli
- service: test
- type: cmd
- author: Kanagaraj Manickam kanagaraj.manickam@huawei.com
-
-http:
-
- service:
- name: sample
- version: v1
- auth: basic
- mode: direct
- request:
- uri: /test
- method: GET
- success_codes:
- - 200
- result_map:
- name: ${name}
diff --git a/framework/src/test/resources/sample-test-schema-yes-auth-with-additional-params-no-catalog.yaml b/framework/src/test/resources/sample-test-schema-yes-auth-with-additional-params-no-catalog.yaml
deleted file mode 100644
index a5a39f92..00000000
--- a/framework/src/test/resources/sample-test-schema-yes-auth-with-additional-params-no-catalog.yaml
+++ /dev/null
@@ -1,28 +0,0 @@
-open_cli_schema_version: 1.0
-
-name: sample-cmd-yes-auth-no-catalog-extra-params
-
-description: sample
-
-
-info:
- product: open-cli
- service: test
- type: cmd
- author: Kanagaraj Manickam kanagaraj.manickam@huawei.com
-
-http:
-
- service:
- name: sample
- version: v1
- auth: testauth
- mode: catalog
-
- request:
- uri: /test
- method: GET
- success_codes:
- - 200
- result_map:
- name: ${name}
diff --git a/framework/src/test/resources/sample-test-schema-yes-auth-yes-catalog.yaml b/framework/src/test/resources/sample-test-schema-yes-auth-yes-catalog.yaml
deleted file mode 100644
index 4efd4c51..00000000
--- a/framework/src/test/resources/sample-test-schema-yes-auth-yes-catalog.yaml
+++ /dev/null
@@ -1,28 +0,0 @@
-open_cli_schema_version: 1.0
-
-name: sample-cmd-no-auth-no-catalog
-
-description: sample
-
-
-info:
- product: open-cli
- service: test
- type: cmd
- author: Kanagaraj Manickam kanagaraj.manickam@huawei.com
-
-http:
-
- service:
- name: sample
- version: v1
- auth: basic
- mode: catalog
-
- request:
- uri: /test
- method: GET
- success_codes:
- - 200
- result_map:
- name: ${name}
diff --git a/framework/src/test/resources/schema-validate-http.yaml b/framework/src/test/resources/schema-validate-http.yaml
deleted file mode 100644
index 7bdafc56..00000000
--- a/framework/src/test/resources/schema-validate-http.yaml
+++ /dev/null
@@ -1,98 +0,0 @@
-open_cli_schema_version: 1.0
-description: Register microservice into Onap
-name: schema-validate
-info:
- product: open-cli
- service: test
- type: cmd
- author: Kanagaraj Manickam kanagaraj.manickam@huawei.com
-
-parameters:
- - name: service-name1
- description: Oclip service name
- type: string
- short_option: x
- long_option: service-name
- is_optional: false
- - name: service-version
- description: Oclip service version
- type: string
- short_option: x
- long_option: service-version
- is_optional: false
- - name: service-url
- description: Oclip service base url
- type: url1
- short_option: u
- long_option: service-url
- is_optional: false1
- - name: status
- description: Oclip service status
- type: digit
- short_option: z
- long_option: service-version
- is_optional: true
- default_value: 1
- - name: node-ip
- description: Oclip service running node IP
- type: string
- - name: node-port
- description: Oclip service running node port
- type: string
- - name: create-or-update
- description: Oclip service create or update
- type: cfbcv
- default_value: true
-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: status
- description: Oclip service base url
- scope: short
- type: url
- - name: status
- description: Oclip service status
- scope: short1
- type: digit
- - name: nodes
- description: Oclip service running nodes
- scope: long
- type: string
- - name: location
- description: Oclip service location
- scope: long
- type: url
-http:
- service:
- name: msb
- version: v1
- type: direct
- auth: none
- request:
- uri: /services
- method: POST1
- body: '{"serviceName":"${service}","serviceName":"${service-name}","version":"${service-version}","url":"${service-url}","protocol":"REST","visualRange":"1","lb_policy":"hash","nodes":[{"ip":"${node-ip}","port":"${node-port}","ttl":0}]}'
- headers:
- queries:
- createOrUpdate: ${create-or-update1}
- success_codes:
- - 201
- - 300
- result_map:
- name: $b{$.serviceName}
- version: $b{$.version}
- url: $b{$.url}
- status1: $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"}
-