Modify validate to include sample plugin 47/24347/4
authorKanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>
Wed, 4 Oct 2017 12:51:52 +0000 (18:21 +0530)
committerKanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>
Mon, 20 Nov 2017 06:02:51 +0000 (11:32 +0530)
Issue-Id: CLI-66

Change-Id: I3397cd29835c5ac3a95a7f0f80fcee5d1e49de99
Signed-off-by: Kanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>
12 files changed:
framework/src/test/java/org/onap/cli/fw/TestCommandValidate.java [deleted file]
framework/src/test/java/org/onap/cli/fw/defaultParameter/TestDefaultParameterSection.java [deleted file]
framework/src/test/resources/sample-test-exclude-param.yaml [deleted file]
framework/src/test/resources/sample-test-import-def-param-false.yaml [deleted file]
framework/src/test/resources/sample-test-include-exclude.yaml [deleted file]
framework/src/test/resources/sample-test-include-param.yaml [deleted file]
framework/src/test/resources/sample-test-invalid-default-parameter.yaml [deleted file]
framework/src/test/resources/sample-test-invalid-default-params-not-exist.yaml [deleted file]
framework/src/test/resources/sample-test-invalid-exclude-noauth.yaml [deleted file]
framework/src/test/resources/sample-test-invalid-include-noauth.yaml [deleted file]
validate/validation/pom.xml
validate/validation/src/test/java/org/onap/cli/validation/OnapValidationTest.java

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 (file)
index 1f83046..0000000
+++ /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 (file)
index b059079..0000000
+++ /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 (file)
index 7aed55c..0000000
+++ /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 (file)
index 2eb92ef..0000000
+++ /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 (file)
index 3568372..0000000
+++ /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 (file)
index 38e5149..0000000
+++ /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 (file)
index 242bdbf..0000000
+++ /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 (file)
index d8bea68..0000000
+++ /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 (file)
index c158411..0000000
+++ /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 (file)
index 1dda3b9..0000000
+++ /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
index 3e0cf59..8c204d8 100644 (file)
         </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>
index 71d015b..6a6d382 100644 (file)
@@ -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"});
+                }
+            }
         }
     }