blob: 1bfd4c30a6b248e526137a525bcc8554557d49a0 [file] [log] [blame]
mojahidi65204c62018-04-25 18:39:53 +05301/*
2 * Copyright © 2016-2017 European Support Limited
3 *
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
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
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.
15 */
16const {Then, When} = require('cucumber');
17const assert = require('assert');
18const util = require('./Utils.js');
19
20
21When('I want to create a VF', function() {
22 let inputData = util.getJSONFromFile('resources/json/operation/createVF_From_Catalog.json');
23
24 inputData.name = util.random();
25 inputData.tags[0] = util.random();
26
27 let path = '/catalog/resources';
28 return util.request(this.context, 'POST', path, inputData, false, 'vf').then(result => {
29 this.context.item = {uniqueId : result.data.uniqueId, id : result.data.inputs[0].uniqueId, name : result.data.inputs[0].name};
30 this.context.vf = {uniqueId : result.data.uniqueId, id : result.data.inputs[0].uniqueId, name : result.data.inputs[0].name};
31});
32});
33
34function makeType() {
35 var text = "";
36 var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
37
38 for (var i = 0; i < 5; i++)
39 text += possible.charAt(Math.floor(Math.random() * possible.length));
40
41 return text;
42}
43
44When('I want to create an Operation', function() {
45 let inputData = util.getJSONFromFile('resources/json/operation/createOperation.json');
mojahidi65204c62018-04-25 18:39:53 +053046 let path = '/catalog/resources/' + this.context.vf.uniqueId +'/interfaceOperations';
47
48 inputData.interfaceOperations.create.operationType = makeType();
mojahidia8480d12018-07-19 12:35:31 +053049 inputData.interfaceOperations.create.description = makeType();
mojahidi4720f5a2018-06-22 16:37:52 +053050 inputData.interfaceOperations.create.inputParams.listToscaDataDefinition[0].paramName = util.random();
51 inputData.interfaceOperations.create.inputParams.listToscaDataDefinition[0].paramId = this.context.vf.id;
52 inputData.interfaceOperations.create.outputParams.listToscaDataDefinition[0].paramName = util.random();
53 inputData.interfaceOperations.create.outputParams.listToscaDataDefinition[0].paramId = this.context.vf.id;
mojahidia8480d12018-07-19 12:35:31 +053054 inputData.interfaceOperations.create.workflowId = makeType();
55 inputData.interfaceOperations.create.workflowVersionId = makeType();
mojahidi4720f5a2018-06-22 16:37:52 +053056
57 return util.request(this.context, 'POST', path, inputData, false, 'vf').then(result => {
58 this.context.item = {uniqueId : result.data.uniqueId, operationType : result.data.operationType};
59 this.context.operation = {uniqueId : result.data.uniqueId, operationType : result.data.operationType};
60});
61});
62
mojahidi65204c62018-04-25 18:39:53 +053063
mojahidia8480d12018-07-19 12:35:31 +053064
mojahidi65204c62018-04-25 18:39:53 +053065When('I want to list Operations', function () {
66 let path = '/catalog/resources/' + this.context.vf.uniqueId + '/filteredDataByParams?include=interfaces';
67 return util.request(this.context, 'GET', path, null, false, 'vf').then((result)=> {
68});
69});
70
71
72When('I want to get an Operation by Id', function () {
73 let path = '/catalog/resources/' + this.context.vf.uniqueId + '/interfaceOperations/' + this.context.operation.uniqueId;
74 return util.request(this.context, 'GET', path, null, false, 'vf').then((result)=> {
75 this.context.item ={uniqueId : result.data.uniqueId, operationType: result.data.operationType};
76 this.context.operation = {uniqueId : result.data.uniqueId, operationType : result.data.operationType};
77});
78});
79
80
81When('I want to update an Operation', function () {
82 let inputData = util.getJSONFromFile('resources/json/operation/updateOperation.json');
83 let path = '/catalog/resources/' + this.context.vf.uniqueId + '/interfaceOperations/';
84 inputData.interfaceOperations.create.uniqueId = this.context.operation.uniqueId;
85 inputData.interfaceOperations.create.operationType = this.context.operation.operationType;
86 inputData.interfaceOperations.create.inputParams.listToscaDataDefinition[0].paramName = util.random();
87 inputData.interfaceOperations.create.inputParams.listToscaDataDefinition[0].paramId = this.context.vf.id;
88 return util.request(this.context, 'PUT', path, inputData, false, 'vf').then((result)=> {
89 this.context.item ={uniqueId : result.data.uniqueId, operationType: result.data.operationType};
90 this.context.operation = {uniqueId : result.data.uniqueId, operationType : result.data.operationType};
91});
92});
93
94
95When('I want to delete an Operation', function() {
96 let path = '/catalog/resources/' + this.context.vf.uniqueId + '/interfaceOperations/' + this.context.operation.uniqueId;
97 return util.request(this.context, 'DELETE', path, null, false, 'vf');
98});
99
100
101When('I want to checkin this VF', function () {
102 let path = '/catalog/resources/' + this.context.vf.uniqueId + '/lifecycleState/CHECKIN' ;
103 let inputData = {userRemarks: 'checkin'};
104 return util.request(this.context, 'POST', path, inputData, false, 'vf').then((result)=> {
105 this.context.item ={uniqueId : result.data.uniqueId};
106 this.context.vf = {uniqueId : result.data.uniqueId};
107});
108});
109
110
111Then('I want to submit this VF', function () {
112 let path = '/catalog/resources/' + this.context.vf.uniqueId + '/lifecycleState/certificationRequest' ;
113 let inputData = {userRemarks: 'submit'};
114 return util.request(this.context, 'POST', path, inputData, false, 'vf').then((result)=> {
115 this.context.item ={uniqueId : result.data.uniqueId};
116 this.context.vf = {uniqueId : result.data.uniqueId};
117});
118});
119
120
121
122