blob: 408db9e9f8ec1d62bdfda97930e01e8decaef714 [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() {
mojahidi5082ac82018-09-07 11:07:49 +053022 let inputData = util.getJSONFromFile('resources/json/operation/createVF.json');
mojahidi65204c62018-04-25 18:39:53 +053023
24 inputData.name = util.random();
25 inputData.tags[0] = util.random();
26
mojahidi5082ac82018-09-07 11:07:49 +053027 var type = "resources";
28 let path = '/catalog/' + type;
siddharth0905b734ea22018-11-22 13:37:31 +053029 return util.request(this.context, 'POST', path, inputData, false, 'catalog').then(result => {
mojahidi5082ac82018-09-07 11:07:49 +053030 this.context.component = {uniqueId : result.data.uniqueId, type : type, id : result.data.inputs[0].uniqueId};
31});
32});
33
34When('I want to create a Service', function() {
35 let inputData = util.getJSONFromFile('resources/json/operation/createService.json');
36
37 inputData.name = util.random();
38 inputData.tags[0] = util.random();
39
40 var type = "services";
41 let path = '/catalog/' + type;
siddharth0905b734ea22018-11-22 13:37:31 +053042 return util.request(this.context, 'POST', path, inputData, false, 'catalog').then(result => {
mojahidi5082ac82018-09-07 11:07:49 +053043 this.context.component = {uniqueId : result.data.uniqueId, type : type, id : result.data.inputs[0].uniqueId};
mojahidi65204c62018-04-25 18:39:53 +053044});
45});
46
47function makeType() {
48 var text = "";
49 var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
50
51 for (var i = 0; i < 5; i++)
52 text += possible.charAt(Math.floor(Math.random() * possible.length));
53
54 return text;
55}
56
mojahidi5082ac82018-09-07 11:07:49 +053057When('I want to create an Operation with input output', function() {
58 let path = '/catalog/' + this.context.component.type + '/' + this.context.component.uniqueId + '/interfaceOperations';
59 let inputData = util.getJSONFromFile('resources/json/operation/createOperationWithInputOutput.json');
mojahidi65204c62018-04-25 18:39:53 +053060
mojahidi5082ac82018-09-07 11:07:49 +053061 inputData.interfaceOperations.operation.inputParams.listToscaDataDefinition[0].name = util.random();
62 inputData.interfaceOperations.operation.inputParams.listToscaDataDefinition[0].property = this.context.component.id;
63 inputData.interfaceOperations.operation.outputParams.listToscaDataDefinition[0].name = util.random();
64 inputData.interfaceOperations.operation.operationType = makeType();
65 inputData.interfaceOperations.operation.description = makeType();
mojahidi4720f5a2018-06-22 16:37:52 +053066
siddharth0905b734ea22018-11-22 13:37:31 +053067 return util.request(this.context, 'POST', path, inputData, false, 'catalog').then(result => {
mojahidi65204c62018-04-25 18:39:53 +053068 this.context.operation = {uniqueId : result.data.uniqueId, operationType : result.data.operationType};
69});
70});
71
siddharth0905b734ea22018-11-22 13:37:31 +053072When('I want to create an Operation', function() {
73 let path = '/catalog/' + this.context.component.type + '/' + this.context.component.uniqueId + '/interfaceOperations';
74 let inputData = util.getJSONFromFile('resources/json/operation/createOperation.json');
75 inputData.interfaceOperations.operation.operationType = makeType();
76 inputData.interfaceOperations.operation.description = makeType();
77
78 return util.request(this.context, 'POST', path, inputData, false, 'catalog').then(result => {
79 this.context.operation = {uniqueId : result.data.uniqueId, operationType : result.data.operationType};
80});
81});
82
83When('I want to create an Operation with workflow', function() {
84 let path = '/catalog/' + this.context.component.type + '/' + this.context.component.uniqueId + '/interfaceOperations';
85 let inputData = util.getJSONFromFile('resources/json/operation/createOperation-with-workflow.json');
86
87 inputData.interfaceOperations.operation.inputParams.listToscaDataDefinition[0].name = util.random();
88 inputData.interfaceOperations.operation.inputParams.listToscaDataDefinition[0].property = this.context.component.id;
89 inputData.interfaceOperations.operation.outputParams.listToscaDataDefinition[0].name = util.random();
90 inputData.interfaceOperations.operation.operationType = makeType();
91 inputData.interfaceOperations.operation.description = makeType();
92 inputData.interfaceOperations.operation.workflowId = makeType();
93 inputData.interfaceOperations.operation.workflowVersionId = makeType();
94
95 return util.request(this.context, 'POST', path, inputData, false, 'catalog').then(result => {
96 this.context.operation = {uniqueId : result.data.uniqueId, operationType : result.data.operationType};
97});
98});
mojahidi65204c62018-04-25 18:39:53 +053099
mojahidi5082ac82018-09-07 11:07:49 +0530100When('I want to list Operations', function () {
101 let path = '/catalog/'+ this.context.component.type + '/' + this.context.component.uniqueId + '/filteredDataByParams?include=interfaces';
siddharth0905b734ea22018-11-22 13:37:31 +0530102 return util.request(this.context, 'GET', path, null, false, 'catalog').then((result)=> {
mojahidi5082ac82018-09-07 11:07:49 +0530103 });
104});
105
106When('I want to get an Operation by Id', function () {
107 let path = '/catalog/'+ this.context.component.type + '/' + this.context.component.uniqueId + '/interfaceOperations/' + this.context.operation.uniqueId;
siddharth0905b734ea22018-11-22 13:37:31 +0530108 return util.request(this.context, 'GET', path, null, false, 'catalog').then((result)=> {
mojahidi5082ac82018-09-07 11:07:49 +0530109 this.context.operation = {uniqueId : result.data.uniqueId, operationType : result.data.operationType};
110});
111});
112
mojahidi65204c62018-04-25 18:39:53 +0530113When('I want to update an Operation', function () {
114 let inputData = util.getJSONFromFile('resources/json/operation/updateOperation.json');
mojahidi5082ac82018-09-07 11:07:49 +0530115 let path = '/catalog/'+ this.context.component.type + '/'+ this.context.component.uniqueId +'/interfaceOperations';
116 inputData.interfaceOperations.operation.uniqueId = this.context.operation.uniqueId;
117 inputData.interfaceOperations.operation.operationType = this.context.operation.operationType;
118 inputData.interfaceOperations.operation.inputParams.listToscaDataDefinition[0].name = util.random();
119 inputData.interfaceOperations.operation.inputParams.listToscaDataDefinition[0].property = this.context.component.id;
120 inputData.interfaceOperations.operation.outputParams.listToscaDataDefinition[0].name = util.random();
siddharth0905b734ea22018-11-22 13:37:31 +0530121 return util.request(this.context, 'PUT', path, inputData, false, 'catalog').then((result)=> {
mojahidi5082ac82018-09-07 11:07:49 +0530122 this.context.operation = {uniqueId : result.data.uniqueId, operationType : result.data.operationType};
mojahidi65204c62018-04-25 18:39:53 +0530123});
124});
125
126
127When('I want to delete an Operation', function() {
mojahidi5082ac82018-09-07 11:07:49 +0530128 let path = '/catalog/'+ this.context.component.type + '/'+ this.context.component.uniqueId +'/interfaceOperations/' + this.context.operation.uniqueId;
siddharth0905b734ea22018-11-22 13:37:31 +0530129 return util.request(this.context, 'DELETE', path, null, false, 'catalog');
mojahidi65204c62018-04-25 18:39:53 +0530130});
131
132
mojahidi5082ac82018-09-07 11:07:49 +0530133When('I want to checkin this component', function () {
134 let path = '/catalog/'+ this.context.component.type + '/' + this.context.component.uniqueId + '/lifecycleState/CHECKIN' ;
mojahidi65204c62018-04-25 18:39:53 +0530135 let inputData = {userRemarks: 'checkin'};
siddharth0905b734ea22018-11-22 13:37:31 +0530136 return util.request(this.context, 'POST', path, inputData, false, 'catalog').then((result)=> {
mojahidi5082ac82018-09-07 11:07:49 +0530137 this.context.component = {uniqueId : result.data.uniqueId, type : this.context.component.type};
mojahidi65204c62018-04-25 18:39:53 +0530138});
139});
140
141
mojahidi5082ac82018-09-07 11:07:49 +0530142Then('I want to submit this component', function () {
143 let path = '/catalog/'+ this.context.component.type + '/' + this.context.component.uniqueId + '/lifecycleState/certificationRequest' ;
mojahidi65204c62018-04-25 18:39:53 +0530144 let inputData = {userRemarks: 'submit'};
siddharth0905b734ea22018-11-22 13:37:31 +0530145 return util.request(this.context, 'POST', path, inputData, false, 'catalog').then((result)=> {
146 this.context.component = {uniqueId : result.data.uniqueId};
mojahidi65204c62018-04-25 18:39:53 +0530147});
148});
149
mojahidi5082ac82018-09-07 11:07:49 +0530150Then('I want to certify this component', function () {
151 let path = '/catalog/'+ this.context.component.type +'/' + this.context.component.uniqueId + '/lifecycleState/certify' ;
152 let inputData = {userRemarks: 'certify'};
siddharth0905b734ea22018-11-22 13:37:31 +0530153 return util.request(this.context, 'POST', path, inputData, false, 'catalog').then((result)=> {
mojahidi5082ac82018-09-07 11:07:49 +0530154 this.context.component = {uniqueId : result.data.uniqueId};
155});
156});