Archive Item

Change-Id: Idd5eedc3b0ca9e3cc72f7de9fd432cdbbf77631d
Issue-ID: SDC-1086
Signed-off-by: ayalaben <ayala.benzvi@amdocs.com>
diff --git a/openecomp-bdd/features/Onboarding/ArchiveItem/ArchiveVlm.feature b/openecomp-bdd/features/Onboarding/ArchiveItem/ArchiveVlm.feature
new file mode 100644
index 0000000..f4b524b
--- /dev/null
+++ b/openecomp-bdd/features/Onboarding/ArchiveItem/ArchiveVlm.feature
@@ -0,0 +1,42 @@
+Feature: Archive and Restore VLM
+
+    Scenario: Archive VLM with 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 commit this Item
+
+        Then I want to archive this item
+        Then I want to list Archived VLMs
+        Then I want to check that item exits in response
+
+    Scenario: Archive Already Archived VLM - 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 submit this VLM
+
+        Then I want to archive this item
+        Then I want to list Archived VLMs
+        Then I want to check that item exits in response
+        Then I want the following to fail with error message "Archive item failed, item {item.id} is already Archived"
+        Then I want to archive this item
+
+
+    Scenario: Archive Certified VLM
+            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 submit this VLM
+
+            Then I want to archive this item
+            Then I want to list Archived VLMs
+            Then I want to check that item exits in response
+            Then I want to list Active VLMs
+            Then I want to check that item does not exits in response
diff --git a/openecomp-bdd/features/Onboarding/ArchiveItem/ArchiveVsp.feature b/openecomp-bdd/features/Onboarding/ArchiveItem/ArchiveVsp.feature
new file mode 100644
index 0000000..2cc0574
--- /dev/null
+++ b/openecomp-bdd/features/Onboarding/ArchiveItem/ArchiveVsp.feature
@@ -0,0 +1,58 @@
+Feature: Archive and Restore VSP
+
+    Background: Init
+        Given I want to create a VLM
+
+    Scenario: Archive VSP with Draft
+            When I want to create a VSP with onboarding type "NetworkPackage"
+            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 archive this item
+            Then I want to list Archived VSPs
+            Then I want to check that item exits in response
+            Then I want to list Active VSPs
+            Then I want to check that item does not exits in response
+
+    Scenario: Archive Already Archived VSP - Negative
+            When I want to create a VSP with onboarding type "NetworkPackage"
+            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 archive this item
+            Then I want to list Archived VSPs
+            Then I want to check that item exits in response
+            Then I want to list Active VSPs
+            Then I want to check that item does not exits in response
+
+            Then I want the following to fail with error message "Archive item failed, item {item.id} is already Archived"
+            Then I want to archive this item
+
+
+    Scenario: Archive Certified VSP
+            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 to archive this item
+            Then I want to list Archived VSPs
+            Then I want to check that item exits in response
+            Then I want to list Active VSPs
+            Then I want to check that item does not exits in response
\ No newline at end of file
diff --git a/openecomp-bdd/features/Onboarding/ArchiveItem/FilterArchivedVSPpackage.feature b/openecomp-bdd/features/Onboarding/ArchiveItem/FilterArchivedVSPpackage.feature
new file mode 100644
index 0000000..f68eece
--- /dev/null
+++ b/openecomp-bdd/features/Onboarding/ArchiveItem/FilterArchivedVSPpackage.feature
@@ -0,0 +1,40 @@
+Feature: Filter Archived VSP Package Details
+
+  Background: Init
+    Given I want to create a VLM
+
+  Scenario: Active VSP Package
+        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 submit this VSP
+        Then I want to package 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 to list Active VSPs packages
+        Then I want to check that VSP package exits in response
+
+
+  Scenario: Archived VSP Package
+          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 submit this VSP
+          Then I want to package 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 to archive this item
+
+          Then I want to list Archived VSPs packages
+          Then I want to check that VSP package exits in response
+
+
diff --git a/openecomp-bdd/stepDefinitions/General_Steps.js b/openecomp-bdd/stepDefinitions/General_Steps.js
index b9ea72f..b3fb0e9 100644
--- a/openecomp-bdd/stepDefinitions/General_Steps.js
+++ b/openecomp-bdd/stepDefinitions/General_Steps.js
@@ -22,6 +22,11 @@
 const fs = require('fs');
 const util = require('./Utils.js');
 
+function getPath(path, context) {
+	let compiled = _.template(path);
+	return compiled(context);
+}
+
 /**
  * @module ContextData
  * @description  Use with "Given". Use ONLY for local testing when you know the value of the Item you want to use
@@ -183,7 +188,8 @@
  **/
 Then('I want the following to fail with error message {string}', function(string)  {
 	this.context.shouldFail = true;
-	this.context.errorMessage = string;
+	let errorMessage = getPath(string, this.context);
+	this.context.errorMessage = errorMessage;
 });
 
 /**
@@ -228,4 +234,47 @@
 	let str = zip.files[string]._data;
 	this.context.responseData = JSON.parse(str);
 	callback();
+});
+
+/**
+ * @module ResponseData
+ * @description Check that the itemId from context exits in result of responseData
+ * exampleFile ArchiveItem.feature
+ * step I want to check that item exits in response
+ **/
+Then('I want to check that item exits in response', function() {
+
+  const id = this.context.item.id;
+  const results = this.context.responseData.results;
+  var testResult = false;
+
+  for(var i=0; i< results.length; i++){
+     if ( id == results[i].id){
+            testResult = true;
+     }
+  }
+
+   assert.equal(testResult,true);
+});
+
+
+/**
+ * @module ResponseData
+ * @description Check that the itemId from context does NOT exits in result of responseData
+ * exampleFile ArchiveItem.feature
+ * step I want to check that item does not exits in response
+ **/
+Then('I want to check that item does not exits in response', function() {
+
+  const id = this.context.item.id;
+  const results = this.context.responseData.results;
+  var testResult = false;
+
+  for(var i=0; i< results.length; i++){
+     if ( id == results[i].id){
+            testResult = true;
+     }
+  }
+
+   assert.equal(testResult,false);
 });
\ No newline at end of file
diff --git a/openecomp-bdd/stepDefinitions/Item_steps.js b/openecomp-bdd/stepDefinitions/Item_steps.js
index 165df6c..3ff7f20 100644
--- a/openecomp-bdd/stepDefinitions/Item_steps.js
+++ b/openecomp-bdd/stepDefinitions/Item_steps.js
@@ -65,3 +65,27 @@
 	return util.request(this.context, 'PUT', path, inputData);
 });
 
+
+/**
+ * @module Item
+ * @exampleFile ArchiveItem.feature
+ * @step I want to archive this item
+ **/
+Then('I want to archive this item', function()  {
+    let path = '/items/' + this.context.item.id + '/actions'
+    let inputData = {action: 'ARCHIVE'};
+	return util.request(this.context, 'PUT', path, inputData);
+});
+
+
+/**
+ * @module Item
+ * @exampleFile ArchiveItem.feature
+ * @step I want to restore this item
+ **/
+Then('I want to restore this item', function()  {
+    let path = '/items/' + this.context.item.id + '/actions'
+    let inputData = {action: 'RESTORE'};
+	return util.request(this.context, 'PUT', path, inputData);
+});
+
diff --git a/openecomp-bdd/stepDefinitions/VLM_steps.js b/openecomp-bdd/stepDefinitions/VLM_steps.js
index ea75313..35e78b2 100644
--- a/openecomp-bdd/stepDefinitions/VLM_steps.js
+++ b/openecomp-bdd/stepDefinitions/VLM_steps.js
@@ -55,3 +55,25 @@
 	return util.request(this.context, 'DELETE', path);
 });
 
+
+/**
+ * @module VLM
+ * @exampleFile ArchiveItem.feature
+ * @step I want to list Archived VLMs
+ **/
+Then('I want to list Archived VLMs', function()  {
+	let path = '/vendor-license-models/?Status=ARCHIVED';
+	return util.request(this.context, 'GET', path);
+});
+
+/**
+ * @module VLM
+ * @exampleFile ArchiveItem.feature
+ * @step I want to list Active VLMs
+ **/
+Then('I want to list Active VLMs', function()  {
+	let path = '/vendor-license-models';
+	return util.request(this.context, 'GET', path);
+});
+
+
diff --git a/openecomp-bdd/stepDefinitions/VSP_steps.js b/openecomp-bdd/stepDefinitions/VSP_steps.js
index bed8921..1f753fe 100644
--- a/openecomp-bdd/stepDefinitions/VSP_steps.js
+++ b/openecomp-bdd/stepDefinitions/VSP_steps.js
@@ -118,4 +118,65 @@
 Then('I want to delete this VSP', function()  {
 	let path = '/vendor-software-products/' + this.context.item.id ;
 	return util.request(this.context, 'DELETE', path);
+});
+
+/**
+ * @module VSP
+ * @exampleFile ArchiveItem.feature
+ * @step I want to list Archived VSPs
+ **/
+Then('I want to list Archived VSPs', function()  {
+	let path = '/vendor-software-products/?Status=ARCHIVED';
+	return util.request(this.context, 'GET', path);
+});
+
+/**
+ * @module VSP
+ * @exampleFile ArchiveItem.feature
+ * @step I want to list Active VSPs
+ **/
+Then('I want to list Active VSPs', function()  {
+	let path = '/vendor-software-products';
+	return util.request(this.context, 'GET', path);
+});
+
+
+/**
+ * @module VSP
+ * @exampleFile FilterArchivedVSPpackage.feature
+ * @step I want to list Archived VSPs packages
+ **/
+Then('I want to list Archived VSPs packages', function()  {
+	let path = '/vendor-software-products/packages?Status=ARCHIVED';
+	return util.request(this.context, 'GET', path);
+});
+
+/**
+ * @module VSP
+ * @exampleFile FilterArchivedVSPpackage.feature
+ * @step I want to list Active VSPs packages
+ **/
+Then('I want to list Active VSPs packages', function()  {
+	let path = '/vendor-software-products/packages';
+	return util.request(this.context, 'GET', path);
+
+});
+
+/**
+ * @module VSP
+ * @exampleFile FilterArchivedVSPpackage.feature
+ * @step I want to check that VSP package exits in response
+ **/
+Then('I want to check that VSP package exits in response', function()  {
+
+      const packages = this.context.responseData.results;
+      const id = this.context.item.id;
+      var testResult = false;
+
+      for(var i=0; i< packages.length; i++){
+          if (id == packages[i].packageId){
+               testResult = true;
+          }
+      }
+      assert.equal(testResult,true);
 });
\ No newline at end of file