Flow Tests - delete item and Toggle 39/32039/1
authorayalaben <Ayala.Benzvi@Amdocs.Com>
Sun, 18 Feb 2018 08:03:22 +0000 (10:03 +0200)
committerayalaben <ayala.benzvi@amdocs.com>
Sun, 18 Feb 2018 08:03:22 +0000 (10:03 +0200)
Change-Id: I73ed5fdc13891b3ad56ab5c8f00083bf8f7d13f3
Issue-ID: SDC-1034
Signed-off-by: ayalaben <ayala.benzvi@amdocs.com>
12 files changed:
openecomp-bdd/features/Example_Toggle.feature [new file with mode: 0644]
openecomp-bdd/features/Onboarding/DeleteItem/DeleteVLMCertified.feature [new file with mode: 0644]
openecomp-bdd/features/Onboarding/DeleteItem/DeleteVLMDraft.feature [new file with mode: 0644]
openecomp-bdd/features/Onboarding/DeleteItem/DeleteVSPCertified.feature [new file with mode: 0644]
openecomp-bdd/features/Onboarding/DeleteItem/DeleteVSPDraft.feature [new file with mode: 0644]
openecomp-bdd/stepDefinitions/General_Steps.js
openecomp-bdd/stepDefinitions/Toggle_Steps.js [new file with mode: 0644]
openecomp-bdd/stepDefinitions/Utils.js
openecomp-bdd/stepDefinitions/VLM_steps.js
openecomp-bdd/stepDefinitions/VSP_steps.js
openecomp-be/api/openecomp-sdc-rest-webapp/togglz-rest/togglz-rest-services/src/main/java/org/openecomp/sdcrests/togglz/rest/TogglzFeatures.java
openecomp-be/api/openecomp-sdc-rest-webapp/togglz-rest/togglz-rest-services/src/main/java/org/openecomp/sdcrests/togglz/rest/services/TogglzFeaturesImpl.java

diff --git a/openecomp-bdd/features/Example_Toggle.feature b/openecomp-bdd/features/Example_Toggle.feature
new file mode 100644 (file)
index 0000000..2d93077
--- /dev/null
@@ -0,0 +1,8 @@
+Feature: Enable all toggls
+
+Scenario: Enable/Disable all toggls
+    When I want to list Togglz
+    Then I want to set all Togglz to be "true"
+    Then I want to list Togglz
+    Then I want to set all Togglz to be "false"
+    Then I want to list Togglz
\ No newline at end of file
diff --git a/openecomp-bdd/features/Onboarding/DeleteItem/DeleteVLMCertified.feature b/openecomp-bdd/features/Onboarding/DeleteItem/DeleteVLMCertified.feature
new file mode 100644 (file)
index 0000000..4eb31ae
--- /dev/null
@@ -0,0 +1,24 @@
+Feature: Delete VLM Certified
+
+    Scenario: Delete VLM that was certified - negative
+        When I want to create a VLM
+        Then I want to create input data
+        Then I want to update the input property "name" with a random value
+        Then I want to update the input property "type" with value "Universal"
+        Then I want to create for path "/vendor-license-models/{item.id}/versions/{item.versionId}/license-key-groups" with the input data from the context
+        Then I want to copy to property "lastProcessId" from response data path "value"
+        Then I want to commit this Item
+
+        Then I want to get path "/items/{item.id}/versions"
+        Then I want to check property "listCount" for value 1
+        Then I want to make sure this Item has status "Draft"
+        When I want to submit this VLM
+        Then I want to make sure this Item has status "Certified"
+        Then I want to get path "/items/{item.id}/versions"
+        Then I want to check property "listCount" for value 1
+
+        Then I want the following to fail with error message "VLM has been certified and cannot be deleted."
+        Then I want to delete this VLM
+
+       Then I want to get path "/items/{item.id}/versions"
+       Then I want to check property "listCount" for value 1
diff --git a/openecomp-bdd/features/Onboarding/DeleteItem/DeleteVLMDraft.feature b/openecomp-bdd/features/Onboarding/DeleteItem/DeleteVLMDraft.feature
new file mode 100644 (file)
index 0000000..c9a7ed7
--- /dev/null
@@ -0,0 +1,24 @@
+Feature: Delete VLM
+
+Scenario: Delete VLM with only draft
+    When I want to create a VLM
+    Then I want to create input data
+    Then I want to update the input property "name" with a random value
+    Then I want to update the input property "type" with value "Universal"
+    Then I want to create for path "/vendor-license-models/{item.id}/versions/{item.versionId}/license-key-groups" with the input data from the context
+    Then I want to copy to property "lastProcessId" from response data path "value"
+    Then I want to commit this Item
+
+    Then I want to get path "/items/{item.id}/versions"
+    Then I want to check property "listCount" for value 1
+    Then I want to make sure this Item has status "Draft"
+
+    Then I want to delete this VLM
+
+   Then I want the following to fail with error code "GENERAL_ERROR_REST_ID"
+   Then I want to get path "/items/{item.id}/versions"
+
+
+
+
+
diff --git a/openecomp-bdd/features/Onboarding/DeleteItem/DeleteVSPCertified.feature b/openecomp-bdd/features/Onboarding/DeleteItem/DeleteVSPCertified.feature
new file mode 100644 (file)
index 0000000..35a506a
--- /dev/null
@@ -0,0 +1,29 @@
+Feature: Delete VSP Draft
+
+    Background: Init
+        Given I want to create a VLM
+
+    Scenario: Delete VSP with only draft
+        When I want to create a VSP with onboarding type "NetworkPackage"
+        Then I want to make sure this Item has status "Draft"
+
+        When I want to upload a NetworkPackage for this VSP from path "resources/uploads/BASE_MUX.zip"
+        And I want to process the NetworkPackage file for this VSP
+
+        Then I want to commit this Item
+
+        Then I want to get path "/items/{item.id}/versions"
+        Then I want to check property "listCount" for value 1
+        Then I want to make sure this Item has status "Draft"
+
+        When I want to submit this VSP
+        Then I want to make sure this Item has status "Certified"
+        Then I want to get path "/items/{item.id}/versions"
+        Then I want to check property "listCount" for value 1
+
+        Then I want the following to fail with error message "VSP has been certified and cannot be deleted."
+        Then I want to delete this VSP
+
+        Then I want to get path "/items/{item.id}/versions"
+        Then I want to check property "listCount" for value 1
+
diff --git a/openecomp-bdd/features/Onboarding/DeleteItem/DeleteVSPDraft.feature b/openecomp-bdd/features/Onboarding/DeleteItem/DeleteVSPDraft.feature
new file mode 100644 (file)
index 0000000..aade3bf
--- /dev/null
@@ -0,0 +1,22 @@
+Feature: Delete VSP Certified
+
+    Background: Init
+        Given I want to create a VLM
+
+    Scenario: Delete VSP with certified - negative
+        When I want to create a VSP with onboarding type "NetworkPackage"
+        Then I want to make sure this Item has status "Draft"
+
+        When I want to upload a NetworkPackage for this VSP from path "resources/uploads/BASE_MUX.zip"
+        And I want to process the NetworkPackage file for this VSP
+
+        Then I want to commit this Item
+
+        Then I want to get path "/items/{item.id}/versions"
+        Then I want to check property "listCount" for value 1
+        Then I want to make sure this Item has status "Draft"
+
+        Then I want to delete this VSP
+
+        Then I want the following to fail with error code "GENERAL_ERROR_REST_ID"
+        Then I want to get path "/items/{item.id}/versions"
index 389112d..bf35cb8 100644 (file)
@@ -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 (file)
index 0000000..16bcc2a
--- /dev/null
@@ -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
index e818e72..ff49727 100644 (file)
@@ -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: {}});
index 6e0dd31..ea75313 100644 (file)
@@ -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);
+});
+
index b957e6f..bed8921 100644 (file)
@@ -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
index 74009f6..64c558f 100644 (file)
@@ -44,6 +44,12 @@ public interface TogglzFeatures {
   Response getFeatures();
 
 
+  @PUT
+  @Path("/state/{state}")
+  @ApiOperation(value = "Update feature toggle state for all features")
+  Response setAllFeatures(@PathParam("state") boolean state);
+
+
   @PUT
   @Path("/{featureName}/state/{state}")
   @ApiOperation(value = "Update feature toggle state")
index 657c428..d62dd4a 100644 (file)
@@ -44,6 +44,18 @@ public class TogglzFeaturesImpl implements TogglzFeatures {
         return Response.ok(featureSetDto).build();
     }
 
+    @Override
+    public Response setAllFeatures(boolean active) {
+        FeatureSetDto featureSetDto = new FeatureSetDto();
+        new MapToggleableFeatureToDto().doMapping(Arrays.asList(ToggleableFeature.values()), featureSetDto);
+        featureSetDto.getFeatures().forEach(featureDto -> {
+            Feature feature = new NamedFeature(featureDto.getName());
+            FeatureState featureState = new FeatureState(feature,active);
+            FeatureContext.getFeatureManager().setFeatureState(featureState);
+        });
+        return Response.ok().build();
+    }
+
     @Override
     public Response setFeatureState(String featureName, boolean active) {
         Feature feature = new NamedFeature(featureName);