diff options
author | talig <talig@amdocs.com> | 2018-08-09 13:13:23 +0300 |
---|---|---|
committer | talig <talig@amdocs.com> | 2018-08-09 13:13:23 +0300 |
commit | ff78ef472f8e481afb39f24a1d37737ef8dfab60 (patch) | |
tree | 2116f2cbc63de2bf82dbf358dbf16268a900a2d0 /workflow-bdd | |
parent | 923910109f7796aca1263df1a7fa13f7d6bc072c (diff) |
Add activity spec code
Move code from sdc repository and:
1. place according to this project structure
2. refactor DTOs and use mapstruct
3. change errorResponse to be a json instead of a string (for all workflow code)
Change-Id: Ia85590b53ab59ff7600e05b8a6d52e06b1773220
Issue-ID: SDC-1606
Signed-off-by: talig <talig@amdocs.com>
Diffstat (limited to 'workflow-bdd')
-rw-r--r-- | workflow-bdd/config.json | 6 | ||||
-rw-r--r-- | workflow-bdd/features/ActivitySpec.feature | 61 | ||||
-rw-r--r-- | workflow-bdd/features/ActivitySpecStatus.feature | 21 | ||||
-rw-r--r-- | workflow-bdd/features/examples/ResponseDataChecks.feature | 2 | ||||
-rw-r--r-- | workflow-bdd/resources/json/createActivitySpec.json | 23 | ||||
-rw-r--r-- | workflow-bdd/stepDefinitions/ActivitySpec_steps.js | 47 | ||||
-rw-r--r-- | workflow-bdd/stepDefinitions/General_Steps.js | 10 | ||||
-rw-r--r-- | workflow-bdd/stepDefinitions/Utils.js | 4 | ||||
-rw-r--r-- | workflow-bdd/stepDefinitions/world.js | 2 |
9 files changed, 169 insertions, 7 deletions
diff --git a/workflow-bdd/config.json b/workflow-bdd/config.json index 260f2859..5d38d099 100644 --- a/workflow-bdd/config.json +++ b/workflow-bdd/config.json @@ -16,13 +16,13 @@ "workflow" : { "port" : 8080, "prefix" : "wf", - "server" : "", + "server": "wf.server", "user" : "user" }, "activity_spec" : { "port" : 8080, - "prefix" : "activity-spec-api/v1.0", - "server" : "activity_spec.server", + "prefix": "v1.0", + "server": "wf.server", "user" : "user" } } diff --git a/workflow-bdd/features/ActivitySpec.feature b/workflow-bdd/features/ActivitySpec.feature new file mode 100644 index 00000000..7d9a754a --- /dev/null +++ b/workflow-bdd/features/ActivitySpec.feature @@ -0,0 +1,61 @@ +Feature: Activity Spec + + #SDC-6350 + Scenario: Create + When I want to set the input data to file "resources/json/createActivitySpec.json" + Then I want to update the input property "name" with a random value + When I want to create an ActivitySpec + + Then I want to check property "id" exists + And I want to check property "versionId" exists + + And I want to list ActivitySpecs with status "Draft" + And I want to check property "total" exists + + And I want to get the ActivitySpec for the current item + And I want to check property "status" for value "Draft" + + And I want to call action "CERTIFY" on this ActivitySpec item + And I want to get the ActivitySpec for the current item + And I want to check property "status" for value "Certified" + + And I want to call action "DEPRECATE" on this ActivitySpec item + And I want to get the ActivitySpec for the current item + And I want to check property "status" for value "Deprecated" + + And I want to call action "DELETE" on this ActivitySpec item + And I want to get the ActivitySpec for the current item + And I want to check property "status" for value "Deleted" + + Scenario: Get with invalid Id + Then I want to set property "item.id" to value "invalidId" + Then I want the following to fail with error message "No Activity Spec found for the given identifiers" + And I want to get the ActivitySpec for the current item + + #SDC-6353 + Scenario: Create with duplicate name - invalid + Given I want to set property "duplicateName" with a random value + And I want to set the input data to file "resources/json/createActivitySpec.json" + And I want to update the input property "name" with value of property "duplicateName" + And I want to create an ActivitySpec + And I want to check property "id" exists + And I want to check property "versionId" exists + + When I want to set the input data to file "resources/json/createActivitySpec.json" + And I want to update the input property "name" with value of property "duplicateName" + Then I want the following to fail with response status code 422 + And I want to create an ActivitySpec + + #SDC-6354 + Scenario: Create with invalid name - invalid + Given I want to set the input data to file "resources/json/createActivitySpec.json" + And I want to update the input property "name" with value "test!@" + Then I want the following to fail with response status code 400 + When I want to create an ActivitySpec + + #SDC-6355 + Scenario: Create with null/blank name - invalid + Given I want to set the input data to file "resources/json/createActivitySpec.json" + And I want to update the input property "name" with value "" + Then I want the following to fail with response status code 400 + When I want to create an ActivitySpec
\ No newline at end of file diff --git a/workflow-bdd/features/ActivitySpecStatus.feature b/workflow-bdd/features/ActivitySpecStatus.feature new file mode 100644 index 00000000..c908701b --- /dev/null +++ b/workflow-bdd/features/ActivitySpecStatus.feature @@ -0,0 +1,21 @@ +Feature: Activity Spec Status + + Scenario: Invalid Status Transition + When I want to set the input data to file "resources/json/createActivitySpec.json" + Then I want to update the input property "name" with a random value + When I want to create an ActivitySpec + Then I want to check property "id" exists + And I want to check property "versionId" exists + + When I want to get the ActivitySpec for the current item + Then I want to check property "status" for value "Draft" + + Then I want the following to fail with response status code 422 + When I want to call action "DEPRECATE" on this ActivitySpec item + + Then I want the following to fail with response status code 422 + When I want to call action "DELETE" on this ActivitySpec item + + When I want to call action "CERTIFY" on this ActivitySpec item + Then I want the following to fail with response status code 422 + When I want to call action "CERTIFY" on this ActivitySpec item
\ No newline at end of file diff --git a/workflow-bdd/features/examples/ResponseDataChecks.feature b/workflow-bdd/features/examples/ResponseDataChecks.feature index 2f8ff52f..7956e651 100644 --- a/workflow-bdd/features/examples/ResponseDataChecks.feature +++ b/workflow-bdd/features/examples/ResponseDataChecks.feature @@ -35,7 +35,7 @@ Feature: Example for checking response data } """ # printing out for test purposes - Then I want to print the context data + #Then I want to print the context data # running the different options of checking the respone data Then I want to check property "field1" for value "string field" diff --git a/workflow-bdd/resources/json/createActivitySpec.json b/workflow-bdd/resources/json/createActivitySpec.json new file mode 100644 index 00000000..bf1b6012 --- /dev/null +++ b/workflow-bdd/resources/json/createActivitySpec.json @@ -0,0 +1,23 @@ +{ + "name": "RANDOM", + "description": "Start Server", + "categoryList": [ + "Server" + ], + "inputs": [ + { + "name": "host", + "type": "string", + "value": "10.1.2.3" + } + ], + "outputs": [ + { + "name": "status", + "type": "string", + "value": "started" + } + ], + "type": "string", + "content": "test" +}
\ No newline at end of file diff --git a/workflow-bdd/stepDefinitions/ActivitySpec_steps.js b/workflow-bdd/stepDefinitions/ActivitySpec_steps.js new file mode 100644 index 00000000..7fe8ddf2 --- /dev/null +++ b/workflow-bdd/stepDefinitions/ActivitySpec_steps.js @@ -0,0 +1,47 @@ +/* + * 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} = require('cucumber'); +const assert = require('assert'); +const util = require('./Utils.js'); +const _ = require('lodash'); + +When('I want to create an ActivitySpec', function () { + let path = '/activity-spec'; + return util.request(this.context, 'POST', path, this.context.inputData, false, 'activity_spec').then((result)=> { + this.context.item = {id : result.data.id, versionId: result.data.versionId}; + this.context.activityspec = {id : result.data.id, versionId: result.data.versionId}; + }); +}); + +When('I want to list ActivitySpecs with status {string}', function (string) { + let path = '/activity-spec?status='+string; + return util.request(this.context, 'GET', path, null, false, 'activity_spec').then((result)=> { + this.context.listCount = result.data.listCount; + }); +}); + +When('I want to get the ActivitySpec for the current item', function () { + let path = '/activity-spec/'+ this.context.item.id+'/versions/'+this.context.item.versionId ; + return util.request(this.context, 'GET', path, null, false, 'activity_spec').then((result)=> { + }); +}); + +Then('I want to call action {string} on this ActivitySpec item', function(string) { + let path = '/activity-spec/'+ this.context.item.id+'/versions/'+this.context.item.versionId+'/actions' ; + let inputData = JSON.parse('{"action" : "' +string+ '"}'); + return util.request(this.context, 'PUT', path, inputData, false, 'activity_spec') +});
\ No newline at end of file diff --git a/workflow-bdd/stepDefinitions/General_Steps.js b/workflow-bdd/stepDefinitions/General_Steps.js index 69a703cc..5968d406 100644 --- a/workflow-bdd/stepDefinitions/General_Steps.js +++ b/workflow-bdd/stepDefinitions/General_Steps.js @@ -81,6 +81,16 @@ Then('I want to set property {string} to value {string}', function(string, strin }); /** + * @module ContextData + * @description sets context property to a random value + * @exampleFile Example_Rest_Calls.feature + * @step I want to update the input property {string} with a random value + **/ +Then('I want to set property {string} with a random value', function (string) { + _.set(this.context, string, util.random()); +}); + +/** * @module ResponseData * @description Will check the output data for a property and a value. property can be a path (example: results[0].id) * @exampleFile ResponseDataChecks.feature diff --git a/workflow-bdd/stepDefinitions/Utils.js b/workflow-bdd/stepDefinitions/Utils.js index 6f8a7a5c..9f398169 100644 --- a/workflow-bdd/stepDefinitions/Utils.js +++ b/workflow-bdd/stepDefinitions/Utils.js @@ -17,7 +17,7 @@ const request = require('request'); const fs = require('fs'); require('node-zip'); -function _request(context, method, path, data, isBinary=false, type='onboarding') { +function _request(context, method, path, data, isBinary=false, type='workflow') { let server = context.getUrlForType(type); let options = { @@ -106,7 +106,7 @@ function _request(context, method, path, data, isBinary=false, type='onboarding' }); } -function download(context, path, filePath, callback, type='onboarding') { +function download(context, path, filePath, callback, type='workflow') { let server = context.getUrlForType(type); let options = { method: 'GET', diff --git a/workflow-bdd/stepDefinitions/world.js b/workflow-bdd/stepDefinitions/world.js index cf749e66..4c50b0c9 100644 --- a/workflow-bdd/stepDefinitions/world.js +++ b/workflow-bdd/stepDefinitions/world.js @@ -70,7 +70,7 @@ class CustomWorld { var _server = context.server; var _config = config; return function(type) { - let typeData = _config["workflow"]; + let typeData = _config[type]; let _url = _config.protocol + '://' + typeData.server + ':' + typeData.port + '/' + |