diff options
5 files changed, 167 insertions, 1 deletions
diff --git a/profiles/http/pom.xml b/profiles/http/pom.xml index 398ed8e1..bbd85082 100644 --- a/profiles/http/pom.xml +++ b/profiles/http/pom.xml @@ -15,7 +15,7 @@ See the License for the specific language governing permissions and limitations under the License. --> - + <project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <modelVersion>4.0.0</modelVersion> @@ -71,6 +71,12 @@ <scope>test</scope> </dependency> <dependency> + <groupId>org.onap.cli</groupId> + <artifactId>cli-main</artifactId> + <version>${project.version}</version> + <scope>test</scope> + </dependency> + <dependency> <groupId>org.jmockit</groupId> <artifactId>jmockit-coverage</artifactId> <version>1.19</version> diff --git a/profiles/http/src/test/java/org/onap/cli/fw/http/schema/ValidateSchemaTest.java b/profiles/http/src/test/java/org/onap/cli/fw/http/schema/ValidateSchemaTest.java index ddf30ba7..0bf073e7 100644 --- a/profiles/http/src/test/java/org/onap/cli/fw/http/schema/ValidateSchemaTest.java +++ b/profiles/http/src/test/java/org/onap/cli/fw/http/schema/ValidateSchemaTest.java @@ -23,7 +23,9 @@ import java.util.List; import org.junit.Test; import org.onap.cli.fw.cmd.OnapCommand; import org.onap.cli.fw.error.OnapCommandException; +import org.onap.cli.fw.registrar.OnapCommandRegistrar; import org.onap.cli.fw.schema.OnapCommandSchemaLoader; +import org.onap.cli.main.OnapCli; public class ValidateSchemaTest { @Test @@ -36,4 +38,13 @@ public class ValidateSchemaTest { List<String> errorList1 = OnapCommandSchemaLoader.loadSchema(cmd1, "schema-validate-http.yaml", true, true); assertTrue(errorList1.size() > 0); } + + @Test + public void testVerify() throws OnapCommandException { + OnapCommandRegistrar.getRegistrar().setEnabledProductVersion("open-cli"); + OnapCli onapCli = new OnapCli(new String[]{"sample-test-verify", "--verify"}); + onapCli.handle(); + + //mrkanag though it pass, when ran alone, It fails during mvn test phase, check it + } } diff --git a/profiles/http/src/test/resources/open-cli-sample/sample-test-verify-schema-1.1-moco.json b/profiles/http/src/test/resources/open-cli-sample/sample-test-verify-schema-1.1-moco.json new file mode 100644 index 00000000..f5e4e444 --- /dev/null +++ b/profiles/http/src/test/resources/open-cli-sample/sample-test-verify-schema-1.1-moco.json @@ -0,0 +1,34 @@ +[{ + "request" : { + "method" : "get", + "uri" : "/aai/v11/cloud-infrastructure/cloud-regions", + "headers" : { + "Authorization" : "Basic QUFJOkFBSQ==", + "X-FromAppId" : "onap-cli", + "Accept" : "application/json", + "X-TransactionId" : "req-77c08aa0-662e-4d32-9206-bd569c3bf61b", + "Content-Type" : "application/json" + }, + "json" : null + }, + "response" : { + "status" : 200, + "json" : { + "cloud-region" : [ { + "cloud-owner" : "huawei-cloud", + "cloud-region-id" : "bangalore", + "sriov-automation" : false, + "resource-version" : "1509027332165" + }, { + "cloud-owner" : "Rackspace", + "cloud-region-id" : "RegionOne", + "cloud-type" : "SharedNode", + "owner-defined-type" : "OwnerType", + "cloud-region-version" : "v1", + "cloud-zone" : "CloudZone", + "sriov-automation" : false, + "resource-version" : "1508827902543" + } ] + } + } +}]
\ No newline at end of file diff --git a/profiles/http/src/test/resources/open-cli-sample/sample-test-verify-schema-1.1-sample.yaml b/profiles/http/src/test/resources/open-cli-sample/sample-test-verify-schema-1.1-sample.yaml new file mode 100644 index 00000000..ffc59961 --- /dev/null +++ b/profiles/http/src/test/resources/open-cli-sample/sample-test-verify-schema-1.1-sample.yaml @@ -0,0 +1,43 @@ +# Copyright 2017-18 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. + +open_cli_sample_version: 1.0 +name: sample-test-verify +version: open-cli +samples: + sample1: + name: sample-test-verify + input: + moco: sample-test-verify-schema-1.1-moco.json + output: | + +--------------+------------+------------------+ + |cloud |region |resource-version | + +--------------+------------+------------------+ + |huawei-cloud |bangalore |1509027332165 | + +--------------+------------+------------------+ + |Rackspace |RegionOne |1508827902543 | + +--------------+------------+------------------+ + + sample2: + name: sample-test-verify + input: + moco: sample-test-verify-schema-1.1-moco.json + output: | + +--------------+------------+------------------+ + |cloud |region |resource-version | + +--------------+------------+------------------+ + |huawei-cloud |bangalore |1509027332165 | + +--------------+------------+------------------+ + |Rackspace |RegionOne |1508827902543 | + +--------------+------------+------------------+ diff --git a/profiles/http/src/test/resources/open-cli-schema/sample-test-verify-schema-1.1.yaml b/profiles/http/src/test/resources/open-cli-schema/sample-test-verify-schema-1.1.yaml new file mode 100644 index 00000000..5e3548ed --- /dev/null +++ b/profiles/http/src/test/resources/open-cli-schema/sample-test-verify-schema-1.1.yaml @@ -0,0 +1,72 @@ +# Copyright 2017-18 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. + +open_cli_schema_version: 1.0 +name: sample-test-verify +description: Oclip sample command to test the command features +info: + product: open-cli + service: test + type: cmd + +results: + direction: landscape + attributes: + - name: cloud + description: Onap cloud + scope: short + type: string + - name: region + description: Onap cloud region + scope: short + type: string + - name: tenant + description: Onap cloud tenat + scope: long + type: string + - name: tenant-id + description: Onap cloud tenat id + scope: long + type: string + - name: customer + description: Onap cloud customer + scope: long + type: string + - name: service + description: Onap cloud service + scope: long + type: string + - name: resource-version + description: Onap cloud resource version + scope: short + type: string +http: + service: + auth: basic + mode: direct + request: + uri: /aai/v11/cloud-infrastructure/cloud-regions + method: GET + success_codes: + - 200 + result_map: + cloud: $b{cloud-region.[*].cloud-owner} + region: $b{cloud-region.[*].cloud-region-id} + resource-version: $b{cloud-region.[*].resource-version} + tenant: $b{cloud-region.[*].tenants.tenant.[*].tenant-name} + tenant-id: $b{cloud-region.[*].tenants.tenant.[*].tenant-id} + customer: $b{cloud-region.[*].tenants.tenant.[*].relationship-list.relationship.[*].relationship-data.[?(@.relationship-key == 'customer.global-customer-id')].relationship-value} + service: $b{cloud-region.[*].tenants.tenant.[*].relationship-list.relationship.[*].relationship-data.[?(@.relationship-key == 'service-subscription.service-type')].relationship-value} + sample_response: + body: '{"cloud-region":[{"cloud-owner":"Rackspace","cloud-region-id":"RegionOne","cloud-type":"SharedNode","owner-defined-type":"OwnerType","cloud-region-version":"v1","cloud-zone":"CloudZone","resource-version":"1500729864","tenants":{"tenant":[{"tenant-id":"e69e6d64b44347509c3fc512391f34a6","tenant-name":"onap","resource-version":"1500729865","relationship-list":{"relationship":[{"related-to":"service-subscription","related-link":"https://192.168.17.12:8443/aai/v8/business/customers/customer/Demonstration/service-subscriptions/service-subscription/vFW/","relationship-data":[{"relationship-key":"customer.global-customer-id","relationship-value":"Demonstration"},{"relationship-key":"service-subscription.service-type","relationship-value":"vFW"}]},{"related-to":"service-subscription","related-link":"https://192.168.17.12:8443/aai/v8/business/customers/customer/Demonstration123/service-subscriptions/service-subscription/vFW/","relationship-data":[{"relationship-key":"customer.global-customer-id","relationship-value":"Demonstration123"},{"relationship-key":"service-subscription.service-type","relationship-value":"vFW"}]},{"related-to":"service-subscription","related-link":"https://192.168.17.12:8443/aai/v8/business/customers/customer/u1/service-subscriptions/service-subscription/vFW/","relationship-data":[{"relationship-key":"customer.global-customer-id","relationship-value":"u1"},{"relationship-key":"service-subscription.service-type","relationship-value":"vFW"}]},{"related-to":"service-subscription","related-link":"https://192.168.17.12:8443/aai/v8/business/customers/customer/u2/service-subscriptions/service-subscription/vFW/","relationship-data":[{"relationship-key":"customer.global-customer-id","relationship-value":"u2"},{"relationship-key":"service-subscription.service-type","relationship-value":"vFW"}]},{"related-to":"service-subscription","related-link":"https://192.168.17.12:8443/aai/v8/business/customers/customer/DemoCust_7151e36a-1a57-4993-b513-54134f2b8f19/service-subscriptions/service-subscription/vFW/","relationship-data":[{"relationship-key":"customer.global-customer-id","relationship-value":"DemoCust_7151e36a-1a57-4993-b513-54134f2b8f19"},{"relationship-key":"service-subscription.service-type","relationship-value":"vFW"}]},{"related-to":"service-subscription","related-link":"https://192.168.17.12:8443/aai/v8/business/customers/customer/Demonstration/service-subscriptions/service-subscription/vLB/","relationship-data":[{"relationship-key":"customer.global-customer-id","relationship-value":"Demonstration"},{"relationship-key":"service-subscription.service-type","relationship-value":"vLB"}]},{"related-to":"service-subscription","related-link":"https://192.168.17.12:8443/aai/v8/business/customers/customer/Linan/service-subscriptions/service-subscription/vFW/","relationship-data":[{"relationship-key":"customer.global-customer-id","relationship-value":"Linan"},{"relationship-key":"service-subscription.service-type","relationship-value":"vFW"}]},{"related-to":"service-subscription","related-link":"https://192.168.17.12:8443/aai/v8/business/customers/customer/Linan/service-subscriptions/service-subscription/vLB/","relationship-data":[{"relationship-key":"customer.global-customer-id","relationship-value":"Linan"},{"relationship-key":"service-subscription.service-type","relationship-value":"vLB"}]}]}}]}}]}' |