aboutsummaryrefslogtreecommitdiffstats
path: root/framework/src/test/java/org/onap
diff options
context:
space:
mode:
authorKanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>2017-10-04 18:21:52 +0530
committerKanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>2017-11-20 11:32:51 +0530
commit3387ffb892b85a20ae44ec58a41e1f3f2cb084f0 (patch)
tree1546466ea4ec4b75c8eb7f7adfff19130b4be4f6 /framework/src/test/java/org/onap
parent01dbd2dc5ac04c7018d3a474c329b40f33d3c400 (diff)
Modify validate to include sample plugin
Issue-Id: CLI-66 Change-Id: I3397cd29835c5ac3a95a7f0f80fcee5d1e49de99 Signed-off-by: Kanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>
Diffstat (limited to 'framework/src/test/java/org/onap')
-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
2 files changed, 0 insertions, 205 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);
- }
-}