2 * Copyright © 2016-2017 European Support Limited
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 const {Then, When} = require('cucumber');
17 const assert = require('assert');
18 const util = require('./Utils.js');
19 const _ = require('lodash');
24 * @description Creates a new VSP with a random name and saves the id and versionId on the context item object and the context vsp object<br>
25 * Input data will be taken from the 'resources/json/createVSP.json' file.
26 * Vendor id and name are taken from the vlm on the context (requires a VLM to be created first).
27 * @exampleFile Example_VSP.feature
28 * @step I want to create a VSP with onboarding type {string}
30 When('I want to create a VSP with onboarding type {string}', function(string) {
31 let inputData = util.getJSONFromFile('resources/json/createVSP.json');
32 inputData.onboardingMethod = string;
33 inputData.vendorName = this.context.vlm.name;
34 inputData.vendorId = this.context.vlm.id;
35 inputData.name = util.random();
36 let path = '/vendor-software-products';
37 return util.request(this.context, 'POST', path, inputData).then(result => {
38 this.context.item = {id : result.data.itemId, versionId: result.data.version.id};
39 this.context.vsp = {id : result.data.itemId, versionId: result.data.version.id};
45 * @description Creates a new VSP with the 'NetowrkPackage' onboarding type and with a random name and saves the id and versionId on the context item object and the context vsp object<br>
46 * Input data will be taken from the 'resources/json/createVSP.json' file.
47 * Vendor id and name are taken from the vlm on the context (requires a VLM to be created first).
48 * @exampleFile Example_VSP.feature
49 * @step I want to create a VSP with onboarding type {string}
51 When('I want to create a VSP with onboarding type Manual', function() {
52 let inputData = util.getJSONFromFile('resources/json/createManualVSP.json');
53 inputData.vendorName = this.context.vlm.name;
54 inputData.vendorId = this.context.vlm.id;
55 inputData.name = util.random();
56 inputData.licensingVersion = this.context.licensingVersion;
57 inputData.licensingData.licenseAgreement = this.context.licenseAgreement;
58 inputData.licensingData.featureGroups[0] = this.context.featureGroupId;
59 let path = '/vendor-software-products';
60 return util.request(this.context, 'POST', path, inputData).then(result => {
61 this.context.item = {id : result.data.itemId, versionId: result.data.version.id};
62 this.context.vsp = {id : result.data.itemId, versionId: result.data.version.id};
69 * @exampleFile Example_VSP.feature
70 * @step I want to submit this VSP
72 Then('I want to submit this VSP', function () {
73 let path = '/vendor-software-products/' + this.context.item.id + '/versions/' + this.context.item.versionId + '/actions';
74 let inputData = {action: 'Submit'};
75 return util.request(this.context, 'PUT', path, inputData);
80 * @exampleFile Example_VSP.feature
81 * @step I want to package this VSP
83 Then('I want to package this VSP', function () {
84 let path = '/vendor-software-products/' + this.context.item.id + '/versions/' + this.context.item.versionId + '/actions';
85 let inputData = {action: 'Create_Package'};
86 return util.request(this.context, 'PUT', path, inputData);
91 * @description Adds a component to the current item
92 * @exampleFile Example_VSP.feature
93 * @step I want to add a component
95 Then('I want to add a component', function () {
96 let path = '/vendor-software-products/' + this.context.item.id + '/versions/' + this.context.item.versionId + '/components';
97 let inputData = {name: 'Cucumber Name', displayName: 'Cucumber', description: 'Cucumber Description'};
98 return util.request(this.context, 'POST', path, inputData).then(result => {
99 this.context.componentId = result.data.vfcId;
106 * @description Downloads the packaged file for this component to the given path
107 * @exampleFile Example_VSP.feature
108 * @step I want to get the package for this Item to path {string}
110 When('I want to get the package for this Item to path {string}', function (string, callback) {
111 let path = '/vendor-software-products/packages/' + this.context.item.id;
112 return [util.download(this.context, path, string, callback)];
118 * @exampleFile DeleteVSPDraft.feature
119 * @step I want to delete this VSP
121 Then('I want to delete this VSP', function() {
122 let path = '/vendor-software-products/' + this.context.item.id ;
123 return util.request(this.context, 'DELETE', path);
128 * @exampleFile ArchiveItem.feature
129 * @step I want to list Archived VSPs
131 Then('I want to list Archived VSPs', function() {
132 let path = '/vendor-software-products/?Status=ARCHIVED';
133 return util.request(this.context, 'GET', path);
138 * @exampleFile ArchiveItem.feature
139 * @step I want to list Active VSPs
141 Then('I want to list Active VSPs', function() {
142 let path = '/vendor-software-products';
143 return util.request(this.context, 'GET', path);
149 * @exampleFile FilterArchivedVSPpackage.feature
150 * @step I want to list Archived VSPs packages
152 Then('I want to list Archived VSPs packages', function() {
153 let path = '/vendor-software-products/packages?Status=ARCHIVED';
154 return util.request(this.context, 'GET', path);
159 * @exampleFile FilterArchivedVSPpackage.feature
160 * @step I want to list Active VSPs packages
162 Then('I want to list Active VSPs packages', function() {
163 let path = '/vendor-software-products/packages';
164 return util.request(this.context, 'GET', path);
170 * @exampleFile FilterArchivedVSPpackage.feature
171 * @step I want to check that VSP package exits in response
173 Then('I want to check that VSP package exits in response', function() {
175 const packages = this.context.responseData.results;
176 const id = this.context.item.id;
177 var testResult = false;
179 for(var i=0; i< packages.length; i++){
180 if (id == packages[i].packageId){
184 assert.equal(testResult,true);