summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--framework/src/test/java/org/onap/cli/fw/TestCommandValidate.java57
-rw-r--r--framework/src/test/java/org/onap/cli/fw/defaultParameter/TestDefaultParameterSection.java148
-rw-r--r--framework/src/test/resources/sample-test-exclude-param.yaml5
-rw-r--r--framework/src/test/resources/sample-test-import-def-param-false.yaml2
-rw-r--r--framework/src/test/resources/sample-test-include-exclude.yaml9
-rw-r--r--framework/src/test/resources/sample-test-include-param.yaml6
-rw-r--r--framework/src/test/resources/sample-test-invalid-default-parameter.yaml12
-rw-r--r--framework/src/test/resources/sample-test-invalid-default-params-not-exist.yaml4
-rw-r--r--framework/src/test/resources/sample-test-invalid-exclude-noauth.yaml4
-rw-r--r--framework/src/test/resources/sample-test-invalid-include-noauth.yaml6
-rw-r--r--validate/validation/pom.xml18
-rw-r--r--validate/validation/src/test/java/org/onap/cli/validation/OnapValidationTest.java17
12 files changed, 14 insertions, 274 deletions
diff --git a/framework/src/test/java/org/onap/cli/fw/TestCommandValidate.java b/framework/src/test/java/org/onap/cli/fw/TestCommandValidate.java
deleted file mode 100644
index 1f830464..00000000
--- a/framework/src/test/java/org/onap/cli/fw/TestCommandValidate.java
+++ /dev/null
@@ -1,57 +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;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.onap.cli.fw.error.OnapCommandException;
-import org.onap.cli.fw.error.OnapCommandParameterMissing;
-import org.onap.cli.fw.input.OnapCommandParameter;
-import org.onap.cli.fw.utils.OnapCommandUtils;
-
-public class TestCommandValidate {
-
- OnapCommand cmd;
-
- @Before
- public void before() {
- cmd = new OnapCommand() {
- @Override
- protected void run() throws OnapCommandException {}
- };
- }
-
- @Test
- public void testNoAuthArgumentTrue() throws OnapCommandException {
-
- OnapCommandUtils.loadSchema(cmd, "sample-test-include-param.yaml", true, false);
-
- OnapCommandParameter noAuthParam = cmd.getParameters().stream().filter(p -> p.getName().equalsIgnoreCase("no-auth")).findFirst().get();
- noAuthParam.setValue(true);
- OnapCommandParameter msbParam = cmd.getParameters().stream().filter(p -> p.getName().equalsIgnoreCase("host-url")).findFirst().get();
- msbParam.setValue("localhost://msbip:msb:port");
- cmd.validate();
- }
-
- @Test(expected = OnapCommandParameterMissing.class)
- public void testNoAuthArgFalse() throws OnapCommandException {
- OnapCommandUtils.loadSchema(cmd, "sample-test-include-param.yaml", true, false);
- OnapCommandParameter msbParam = cmd.getParameters().stream().filter(p -> p.getName().equalsIgnoreCase("host-url")).findFirst().get();
- msbParam.setValue("");
- cmd.validate();
- }
-}
diff --git a/framework/src/test/java/org/onap/cli/fw/defaultParameter/TestDefaultParameterSection.java b/framework/src/test/java/org/onap/cli/fw/defaultParameter/TestDefaultParameterSection.java
deleted file mode 100644
index b0590791..00000000
--- a/framework/src/test/java/org/onap/cli/fw/defaultParameter/TestDefaultParameterSection.java
+++ /dev/null
@@ -1,148 +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.defaultParameter;
-
-import org.junit.Test;
-import org.onap.cli.fw.OnapCommand;
-import org.onap.cli.fw.error.OnapCommandException;
-import org.onap.cli.fw.error.OnapCommandInvalidDefaultParameter;
-import org.onap.cli.fw.error.OnapCommandInvalidSchema;
-import org.onap.cli.fw.input.OnapCommandParameter;
-import org.onap.cli.fw.utils.OnapCommandUtils;
-
-import java.util.List;
-import java.util.stream.Collectors;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-
-public class TestDefaultParameterSection {
- @Test
- public void checkOnlyInclude() throws OnapCommandException {
- OnapCommand cmd = new OnapCommand() {
- @Override
- protected void run() throws OnapCommandException {}
- };
-
- OnapCommandUtils.loadSchema(cmd, "sample-test-include-param.yaml", true, false);
- List<String> parameters = cmd.getParameters().stream().map(p -> p.getName()).collect(Collectors.toList());
- assertTrue(parameters.contains("host-username"));
- assertTrue(parameters.contains("host-password"));
- assertTrue(parameters.contains("host-url"));
- }
-
- @Test
- public void checkOnlyExclude() throws OnapCommandException {
- OnapCommand cmd = new OnapCommand() {
- @Override
- protected void run() throws OnapCommandException {}
- };
-
- OnapCommandUtils.loadSchema(cmd, "sample-test-exclude-param.yaml", true, false);
- List<String> parameters = cmd.getParameters().stream().map(p -> p.getName()).collect(Collectors.toList());
- assertTrue(parameters.contains("host-username"));
- assertTrue(parameters.contains("host-password"));
- assertTrue(parameters.contains("host-url"));
- assertFalse(parameters.contains("long"));
- assertFalse(parameters.contains("format"));
- assertTrue(parameters.contains("debug"));
- }
-
- @Test
- public void checkBothIncludeAndExclude() throws OnapCommandException {
- OnapCommand cmd = new OnapCommand() {
- @Override
- protected void run() throws OnapCommandException {}
- };
-
- OnapCommandUtils.loadSchema(cmd, "sample-test-include-exclude.yaml", true, false);
- List<String> parameters = cmd.getParameters().stream().map(p -> p.getName()).collect(Collectors.toList());
-
- assertTrue(parameters.contains("host-username"));
- assertTrue(parameters.contains("host-password"));
- assertTrue(parameters.contains("host-url"));
- }
-
- @Test
- public void checkDefaultSectionAbsent() throws OnapCommandException {
- OnapCommand cmd = new OnapCommand() {
- @Override
- protected void run() throws OnapCommandException {}
- };
-
- OnapCommandUtils.loadSchema(cmd, "onap-test-schema.yaml", true, false);
- List<String> parameters = cmd.getParameters().stream().map(p -> p.getName()).collect(Collectors.toList());
-
- assertFalse(parameters.contains("host-username"));
- assertFalse(parameters.contains("host-password"));
- assertTrue(parameters.contains("host-url"));
- assertTrue(parameters.contains("debug"));
- assertTrue(parameters.contains("long"));
- assertTrue(parameters.contains("format"));
- }
-
- @Test(expected = OnapCommandInvalidDefaultParameter.class)
- public void checkInvalidDefaultArgument() throws OnapCommandException {
- OnapCommand cmd = new OnapCommand() {
- @Override
- protected void run() throws OnapCommandException {}
- };
-
- OnapCommandUtils.loadSchema(cmd, "sample-test-invalid-default-parameter.yaml", true, false);
- }
-
- @Test(expected = OnapCommandInvalidDefaultParameter.class)
- public void checkInvalidDefaultArgumentNotExist() throws OnapCommandException {
- OnapCommand cmd = new OnapCommand() {
- @Override
- protected void run() throws OnapCommandException {}
- };
-
- OnapCommandUtils.loadSchema(cmd, "sample-test-invalid-default-params-not-exist.yaml", true, false);
- }
-
- @Test(expected = OnapCommandInvalidSchema.class)
- public void checkDefaltwithNoExcludeAndInclude() throws OnapCommandException {
- OnapCommand cmd = new OnapCommand() {
- @Override
- protected void run() throws OnapCommandException {}
- };
-
- OnapCommandUtils.loadSchema(cmd, "sample-test-import-def-param-false.yaml", true, false);
- }
-
- @Test(expected = OnapCommandInvalidDefaultParameter.class)
- public void checkInvalidIncludeNoAuth() throws OnapCommandException {
- OnapCommand cmd = new OnapCommand() {
- @Override
- protected void run() throws OnapCommandException {}
- };
-
- OnapCommandUtils.loadSchema(cmd, "sample-test-invalid-include-noauth.yaml", true, false);
- }
-
- @Test(expected = OnapCommandInvalidDefaultParameter.class)
- public void checkInvalidExcludeNoAuth() throws OnapCommandException {
- OnapCommand cmd = new OnapCommand() {
- @Override
- protected void run() throws OnapCommandException {}
- };
-
- OnapCommandUtils.loadSchema(cmd, "sample-test-invalid-exclude-noauth.yaml", true, false);
- }
-}
diff --git a/framework/src/test/resources/sample-test-exclude-param.yaml b/framework/src/test/resources/sample-test-exclude-param.yaml
deleted file mode 100644
index 7aed55cf..00000000
--- a/framework/src/test/resources/sample-test-exclude-param.yaml
+++ /dev/null
@@ -1,5 +0,0 @@
-open_cli_schema_version: 1.0
-default_parameters:
- exclude:
- - long
- - format
diff --git a/framework/src/test/resources/sample-test-import-def-param-false.yaml b/framework/src/test/resources/sample-test-import-def-param-false.yaml
deleted file mode 100644
index 2eb92ef3..00000000
--- a/framework/src/test/resources/sample-test-import-def-param-false.yaml
+++ /dev/null
@@ -1,2 +0,0 @@
-open_cli_schema_version: 1.0
-default_parameters:
diff --git a/framework/src/test/resources/sample-test-include-exclude.yaml b/framework/src/test/resources/sample-test-include-exclude.yaml
deleted file mode 100644
index 3568372b..00000000
--- a/framework/src/test/resources/sample-test-include-exclude.yaml
+++ /dev/null
@@ -1,9 +0,0 @@
-open_cli_schema_version: 1.0
-default_parameters:
- include:
- - host-username
- - host-password
- - host-url
- - no-auth
- exclude:
- - long
diff --git a/framework/src/test/resources/sample-test-include-param.yaml b/framework/src/test/resources/sample-test-include-param.yaml
deleted file mode 100644
index 38e5149e..00000000
--- a/framework/src/test/resources/sample-test-include-param.yaml
+++ /dev/null
@@ -1,6 +0,0 @@
-open_cli_schema_version: 1.0
-default_parameters:
- include:
- - host-username
- - host-password
- - no-auth
diff --git a/framework/src/test/resources/sample-test-invalid-default-parameter.yaml b/framework/src/test/resources/sample-test-invalid-default-parameter.yaml
deleted file mode 100644
index 242bdbfb..00000000
--- a/framework/src/test/resources/sample-test-invalid-default-parameter.yaml
+++ /dev/null
@@ -1,12 +0,0 @@
-open_cli_schema_version: 1.0
-default_parameters:
- exclude:
- - invalid-param
-parameters:
- - name: invalid-param
- type: bool
- description: Onap 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-invalid-default-params-not-exist.yaml b/framework/src/test/resources/sample-test-invalid-default-params-not-exist.yaml
deleted file mode 100644
index d8bea682..00000000
--- a/framework/src/test/resources/sample-test-invalid-default-params-not-exist.yaml
+++ /dev/null
@@ -1,4 +0,0 @@
-open_cli_schema_version: 1.0
-default_parameters:
- exclude:
- - invalid-param-1 \ No newline at end of file
diff --git a/framework/src/test/resources/sample-test-invalid-exclude-noauth.yaml b/framework/src/test/resources/sample-test-invalid-exclude-noauth.yaml
deleted file mode 100644
index c1584116..00000000
--- a/framework/src/test/resources/sample-test-invalid-exclude-noauth.yaml
+++ /dev/null
@@ -1,4 +0,0 @@
-open_cli_schema_version: 1.0
-default_parameters:
- exclude:
- - host-username \ No newline at end of file
diff --git a/framework/src/test/resources/sample-test-invalid-include-noauth.yaml b/framework/src/test/resources/sample-test-invalid-include-noauth.yaml
deleted file mode 100644
index 1dda3b96..00000000
--- a/framework/src/test/resources/sample-test-invalid-include-noauth.yaml
+++ /dev/null
@@ -1,6 +0,0 @@
-open_cli_schema_version: 1.0
-service:
- auth: none
-default_parameters:
- include:
- - host-username \ No newline at end of file
diff --git a/validate/validation/pom.xml b/validate/validation/pom.xml
index 3e0cf59d..8c204d87 100644
--- a/validate/validation/pom.xml
+++ b/validate/validation/pom.xml
@@ -50,24 +50,10 @@
</dependency>
<dependency>
<groupId>org.onap.cli</groupId>
- <artifactId>cli-plugins-msb</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.onap.cli</groupId>
- <artifactId>cli-plugins-sdc</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.onap.cli</groupId>
- <artifactId>cli-plugins-aai</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.onap.cli</groupId>
- <artifactId>cli-plugins-so</artifactId>
+ <artifactId>cli-plugins-sample</artifactId>
<version>${project.version}</version>
</dependency>
+
</dependencies>
<!-- <build>
<plugins>
diff --git a/validate/validation/src/test/java/org/onap/cli/validation/OnapValidationTest.java b/validate/validation/src/test/java/org/onap/cli/validation/OnapValidationTest.java
index 71d015b5..6a6d3823 100644
--- a/validate/validation/src/test/java/org/onap/cli/validation/OnapValidationTest.java
+++ b/validate/validation/src/test/java/org/onap/cli/validation/OnapValidationTest.java
@@ -57,12 +57,19 @@ public class OnapValidationTest {
}
@Test
- public void validateCommandSchemas() throws IOException, OnapCommandException {
- OnapCommandRegistrar.getRegistrar().setEnabledProductVersion("cli-1.0");
- for (ExternalSchema sch : OnapCommandRegistrar.getRegistrar().listCommandInfo()) {
- System.out.println(
+ public void validateCommandsResult() throws IOException, OnapCommandException {
+ for (String version: OnapCommandRegistrar.getRegistrar().getAvailableProductVersions()) {
+ OnapCommandRegistrar.getRegistrar().setEnabledProductVersion(version);
+ System.out.println(version);
+ System.out.println("==========================\n\n");
+ for (ExternalSchema sch : OnapCommandRegistrar.getRegistrar().listCommandInfo()) {
+ if (sch.getCmdVersion().equals(version)) {
+ System.out.println(
"************************* validate '" + sch.getCmdName() + "' *******************************");
- this.handle(new String[] { "schema-validate", "-l", sch.getSchemaName(), "-i"});
+ OnapCommandRegistrar.getRegistrar().setEnabledProductVersion("cli-1.0");
+ this.handle(new String[] { "schema-validate", "-l", sch.getSchemaName(), "-i"});
+ }
+ }
}
}