From 39c01dd3ccb69f53d2e9350994e25f6e64412aa4 Mon Sep 17 00:00:00 2001 From: talig Date: Sun, 15 Jul 2018 15:41:31 +0300 Subject: Get and update workflow version state Remove redundant controller interfaces, rename WorkflowVersionStatus to State Change-Id: I8ddc9cd656fc8bed607c68aa326c7fa7d2980116 Issue-ID: SDC-1503 Signed-off-by: talig --- workflow-bdd/features/Version_State.feature | 30 +++++++++++++++++++++++++++ workflow-bdd/pom.xml | 4 ++-- workflow-bdd/stepDefinitions/General_Steps.js | 15 ++++++++++++-- workflow-bdd/stepDefinitions/Utils.js | 5 +++++ workflow-bdd/stepDefinitions/world.js | 5 ----- 5 files changed, 50 insertions(+), 9 deletions(-) create mode 100644 workflow-bdd/features/Version_State.feature (limited to 'workflow-bdd') diff --git a/workflow-bdd/features/Version_State.feature b/workflow-bdd/features/Version_State.feature new file mode 100644 index 00000000..8c1e13fd --- /dev/null +++ b/workflow-bdd/features/Version_State.feature @@ -0,0 +1,30 @@ +Feature: Workflow Version State + + Background: Create workflow and first version + Given I want to create a Workflow + And I want to update the input property "description" with value "workflow version description" + 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" + + Scenario: Get state after creation + When I want to get path "/workflows/{item.id}/versions/{item.versionId}/state" + Then I want to check property "name" for value "DRAFT" + And I want to check property "nextStates[0]" for value "CERTIFIED" + + Scenario: Update state to current state + Then I want the following to fail with response status code 422 + When I want to update the input property "name" with value "DRAFT" + And I want to create for path "/workflows/{item.id}/versions/{item.versionId}/state" with the input data from the context + + Scenario: Update state - DRAFT to CERTIFIED + When I want to update the input property "name" with value "CERTIFIED" + And I want to create for path "/workflows/{item.id}/versions/{item.versionId}/state" with the input data from the context + Then I want to get path "/workflows/{item.id}/versions/{item.versionId}/state" + And I want to check property "name" for value "CERTIFIED" + And I want to check property "nextStates" to have length 0 + + Scenario: Update state when CERTIFIED + When I want to update the input property "name" with value "CERTIFIED" + And I want to create for path "/workflows/{item.id}/versions/{item.versionId}/state" with the input data from the context + When I want the following to fail with response status code 422 + Then I want to create for path "/workflows/{item.id}/versions/{item.versionId}/state" with the input data from the context \ No newline at end of file diff --git a/workflow-bdd/pom.xml b/workflow-bdd/pom.xml index 111fe39e..3502451c 100644 --- a/workflow-bdd/pom.xml +++ b/workflow-bdd/pom.xml @@ -8,11 +8,11 @@ cucumber-report 1.2.0-SNAPSHOT - + diff --git a/workflow-bdd/stepDefinitions/General_Steps.js b/workflow-bdd/stepDefinitions/General_Steps.js index 448c97f8..0550e415 100644 --- a/workflow-bdd/stepDefinitions/General_Steps.js +++ b/workflow-bdd/stepDefinitions/General_Steps.js @@ -52,11 +52,11 @@ Given('Response Data:', function (docString) { /** * @module ContextData - * @description Copy a property from the response data to context Item/VLM/VSP data, example: vsp.componentId + * @description Copy a property from the response data to context Item data, example: item.componentId * @step I want to save on the context for {string} property {string} with value {string} **/ Then('I want to save on the context for {string} property {string} with value {string}', function(string, string1, string2) { - assert.equal(_.includes(['VLM', 'VSP', 'Item'], string), true); + assert.equal(_.includes(['Item'], string), true); let val = _.get(this.context.responseData, string2); _.set(this.context, string1, val); }); @@ -168,6 +168,17 @@ Then('I want the following to fail', function() { this.context.shouldFail = true; }); +/** + * @module ContextData + * @description Set this in order to check that the following Rest call will not have response code 200 + * @exampleFile Example_Rest_Calls.feature + * @step I want the following to fail + **/ +Then('I want the following to fail with response status code {int}', function(int) { + this.context.shouldFail = true; + this.context.responseStatusCode = int; +}); + /** * @module ContextData * @description Set this in order to check that the following Rest call will have the error code on the return data diff --git a/workflow-bdd/stepDefinitions/Utils.js b/workflow-bdd/stepDefinitions/Utils.js index 66e959f6..6f8a7a5c 100644 --- a/workflow-bdd/stepDefinitions/Utils.js +++ b/workflow-bdd/stepDefinitions/Utils.js @@ -55,6 +55,11 @@ function _request(context, method, path, data, isBinary=false, type='onboarding' console.error(result.body); reject('Status Code was ' + result.statusCode); } + if (context.shouldFail && context.responseStatusCode) { + if (result.statusCode !== context.responseStatusCode) { + reject('Response Status Code was ' + result.statusCode + ' instead of ' + context.responseStatusCode); + } + } if (context.shouldFail && context.errorCode) { if (typeof data === 'string' && data) { data = JSON.parse(data); diff --git a/workflow-bdd/stepDefinitions/world.js b/workflow-bdd/stepDefinitions/world.js index 4ef03813..cf749e66 100644 --- a/workflow-bdd/stepDefinitions/world.js +++ b/workflow-bdd/stepDefinitions/world.js @@ -38,9 +38,6 @@ var {setDefaultTimeout} = require('cucumber'); *
* Contains the following items:
*
  • this.context.server
      REST server and onboarding prefix including version. set either in configuration file or from the command line or SERVER environment variable
    - *
  • this.context.vlm
      When a VLM has been created, this has the an id and versionId set to the correct IDs.
    - *
  • this.context.vsp
      When a VSP has been created, this has the an id and versionId and componentId set to the correct IDs.
    - *
  • this.context.item
      When a VLM or VSP has been created, this has the an id and versionId set to the correct IDs.
    *
  • this.context
      Object with properties that were saved in the steps.
    *
  • this.context.inputdata
      Automatically updated with the last responseData from the Rest call
      Object with properties that were prepares in the steps.
    *
  • this.context.responseData
      Response from the last REST call.
    @@ -57,8 +54,6 @@ class CustomWorld { } } - this.context.vlm = {id: null, versionId: null}; - this.context.vsp = {id: null, versionId: null}; this.context.item = {id: null, versionId: null, componentId: null}; this.context.shouldFail = false; -- cgit 1.2.3-korg