diff options
Diffstat (limited to 'framework/src/test')
10 files changed, 0 insertions, 253 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 |