From 02201e449b644790e99bbb230579d96cae4a53da Mon Sep 17 00:00:00 2001 From: talig Date: Sun, 5 Aug 2018 10:47:36 +0300 Subject: Refactor and add test flows Small fix in version state filter Change-Id: I015cbc52b8620b92ebb4f8f0167711e39d9d30a8 Issue-ID: SDC-1503 Signed-off-by: talig --- workflow-bdd/features/Version.feature | 32 ++++++-- workflow-bdd/features/WorkflowList.feature | 52 ++++++------- .../features/examples/ResponseDataChecks.feature | 50 ++++++++++++ .../json/createVersionWithInputsOutputs.json | 17 ----- .../json/versionWith2Inputs2Outputs1.json | 27 +++++++ .../json/versionWith2Inputs2Outputs2.json | 27 +++++++ workflow-bdd/stepDefinitions/General_Steps.js | 88 ++++++++++++++-------- 7 files changed, 210 insertions(+), 83 deletions(-) create mode 100644 workflow-bdd/features/examples/ResponseDataChecks.feature delete mode 100644 workflow-bdd/resources/json/createVersionWithInputsOutputs.json create mode 100644 workflow-bdd/resources/json/versionWith2Inputs2Outputs1.json create mode 100644 workflow-bdd/resources/json/versionWith2Inputs2Outputs2.json (limited to 'workflow-bdd') diff --git a/workflow-bdd/features/Version.feature b/workflow-bdd/features/Version.feature index e43971cb..a5327fd7 100644 --- a/workflow-bdd/features/Version.feature +++ b/workflow-bdd/features/Version.feature @@ -25,15 +25,16 @@ Feature: Workflow Versions Then I want to get path "/workflows/{item.id}/versions/{item.versionId}" And I want to check that property "id" in the response equals to value of saved property "item.versionId" And I want to get path "/workflows/{item.id}/versions" - And I want to check that element in the response list with "id" equals to value of saved property "item.versionId" exists + And I want to check in the list "items" property "id" with value of saved property "item.versionId" exists Scenario: Create first version with inputs/outputs - When I want to set the input data to file "resources/json/createVersionWithInputsOutputs.json" + When I want to set the input data to file "resources/json/versionWith2Inputs2Outputs1.json" And I want to create for path "/workflows/{item.id}/versions" with the input data from the context - And I want to copy to property "item.versionId" from response data path "id" - Then I want to check property "inputs[0].name" for value "in1" - And I want to check property "outputs[0].name" for value "out1" + Then I want to check in the list "inputs" property "name" with value "in1" exists + And I want to check in the list "inputs" property "name" with value "in2" exists + And I want to check in the list "outputs" property "name" with value "out1" exists + And I want to check in the list "outputs" property "name" with value "out2" exists Scenario: Create second version And I want to update the input property "description" with value "first empty version" @@ -50,7 +51,7 @@ Feature: Workflow Versions Then I want to get path "/workflows/{item.id}/versions/{item.versionId}" And I want to check that property "id" in the response equals to value of saved property "item.versionId" And I want to get path "/workflows/{item.id}/versions" - And I want to check that element in the response list with "id" equals to value of saved property "item.versionId" exists + And I want to check in the list "items" property "id" with value of saved property "item.versionId" exists Scenario: Update version And I want to create input data @@ -62,4 +63,21 @@ Feature: Workflow Versions And I want to update for path "/workflows/{item.id}/versions/{item.versionId}" with the input data from the context Then I want to get path "/workflows/{item.id}/versions/{item.versionId}" - And I want to check property "description" for value "workflow version description updated" \ No newline at end of file + And I want to check property "description" for value "workflow version description updated" + + Scenario: Update version with inputs/outputs (create/update/delete parameters) + And I want to set the input data to file "resources/json/versionWith2Inputs2Outputs1.json" + And I want to create for path "/workflows/{item.id}/versions" with the input data from the context + And I want to copy to property "item.versionId" from response data path "id" + + When I want to set the input data to file "resources/json/versionWith2Inputs2Outputs2.json" + And I want to update for path "/workflows/{item.id}/versions/{item.versionId}" with the input data from the context + + Then I want to get path "/workflows/{item.id}/versions/{item.versionId}" + And I want to check in the list "inputs" property "name" with value "in1" exists + And I want to check in the list "inputs" property "name" with value "in2" does not exist + And I want to check in the list "inputs" property "name" with value "in3" exists + And I want to check in the list "outputs" property "name" with value "out1" exists + And I want to check in the list "outputs" property "name" with value "out2" does not exist + And I want to check in the list "outputs" property "name" with value "out3" exists + diff --git a/workflow-bdd/features/WorkflowList.feature b/workflow-bdd/features/WorkflowList.feature index 5b6941ec..3cd27a05 100644 --- a/workflow-bdd/features/WorkflowList.feature +++ b/workflow-bdd/features/WorkflowList.feature @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -Feature: List Workflows +Feature: Workflows list Background: Init - create various workflows in order to test list filter Given I want to create a Workflow @@ -41,36 +41,36 @@ Feature: List Workflows And I want to create for path "/workflows/{item.id}/versions?baseVersionId={item.versionId}" with the input data from the context Scenario: List all - When I want to get path "/workflows?size=2000" - Then I want to check that element in the response list with "id" equals to value of saved property "noVersionsWorkflowId" exists - And I want to check that element in the response list with "id" equals to value of saved property "draftVersionWorkflowId" exists - And I want to check that element in the response list with "id" equals to value of saved property "certifiedVersionWorkflowId" exists - And I want to check that element in the response list with "id" equals to value of saved property "draftAndCertifiedVersionWorkflowId" exists + When I want to get path "/workflows?limit=2000" + Then I want to check in the list "items" property "id" with value of saved property "noVersionsWorkflowId" exists + And I want to check in the list "items" property "id" with value of saved property "draftVersionWorkflowId" exists + And I want to check in the list "items" property "id" with value of saved property "certifiedVersionWorkflowId" exists + And I want to check in the list "items" property "id" with value of saved property "draftAndCertifiedVersionWorkflowId" exists Scenario: List ones with DRAFT version(s) - When I want to get path "/workflows?versionState=DRAFT&size=2000" - Then I want to check that element in the response list with "id" equals to value of saved property "noVersionsWorkflowId" does not exist - And I want to check that element in the response list with "id" equals to value of saved property "draftVersionWorkflowId" exists - And I want to check that element in the response list with "id" equals to value of saved property "certifiedVersionWorkflowId" does not exist - And I want to check that element in the response list with "id" equals to value of saved property "draftAndCertifiedVersionWorkflowId" exists + When I want to get path "/workflows?versionState=DRAFT&limit=2000" + Then I want to check in the list "items" property "id" with value of saved property "noVersionsWorkflowId" does not exist + And I want to check in the list "items" property "id" with value of saved property "draftVersionWorkflowId" exists + And I want to check in the list "items" property "id" with value of saved property "certifiedVersionWorkflowId" does not exist + And I want to check in the list "items" property "id" with value of saved property "draftAndCertifiedVersionWorkflowId" exists Scenario: List ones with CERTIFIED version(s) - When I want to get path "/workflows?versionState=CERTIFIED&size=2000" - Then I want to check that element in the response list with "id" equals to value of saved property "noVersionsWorkflowId" does not exist - And I want to check that element in the response list with "id" equals to value of saved property "draftVersionWorkflowId" does not exist - And I want to check that element in the response list with "id" equals to value of saved property "certifiedVersionWorkflowId" exists - And I want to check that element in the response list with "id" equals to value of saved property "draftAndCertifiedVersionWorkflowId" exists + When I want to get path "/workflows?versionState=CERTIFIED&limit=2000" + Then I want to check in the list "items" property "id" with value of saved property "noVersionsWorkflowId" does not exist + And I want to check in the list "items" property "id" with value of saved property "draftVersionWorkflowId" does not exist + And I want to check in the list "items" property "id" with value of saved property "certifiedVersionWorkflowId" exists + And I want to check in the list "items" property "id" with value of saved property "draftAndCertifiedVersionWorkflowId" exists Scenario: List ones with DRAFT/CERTIFIED version(s) - When I want to get path "/workflows?versionState=DRAFT,CERTIFIED&size=2000" - Then I want to check that element in the response list with "id" equals to value of saved property "noVersionsWorkflowId" does not exist - And I want to check that element in the response list with "id" equals to value of saved property "draftVersionWorkflowId" exists - And I want to check that element in the response list with "id" equals to value of saved property "certifiedVersionWorkflowId" exists - And I want to check that element in the response list with "id" equals to value of saved property "draftAndCertifiedVersionWorkflowId" exists + When I want to get path "/workflows?versionState=DRAFT,CERTIFIED&limit=2000" + Then I want to check in the list "items" property "id" with value of saved property "noVersionsWorkflowId" does not exist + And I want to check in the list "items" property "id" with value of saved property "draftVersionWorkflowId" exists + And I want to check in the list "items" property "id" with value of saved property "certifiedVersionWorkflowId" exists + And I want to check in the list "items" property "id" with value of saved property "draftAndCertifiedVersionWorkflowId" exists Scenario: List ones with gibberish version(s) = none - When I want to get path "/workflows?versionState=gibberish&size=2000" - Then I want to check that element in the response list with "id" equals to value of saved property "noVersionsWorkflowId" does not exist - And I want to check that element in the response list with "id" equals to value of saved property "draftVersionWorkflowId" does not exist - And I want to check that element in the response list with "id" equals to value of saved property "certifiedVersionWorkflowId" does not exist - And I want to check that element in the response list with "id" equals to value of saved property "draftAndCertifiedVersionWorkflowId" does not exist \ No newline at end of file + When I want to get path "/workflows?versionState=gibberish&limit=2000" + Then I want to check in the list "items" property "id" with value of saved property "noVersionsWorkflowId" does not exist + And I want to check in the list "items" property "id" with value of saved property "draftVersionWorkflowId" does not exist + And I want to check in the list "items" property "id" with value of saved property "certifiedVersionWorkflowId" does not exist + And I want to check in the list "items" property "id" with value of saved property "draftAndCertifiedVersionWorkflowId" does not exist \ No newline at end of file diff --git a/workflow-bdd/features/examples/ResponseDataChecks.feature b/workflow-bdd/features/examples/ResponseDataChecks.feature new file mode 100644 index 00000000..2f8ff52f --- /dev/null +++ b/workflow-bdd/features/examples/ResponseDataChecks.feature @@ -0,0 +1,50 @@ +Feature: Example for checking response data + Scenario: Example Checks + # setting some data just for testing purposes + Given Response Data: + """ + { + "field1" : "string field", + "field2" : true, + "field3": "5", + "field4" : [{"entry1":"a"},{"entry2":"b"},{"entry3":"c"}], + "inputs": [ + { + "mandatory": true, + "name": "in1", + "type": "STRING" + }, + { + "mandatory": true, + "name": "in2", + "type": "INTEGER" + } + ], + "outputs": [ + { + "mandatory": true, + "name": "workflow", + "type": "TIMESTAMP" + }, + { + "mandatory": true, + "name": "out2", + "type": "BOOLEAN" + } + ] + } + """ + # printing out for test purposes + 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" + Then I want to check property "field2" to be true + Then I want to check property "field3" for value 5 + Then I want to check property "field4" to have length 3 + Then I want to check property "field4[0].entry1" exists + Then I want to check property "field4[0].no_exist" does not exist + Then I want to check property "outputs[0].name" exists + Then I want to check property "outputs[0].name" for value "workflow" + Then I want to check in the list "outputs" property "name" with value "out2" exists + Then I want to check in the list "outputs" property "name" with value "out3" does not exist diff --git a/workflow-bdd/resources/json/createVersionWithInputsOutputs.json b/workflow-bdd/resources/json/createVersionWithInputsOutputs.json deleted file mode 100644 index a9b6c3de..00000000 --- a/workflow-bdd/resources/json/createVersionWithInputsOutputs.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "description": "first version - with inputs and outputs", - "inputs": [ - { - "mandatory": true, - "name": "in1", - "type": "STRING" - } - ], - "outputs": [ - { - "mandatory": true, - "name": "out1", - "type": "TIMESTAMP" - } - ] -} \ No newline at end of file diff --git a/workflow-bdd/resources/json/versionWith2Inputs2Outputs1.json b/workflow-bdd/resources/json/versionWith2Inputs2Outputs1.json new file mode 100644 index 00000000..cc0a38ef --- /dev/null +++ b/workflow-bdd/resources/json/versionWith2Inputs2Outputs1.json @@ -0,0 +1,27 @@ +{ + "description": "version with 2 inputs and 2 outputs", + "inputs": [ + { + "mandatory": true, + "name": "in1", + "type": "STRING" + }, + { + "mandatory": true, + "name": "in2", + "type": "INTEGER" + } + ], + "outputs": [ + { + "mandatory": true, + "name": "out1", + "type": "TIMESTAMP" + }, + { + "mandatory": true, + "name": "out2", + "type": "BOOLEAN" + } + ] +} \ No newline at end of file diff --git a/workflow-bdd/resources/json/versionWith2Inputs2Outputs2.json b/workflow-bdd/resources/json/versionWith2Inputs2Outputs2.json new file mode 100644 index 00000000..58f9b2b8 --- /dev/null +++ b/workflow-bdd/resources/json/versionWith2Inputs2Outputs2.json @@ -0,0 +1,27 @@ +{ + "description": "version with 2 inputs and 2 outputs", + "inputs": [ + { + "mandatory": false, + "name": "in1", + "type": "STRING" + }, + { + "mandatory": true, + "name": "in3", + "type": "INTEGER" + } + ], + "outputs": [ + { + "mandatory": false, + "name": "out1", + "type": "TIMESTAMP" + }, + { + "mandatory": true, + "name": "out3", + "type": "BOOLEAN" + } + ] +} \ No newline at end of file diff --git a/workflow-bdd/stepDefinitions/General_Steps.js b/workflow-bdd/stepDefinitions/General_Steps.js index 2e74c6ee..69a703cc 100644 --- a/workflow-bdd/stepDefinitions/General_Steps.js +++ b/workflow-bdd/stepDefinitions/General_Steps.js @@ -39,7 +39,7 @@ Given('Item {string} and version Id {string}', function (string, string2) { }); /** * @module ContextData - * @exampleFile Example_ResponseData_CheckAndManipulation.feature + * @exampleFile ResponseDataChecks.feature * @description Response Data::
* """
* {jsonObject}
@@ -83,7 +83,7 @@ Then('I want to set property {string} to value {string}', function(string, strin /** * @module ResponseData * @description Will check the output data for a property and a value. property can be a path (example: results[0].id) - * @exampleFile Example_ResponseData_CheckAndManipulation.feature + * @exampleFile ResponseDataChecks.feature * @step I want to check property {string} for value {string} **/ Then('I want to check property {string} for value {string}', function(string, string2) { @@ -103,16 +103,17 @@ Then('I want to check property {string} for value:', function(string, docString) /** * @module ResponseData * @description Will check the output data for a property and a integer. property can be a path (example: results[0].id) - * @exampleFile Example_ResponseData_CheckAndManipulation.feature + * @exampleFile ResponseDataChecks.feature * @step I want to check property {string} for value {int} **/ Then('I want to check property {string} for value {int}', function(string, int) { assert.equal(_.get(this.context.responseData, string), int); }); + /** * @module ResponseData * @description Will check the output data for a property and a boolean. property can be a path (example: results[0].id) - * @exampleFile Example_ResponseData_CheckAndManipulation.feature + * @exampleFile ResponseDataChecks.feature * @step I want to check property {string} to be "True/False" **/ Then('I want to check property {string} to be {word}', function(string, string2) { @@ -121,7 +122,7 @@ Then('I want to check property {string} to be {word}', function(string, string2) /** * @module ResponseData * @description Will check the output data for a property and a boolean. property can be a path (example: results[0].id) - * @exampleFile Example_ResponseData_CheckAndManipulation.feature + * @exampleFile ResponseDataChecks.feature * @step I want to check property {string} to have length {int} **/ Then('I want to check property {string} to have length {int}', function(string, intLength) { @@ -131,7 +132,7 @@ Then('I want to check property {string} to have length {int}', function(string, /** * @module ResponseData * @description Will check the output data for a property and make sure it exists - * @exampleFile Example_ResponseData_CheckAndManipulation.feature + * @exampleFile ResponseDataChecks.feature * @step I want to check property {string} exists **/ Then('I want to check property {string} exists', function(string) { @@ -140,17 +141,63 @@ Then('I want to check property {string} exists', function(string) { /** * @module ResponseData * @description Will check the output data for a property and make sure it does not exist - * @exampleFile Example_ResponseData_CheckAndManipulation.feature + * @exampleFile ResponseDataChecks.feature * @step I want to check property {string} does not exist **/ Then('I want to check property {string} does not exist', function(string) { assert.equal(_.has(this.context.responseData, string), false); }); +/** + * @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 + * @step I want to check property {string} for value {string} + **/ +Then('I want to check in the list {string} property {string} with value {string} exists', function(listPath, propertyPath, value) { + var list = _.get(this.context.responseData, listPath); + assert.notEqual(list.find(element => _.get(element, propertyPath) === value), undefined); +}); + +/** + * @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 + * @step I want to check property {string} for value {string} + **/ +Then('I want to check in the list {string} property {string} with value {string} does not exist', function(listPath, propertyPath, value) { + var list = _.get(this.context.responseData, listPath); + assert.equal(list.find(element => _.get(element, propertyPath) === value), undefined); +}); + +/** + * @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 + * @step I want to check property {string} for value {string} + **/ +Then('I want to check in the list {string} property {string} with value of saved property {string} exists', function(listPath, propertyPath, valueProperty) { + var list = _.get(this.context.responseData, listPath); + var value = _.get(this.context, valueProperty); + assert.notEqual(list.find(element => _.get(element, propertyPath) === value), undefined); +}); + +/** + * @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 + * @step I want to check property {string} for value {string} + **/ +Then('I want to check in the list {string} property {string} with value of saved property {string} does not exist', function(listPath, propertyPath, valueProperty) { + var list = _.get(this.context.responseData, listPath); + var value = _.get(this.context, valueProperty); + assert.equal(list.find(element => _.get(element, propertyPath) === value), undefined); +}); + /** * @module ContextData * @description Use during development to see what is on the context - * @exampleFile Example_ResponseData_CheckAndManipulation.feature + * @exampleFile ResponseDataChecks.feature * @step I want to print the context data **/ Then('I want to print the context data', function() { @@ -247,31 +294,6 @@ When('I want to load the json content of the entry {string} in the zip {string} callback(); }); -/** - * @module ResponseData - * @description Check that the result list doesn't contain an element with property x which has value - * equals to saved property y - * @exampleFile ListItemsFilters.feature - * @step I want to check that element in the response list with {string} equals to value of saved property {string} does not exist - **/ -Then('I want to check that element in the response list with {string} equals to value of saved property {string} does not exist', function (propertyPath, valueProperty) { - const results = this.context.responseData.results; - assert.equal(results.find(result => this.context[valueProperty] === _.get(result, propertyPath)), undefined); -}); - -/** - * @module ResponseData - * @description Check that the result list contains an element with property x which has value - * equals to saved property y - * @exampleFile ListItemsFilters.feature - * @step I want to check that element in the response list with {string} equals to value of saved property {string} exists - **/ -Then('I want to check that element in the response list with {string} equals to value of saved property {string} exists', function(propertyPath, valueProperty) { - const results = this.context.responseData.results; - assert.notEqual(results.find(result => _.get(this.context, valueProperty) === _.get(result, propertyPath)), undefined); -}); - - Then('I want to check that property {string} in the response equals to value of saved property {string}', function(propertyPath, valueProperty) { const results = this.context.responseData; assert.equal(results[propertyPath], _.get(this.context, valueProperty)); -- cgit 1.2.3-korg