aboutsummaryrefslogtreecommitdiffstats
path: root/framework/src/test/java/org
diff options
context:
space:
mode:
Diffstat (limited to 'framework/src/test/java/org')
-rw-r--r--framework/src/test/java/org/onap/cli/cmd/sample/OnapCommandSample.java2
-rw-r--r--framework/src/test/java/org/onap/cli/fw/OnapCommandRegistrarTest.java20
-rw-r--r--framework/src/test/java/org/onap/cli/fw/error/OnapCommandErrorTest.java6
-rw-r--r--framework/src/test/java/org/onap/cli/fw/utils/OnapCommandUtilsTest.java6
-rw-r--r--framework/src/test/java/org/onap/cli/fw/utils/OpenCommandRegistrarTest.java4
5 files changed, 21 insertions, 17 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 69714ad7..16c92185 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
@@ -25,7 +25,7 @@ import org.onap.cli.fw.error.OnapCommandExecutionFailed;
* This command helps to test the Command functionalities.
*
*/
-@OnapCommandSchema(name = "sample-test", schema = "sample-test-schema.yaml")
+@OnapCommandSchema(name = "sample-test", version="cli-1.0", schema = "sample-test-schema.yaml")
public class OnapCommandSample extends OnapCommand {
public OnapCommandSample() {
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 a076eee6..840a75d7 100644
--- a/framework/src/test/java/org/onap/cli/fw/OnapCommandRegistrarTest.java
+++ b/framework/src/test/java/org/onap/cli/fw/OnapCommandRegistrarTest.java
@@ -50,7 +50,7 @@ public class OnapCommandRegistrarTest {
if (!file.exists()) {
file.mkdir();
} else {
- File f1 = new File(path + "/external-schema.json");
+ File f1 = new File(path + "/cli-schema.json");
f1.delete();
}
}
@@ -60,7 +60,7 @@ public class OnapCommandRegistrarTest {
public void registerTest() throws OnapCommandException {
OnapCommand test = new OnapCommandTest();
Class<OnapCommand> cmd = (Class<OnapCommand>) test.getClass();
- registerar.register("Test", cmd);
+ registerar.register("Test", "cli-1.0", cmd);
OnapCommand cc = registerar.get("Test");
assertTrue(cmd == cc.getClass());
@@ -71,7 +71,7 @@ public class OnapCommandRegistrarTest {
public void cmdTestSchema() throws OnapCommandException {
OnapCommand test = new OnapCommandTest();
Class<OnapCommand> cmd = (Class<OnapCommand>) test.getClass();
- registerar.register("Test", cmd);
+ registerar.register("Test", "cli-1.0", cmd);
OnapCommand cc = registerar.get("Test");
}
@@ -82,14 +82,16 @@ public class OnapCommandRegistrarTest {
registerar.get("Test1");
fail("This should have thrown an exception");
} catch (OnapCommandNotFound e) {
- assertEquals(e.getMessage(), "0x0011::Command Test1 is not registered");
+ //pass // NOSONAR
+ } catch (Exception e) {
+ fail("This should have thrown an OnapCommandNotFound exception");
}
}
@Test
public void onapCommandRegistrationFailedTest() throws OnapCommandException {
- @OnapCommandSchema(name = "Test2", schema = "sample-test-schema.yaml")
+ @OnapCommandSchema(name = "Test2", version= "cli-1.0", schema = "sample-test-schema.yaml")
class Test extends OnapCommand {
@Override
@@ -102,7 +104,7 @@ public class OnapCommandRegistrarTest {
OnapCommand com = new Test();
Class<OnapCommand> cmd = (Class<OnapCommand>) com.getClass();
try {
- registerar.register("Test2", cmd);
+ registerar.register("Test2", "cli-1.0", cmd);
registerar.get("Test2");
fail("This should have thrown an exception");
} catch (OnapCommandRegistrationFailed e) {
@@ -116,7 +118,7 @@ public class OnapCommandRegistrarTest {
OnapCommand test = new OnapCommandTest1();
Class<OnapCommand> cmd = (Class<OnapCommand>) test.getClass();
registerar = new OnapCommandRegistrar();
- registerar.register("test1", cmd);
+ registerar.register("test1", "cli-1.0", cmd);
String help = registerar.getHelp();
assertNotNull(help);
}
@@ -139,7 +141,7 @@ public class OnapCommandRegistrarTest {
}
}
-@OnapCommandSchema(name = OnapCommandTest.CMD_NAME, schema = "sample-test-schema.yaml")
+@OnapCommandSchema(name = OnapCommandTest.CMD_NAME, version = "cli-1.0", schema = "sample-test-schema.yaml")
class OnapCommandTest extends OnapCommand {
public OnapCommandTest() {
@@ -154,7 +156,7 @@ class OnapCommandTest extends OnapCommand {
}
-@OnapCommandSchema(name = OnapCommandTest1.CMD_NAME, schema = "test-schema.yaml")
+@OnapCommandSchema(name = OnapCommandTest1.CMD_NAME, version = "cli-1.0", schema = "test-schema.yaml")
class OnapCommandTest1 extends OnapCommand {
public OnapCommandTest1() {
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 1d0c1a6b..0a388e5f 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
@@ -190,9 +190,11 @@ public class OnapCommandErrorTest {
@Test
public void onapCommandNotFoundTest() {
- OnapCommandNotFound failed = new OnapCommandNotFound("Test");
+ OnapCommandNotFound failed = new OnapCommandNotFound("Test", "1.0");
- assertEquals("0x0011::Command Test is not registered", failed.getMessage());
+ assertEquals("0x0011::Command Test is not available for product version 1.0."
+ + " so please check command name or product version set in env variable CLI_PRODUCT_VERSION or"
+ + " cli.product.version in onap.properties", failed.getMessage());
}
@Test
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 064576d8..5a992c6f 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
@@ -434,14 +434,14 @@ public class OnapCommandUtilsTest {
}
- @OnapCommandSchema(name = "sample-test", schema = "sample-test-schema.yaml")
+ @OnapCommandSchema(name = "sample-test", version = "cli-1.0", schema = "sample-test-schema.yaml")
class OnapCommandSample extends OnapCommand {
@Override
protected void run() throws OnapCommandException {
}
}
- @OnapCommandSchema(name = "sample-swagger-test", schema = "sample-test-schema-swagger.yaml")
+ @OnapCommandSchema(name = "sample-swagger-test", version = "cli-1.0", schema = "sample-test-schema-swagger.yaml")
class OnapSwaggerBasedCommandSample extends OnapSwaggerCommand {
@Override
@@ -449,7 +449,7 @@ public class OnapCommandUtilsTest {
}
}
- @OnapCommandSchema(name = "sample-http-test", schema = "sample-test-schema-http.yaml")
+ @OnapCommandSchema(name = "sample-http-test", version = "cli-1.0", schema = "sample-test-schema-http.yaml")
class OnapHttpCommandSample extends OnapHttpCommand {
@Override
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
index fa73ea6e..f7ba2355 100644
--- a/framework/src/test/java/org/onap/cli/fw/utils/OpenCommandRegistrarTest.java
+++ b/framework/src/test/java/org/onap/cli/fw/utils/OpenCommandRegistrarTest.java
@@ -34,9 +34,9 @@ public class OpenCommandRegistrarTest {
public void test() throws OnapCommandException {
OnapCommandRegistrar registrar = OnapCommandRegistrar.getRegistrar();
OnapCommand cmd = registrar.get("sample-test");
- registrar.listCommands();
- registrar.getAllCommandToSchemaMap();
cmd.printVersion();
+ registrar.listCommands();
+
}
}