diff options
author | ayalaben <Ayala.Benzvi@Amdocs.Com> | 2018-02-18 10:03:22 +0200 |
---|---|---|
committer | ayalaben <ayala.benzvi@amdocs.com> | 2018-02-18 10:03:22 +0200 |
commit | aad2781298db9c48ef4be167709b905af39bf9e4 (patch) | |
tree | 76d1e2ea2c6827d8d31de7bc5faaded2a2cf62f6 /openecomp-bdd/stepDefinitions | |
parent | 7866faac17505ef230f4e01c487a0b72621ee409 (diff) |
Flow Tests - delete item and Toggle
Change-Id: I73ed5fdc13891b3ad56ab5c8f00083bf8f7d13f3
Issue-ID: SDC-1034
Signed-off-by: ayalaben <ayala.benzvi@amdocs.com>
Diffstat (limited to 'openecomp-bdd/stepDefinitions')
-rw-r--r-- | openecomp-bdd/stepDefinitions/General_Steps.js | 12 | ||||
-rw-r--r-- | openecomp-bdd/stepDefinitions/Toggle_Steps.js | 48 | ||||
-rw-r--r-- | openecomp-bdd/stepDefinitions/Utils.js | 14 | ||||
-rw-r--r-- | openecomp-bdd/stepDefinitions/VLM_steps.js | 10 | ||||
-rw-r--r-- | openecomp-bdd/stepDefinitions/VSP_steps.js | 11 |
5 files changed, 95 insertions, 0 deletions
diff --git a/openecomp-bdd/stepDefinitions/General_Steps.js b/openecomp-bdd/stepDefinitions/General_Steps.js index 389112da84..bf35cb8499 100644 --- a/openecomp-bdd/stepDefinitions/General_Steps.js +++ b/openecomp-bdd/stepDefinitions/General_Steps.js @@ -172,6 +172,18 @@ Then('I want the following to fail with error code {string}', function(string) this.context.errorCode = string; }); + +/** + * @module ContextData + * @description Set this in order to check that the following Rest call will have the error message on the return data + * @exampleFile DeleteVLMCertified.feature + * @step I want the following to fail with error message {string} + **/ +Then('I want the following to fail with error message {string}', function(string) { + this.context.shouldFail = true; + this.context.errorMessage = string; +}); + /** * @module ZipData * @description Use this in order to extract a file from a zip file and to compare it to a local file (string comparison). diff --git a/openecomp-bdd/stepDefinitions/Toggle_Steps.js b/openecomp-bdd/stepDefinitions/Toggle_Steps.js new file mode 100644 index 0000000000..16bcc2afb9 --- /dev/null +++ b/openecomp-bdd/stepDefinitions/Toggle_Steps.js @@ -0,0 +1,48 @@ +/* +* Copyright © 2016-2018 European Support Limited +* +* 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. +*/ + +const {Then, When, Given} = require('cucumber'); +const assert = require('assert'); +const util = require('./Utils.js'); + + +/** + * @module Toggle + * @description this step will retrun and print to console the list of toggled features with their status + * @exampleFile Example_Toggle.feature + * @step I want to list Togglz + **/ + +Then('I want to list Togglz', function() { + let path = '/togglz' ; + return util.request(this.context, 'GET', path).then(result => { + const featureList = result.data.features; + console.log(featureList); + }); + +}); + +/** + * @module Toggle + * @description this step will set the status for all toggled features + * @exampleFile Example_Toggle.feature + * @step I want to set all Togglz to be "true/false" + **/ + +Then('I want to set all Togglz to be {string}', function(string) { + let path = '/togglz/state/' + string ; + return util.request(this.context, 'PUT', path); +});
\ No newline at end of file diff --git a/openecomp-bdd/stepDefinitions/Utils.js b/openecomp-bdd/stepDefinitions/Utils.js index e818e72b1b..ff49727409 100644 --- a/openecomp-bdd/stepDefinitions/Utils.js +++ b/openecomp-bdd/stepDefinitions/Utils.js @@ -53,6 +53,9 @@ function _request(context, method, path, data, isBinary=false, isVFCall=false) { reject('Status Code was ' + result.statusCode); } if (context.shouldFail && context.errorCode) { + if (typeof data === 'string' && data) { + data = JSON.parse(data); + } let errorCode = data.errorCode; let contextErrorCode = context.errorCode; context.errorCode = null; @@ -60,6 +63,17 @@ function _request(context, method, path, data, isBinary=false, isVFCall=false) { reject('Error Code was ' + errorCode + ' instead of ' + contextErrorCode); } } + if (context.shouldFail && context.errorMessage) { + if (typeof data === 'string' && data) { + data = JSON.parse(data); + } + let errorMessage = data.message; + let contextErrorMessage = context.errorMessage; + context.errorMessage = null; + if (errorMessage !== contextErrorMessage) { + reject('Error Message was ' + errorMessage + ' instead of ' + contextErrorMessage); + } + } if (context.shouldFail) { context.shouldFail = false; resolve({statusCode: result.statusCode, data: {}}); diff --git a/openecomp-bdd/stepDefinitions/VLM_steps.js b/openecomp-bdd/stepDefinitions/VLM_steps.js index 6e0dd318cf..ea75313789 100644 --- a/openecomp-bdd/stepDefinitions/VLM_steps.js +++ b/openecomp-bdd/stepDefinitions/VLM_steps.js @@ -45,3 +45,13 @@ Then('I want to submit this VLM', function() { return util.request(this.context, 'PUT', path, inputData); }); +/** + * @module VLM + * @exampleFile DeleteVLMDraft.feature + * @step I want to delete this VLM + **/ +Then('I want to delete this VLM', function() { + let path = '/vendor-license-models/' + this.context.item.id ; + return util.request(this.context, 'DELETE', path); +}); + diff --git a/openecomp-bdd/stepDefinitions/VSP_steps.js b/openecomp-bdd/stepDefinitions/VSP_steps.js index b957e6f723..bed8921a3c 100644 --- a/openecomp-bdd/stepDefinitions/VSP_steps.js +++ b/openecomp-bdd/stepDefinitions/VSP_steps.js @@ -107,4 +107,15 @@ Then('I want to add a component', function () { When('I want to get the package for this Item to path {string}', function (string, callback) { let path = '/vendor-software-products/packages/' + this.context.item.id; return [util.download(this.context, path, string, callback)]; +}); + + +/** + * @module VSP + * @exampleFile DeleteVSPDraft.feature + * @step I want to delete this VSP + **/ +Then('I want to delete this VSP', function() { + let path = '/vendor-software-products/' + this.context.item.id ; + return util.request(this.context, 'DELETE', path); });
\ No newline at end of file |