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/fw/OnapCommandRegistrarTest.java2
-rw-r--r--framework/src/test/java/org/onap/cli/fw/cmd/OnapSchemaRefreshCommandTest.java18
-rw-r--r--framework/src/test/java/org/onap/cli/fw/cmd/OnapSchemaValidateCommandTest.java43
-rw-r--r--framework/src/test/java/org/onap/cli/fw/conf/OnapCommandConfgTest.java6
-rw-r--r--framework/src/test/java/org/onap/cli/fw/error/OnapCommandErrorTest.java10
-rw-r--r--framework/src/test/java/org/onap/cli/fw/http/HttpInputOutputTest.java4
-rw-r--r--framework/src/test/java/org/onap/cli/fw/http/OnapHttpConnectionTest.java14
-rw-r--r--framework/src/test/java/org/onap/cli/fw/input/OnapCommandParameterTest.java8
-rw-r--r--framework/src/test/java/org/onap/cli/fw/output/OnapCommandResultAttributeScopeTest.java4
-rw-r--r--framework/src/test/java/org/onap/cli/fw/output/OnapCommandResultTest.java8
-rw-r--r--framework/src/test/java/org/onap/cli/fw/output/print/OnapCommandPrintTest.java8
-rw-r--r--framework/src/test/java/org/onap/cli/fw/output/print/TableGeneratorTest.java6
-rw-r--r--framework/src/test/java/org/onap/cli/fw/schema/ValidateSchemaTest.java8
-rw-r--r--framework/src/test/resources/open-cli.properties39
14 files changed, 97 insertions, 81 deletions
diff --git a/framework/src/test/java/org/onap/cli/fw/OnapCommandRegistrarTest.java b/framework/src/test/java/org/onap/cli/fw/OnapCommandRegistrarTest.java
index 339a0f66..3f9f780d 100644
--- a/framework/src/test/java/org/onap/cli/fw/OnapCommandRegistrarTest.java
+++ b/framework/src/test/java/org/onap/cli/fw/OnapCommandRegistrarTest.java
@@ -25,12 +25,10 @@ import java.io.File;
import java.net.URL;
import org.junit.Before;
-import org.junit.Ignore;
import org.junit.Test;
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.error.OnapCommandRegistrationFailed;
public class OnapCommandRegistrarTest {
diff --git a/framework/src/test/java/org/onap/cli/fw/cmd/OnapSchemaRefreshCommandTest.java b/framework/src/test/java/org/onap/cli/fw/cmd/OnapSchemaRefreshCommandTest.java
index 7aedd42d..99f45190 100644
--- a/framework/src/test/java/org/onap/cli/fw/cmd/OnapSchemaRefreshCommandTest.java
+++ b/framework/src/test/java/org/onap/cli/fw/cmd/OnapSchemaRefreshCommandTest.java
@@ -16,13 +16,13 @@
package org.onap.cli.fw.cmd;
-import org.junit.Test;
-import org.onap.cli.fw.error.OnapCommandException;
-import org.onap.cli.fw.output.OnapCommandResultAttribute;
+import static org.junit.Assert.assertTrue;
import java.util.List;
-import static org.junit.Assert.assertTrue;
+import org.junit.Test;
+import org.onap.cli.fw.error.OnapCommandException;
+import org.onap.cli.fw.output.OnapCommandResultAttribute;
public class OnapSchemaRefreshCommandTest {
@@ -32,15 +32,11 @@ public class OnapSchemaRefreshCommandTest {
cmd.initializeSchema("schema-refresh.yaml");
cmd.execute();
- List<OnapCommandResultAttribute> oclipCommandResultAttribute = cmd.getResult()
+ List<OnapCommandResultAttribute> oclipCommandResultAttributes = cmd.getResult()
.getRecords();
- String s1Number = oclipCommandResultAttribute.get(0).getValues().get(0);
- String cmdName = oclipCommandResultAttribute.get(1).getValues().get(0);
- String cmdVer = oclipCommandResultAttribute.get(2).getValues().get(0);
- String cmdFile = oclipCommandResultAttribute.get(3).getValues().get(0);
- String version = oclipCommandResultAttribute.get(4).getValues().get(0);
- assertTrue(s1Number.equalsIgnoreCase("1"));
+ assertTrue(oclipCommandResultAttributes.size() > 1);
+
}
}
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 2355d668..8d8de2f7 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
@@ -16,49 +16,32 @@
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.input.OnapCommandParameter;
import org.onap.cli.fw.schema.ValidateSchemaTest;
+
public class OnapSchemaValidateCommandTest {
+ @Ignore
@Test
public void validateSchemaCommandTest1() throws OnapCommandException {
- OnapSchemaValidateCommand cmd = new OnapSchemaValidateCommand();
- cmd.initializeSchema("schema-validate.yaml");
- for (OnapCommandParameter param : cmd.getParameters()) {
- if ("host-username".equals(param.getName())) {
- param.setValue("test");
- } else if ("host-password".equals(param.getName())) {
- param.setValue("test");
- } else if ("host-url".equals(param.getName())) {
- param.setValue("test-url");
- } else if ("schema-location".equals(param.getName())) {
- param.setValue("schema-validate-pass.yaml");
- } else if ("internal-schema".equals(param.getName())) {
- param.setValue("true");
- }
- }
+ OnapCommand cmd = OnapCommandRegistrar.getRegistrar().get("schema-validate");
+ cmd.getParametersMap().get("schema-location").setValue("schema-validate-pass.yaml");
+ cmd.getParametersMap().get("internal-schema").setValue("true");
cmd.execute();
}
+ @Ignore
@Test
public void validateSchemaCommandTest2() throws OnapCommandException {
- OnapSchemaValidateCommand cmd = new OnapSchemaValidateCommand();
- cmd.initializeSchema("schema-validate.yaml");
- for (OnapCommandParameter param : cmd.getParameters()) {
- if ("host-username".equals(param.getName())) {
- param.setValue("test");
- } else if ("host-password".equals(param.getName())) {
- param.setValue("test");
- } else if ("host-url".equals(param.getName())) {
- param.setValue("test-url");
- } else if ("schema-location".equals(param.getName())) {
- param.setValue(
- ValidateSchemaTest.class.getClassLoader().getResource("schema-validate-pass.yaml").getFile());
- }
- }
+ OnapCommand cmd = OnapCommandRegistrar.getRegistrar().get("schema-validate");
+ cmd.getParametersMap().get("schema-location").setValue(
+ ValidateSchemaTest.class.getClassLoader().getResource("schema-validate-pass.yaml").getFile());
+ cmd.getParametersMap().get("internal-schema").setValue("true");
cmd.execute();
}
}
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 1a677707..2c25991b 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,12 +16,12 @@
package org.onap.cli.fw.conf;
-import org.junit.Assert;
-import org.junit.Test;
-
import java.io.IOException;
import java.util.Properties;
+import org.junit.Assert;
+import org.junit.Test;
+
public class OnapCommandConfgTest {
@Test
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 45560c4a..899f2e3b 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
@@ -94,9 +94,9 @@ public class OnapCommandErrorTest {
@Test
public void oclipCommandExecutorInfoMissingTest() {
- OnapCommandExecutorInfoMissing failed = new OnapCommandExecutorInfoMissing("Test");
+ OnapCommandInstantiationFailed failed = new OnapCommandInstantiationFailed("Test");
- assertEquals("0x6002::Command Test excutor info is missing from schema", failed.getMessage());
+ assertEquals("0x6002::Failed to instantiate the command plugin Test", failed.getMessage());
}
@Test
@@ -225,9 +225,9 @@ public class OnapCommandErrorTest {
@Test
public void oclipCommandParameterOptionConflictTest() {
- OnapCommandParameterOptionConflict failed = new OnapCommandParameterOptionConflict("option");
+ OnapCommandParameterOptionConflict failed = new OnapCommandParameterOptionConflict("test", "option");
- assertEquals("0x7006::Parameter option option is in conflict, only one option is allowed with given name",
+ assertEquals("0x7006::In test, Parameter option option is in conflict, only one option is allowed with given name",
failed.getMessage());
}
@@ -296,5 +296,5 @@ public class OnapCommandErrorTest {
OnapCommandInvalidCommandType failed = new OnapCommandInvalidCommandType("test");
assertEquals("0x3003::Command type test is invalid", failed.getMessage());
- }
+ }
}
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
index 900d72e8..0a3a817e 100644
--- a/framework/src/test/java/org/onap/cli/fw/http/HttpInputOutputTest.java
+++ b/framework/src/test/java/org/onap/cli/fw/http/HttpInputOutputTest.java
@@ -18,10 +18,10 @@ package org.onap.cli.fw.http;
import static org.junit.Assert.assertTrue;
-import org.junit.Test;
-
import java.util.HashMap;
+import org.junit.Test;
+
public class HttpInputOutputTest {
@Test
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
index ab00f90b..785092c2 100644
--- a/framework/src/test/java/org/onap/cli/fw/http/OnapHttpConnectionTest.java
+++ b/framework/src/test/java/org/onap/cli/fw/http/OnapHttpConnectionTest.java
@@ -17,11 +17,11 @@
package org.onap.cli.fw.http;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import mockit.Invocation;
-import mockit.Mock;
-import mockit.MockUp;
+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;
@@ -31,9 +31,9 @@ import org.junit.Before;
import org.junit.Test;
import org.onap.cli.fw.error.OnapCommandHttpFailure;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
+import mockit.Invocation;
+import mockit.Mock;
+import mockit.MockUp;
public class OnapHttpConnectionTest {
HttpInput inp = null;
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 f2e9f0b3..44656f9f 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
@@ -16,15 +16,15 @@
package org.onap.cli.fw.input;
-import org.junit.Test;
-import org.onap.cli.fw.error.OnapCommandException;
-import org.onap.cli.fw.error.OnapCommandInvalidParameterValue;
+import static org.junit.Assert.assertTrue;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
-import static org.junit.Assert.assertTrue;
+import org.junit.Test;
+import org.onap.cli.fw.error.OnapCommandException;
+import org.onap.cli.fw.error.OnapCommandInvalidParameterValue;
public class OnapCommandParameterTest {
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 76d139a0..7ab3fe52 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
@@ -18,11 +18,11 @@ package org.onap.cli.fw.output;
import static org.junit.Assert.assertTrue;
+import java.util.Collections;
+
import org.junit.Test;
import org.onap.cli.fw.input.ParameterType;
-import java.util.Collections;
-
public class OnapCommandResultAttributeScopeTest {
@Test
public void oclipCommandResultAttributeTest() {
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 dddab1bc..9c832c24 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
@@ -19,15 +19,15 @@ package org.onap.cli.fw.output;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
import org.junit.Ignore;
import org.junit.Test;
import org.onap.cli.fw.error.OnapCommandException;
import org.onap.cli.fw.input.ParameterType;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
public class OnapCommandResultTest {
@Test
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 ae17d6d4..84c868b3 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
@@ -18,15 +18,15 @@ package org.onap.cli.fw.output.print;
import static org.junit.Assert.assertEquals;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
import org.junit.Ignore;
import org.junit.Test;
import org.onap.cli.fw.error.OnapCommandOutputPrintingFailed;
import org.onap.cli.fw.output.PrintDirection;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
public class OnapCommandPrintTest {
@Test
diff --git a/framework/src/test/java/org/onap/cli/fw/output/print/TableGeneratorTest.java b/framework/src/test/java/org/onap/cli/fw/output/print/TableGeneratorTest.java
index f9ae0717..58ff4751 100644
--- a/framework/src/test/java/org/onap/cli/fw/output/print/TableGeneratorTest.java
+++ b/framework/src/test/java/org/onap/cli/fw/output/print/TableGeneratorTest.java
@@ -18,13 +18,13 @@ package org.onap.cli.fw.output.print;
import static org.junit.Assert.assertEquals;
-import org.junit.Before;
-import org.junit.Test;
-
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+import org.junit.Before;
+import org.junit.Test;
+
public class TableGeneratorTest {
private TableGenerator table;
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 22c36c3d..a900fe6d 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
@@ -16,6 +16,10 @@
package org.onap.cli.fw.schema;
+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;
@@ -23,10 +27,6 @@ import org.onap.cli.fw.error.OnapCommandException;
import org.onap.cli.fw.error.OnapCommandInvalidSchema;
import org.onap.cli.fw.utils.OnapCommandSchemaLoaderUtils;
-import java.util.List;
-
-import static org.junit.Assert.assertTrue;
-
public class ValidateSchemaTest {
@Test(expected = OnapCommandInvalidSchema.class)
diff --git a/framework/src/test/resources/open-cli.properties b/framework/src/test/resources/open-cli.properties
new file mode 100644
index 00000000..23ba7800
--- /dev/null
+++ b/framework/src/test/resources/open-cli.properties
@@ -0,0 +1,39 @@
+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
+