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('../cucumber-common/utils/Utils.js');
21 When('I want to create a VF', function() {
22 let inputData = util.getJSONFromFile('resources/json/createVFWithoutCSAR.json');
24 var resourceName = util.random();
25 inputData.name = resourceName;
26 inputData.tags[0] = resourceName;
28 var type = "resources";
29 let path = '/catalog/' + type;
30 return util.request(this.context, 'POST', path, inputData, 'catalog').then(result => {
31 this.context.component = {uniqueId : result.data.uniqueId, type : type, id : result.data.inputs[0].uniqueId};
35 When('I want to create a Service', function() {
36 let inputData = util.getJSONFromFile('resources/json/createService.json');
38 var serviceName = util.random();
39 inputData.name = serviceName;
40 inputData.tags[0] = serviceName;
42 var type = "services";
43 let path = '/catalog/' + type;
44 return util.request(this.context, 'POST', path, inputData, 'catalog').then(result => {
45 this.context.component = {uniqueId : result.data.uniqueId, type : type, id : result.data.inputs[0].uniqueId};
51 var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
53 for (var i = 0; i < 5; i++)
54 text += possible.charAt(Math.floor(Math.random() * possible.length));
59 When('I want to create an Operation', function() {
60 let path = '/catalog/' + this.context.component.type + '/' + this.context.component.uniqueId + '/interfaceOperations';
61 let inputData = util.getJSONFromFile('resources/json/interfaceOperation/createInterfaceOperations.json');
62 var operationName = makeType();
63 var interfaceType = makeType();
64 inputData.interfaces.interface1.type = interfaceType;
65 inputData.interfaces.interface1.operations.delete.name = operationName;
66 inputData.interfaces.interface1.operations.delete.inputs.listToscaDataDefinition[0].name = util.random();
67 inputData.interfaces.interface1.operations.delete.inputs.listToscaDataDefinition[0].inputId = this.context.component.id;
68 inputData.interfaces.interface1.operations.delete.outputs.listToscaDataDefinition[0].name = util.random();
69 inputData.interfaces.interface1.operations.delete.description = operationName + " description";
71 return util.request(this.context, 'POST', path, inputData, 'catalog').then(result => {
72 {intOperations = result.data.interfaces[0].operations};
73 this.context.interface = { interfaceUniqueId : result.data.interfaces[0].uniqueId,
74 interfaceType : result.data.interfaces[0].type,
75 operationUniqueId : Object.keys(intOperations)[0]
80 When('I want to update an Operation', function () {
81 let inputData = util.getJSONFromFile('resources/json/interfaceOperation/updateInterfaceOperation.json');
82 let path = '/catalog/'+ this.context.component.type + '/'+ this.context.component.uniqueId +'/interfaceOperations';
83 inputData.interfaces.interface1.operations.delete.uniqueId = this.context.interface.operationUniqueId;
84 inputData.interfaces.interface1.type=this.context.interface.interfaceType;
85 inputData.interfaces.interface1.operations.delete.inputs.listToscaDataDefinition[0].name = util.random();
86 inputData.interfaces.interface1.operations.delete.inputs.listToscaDataDefinition[0].inputId = this.context.component.id;
87 inputData.interfaces.interface1.operations.delete.outputs.listToscaDataDefinition[0].name = util.random();
89 return util.request(this.context, 'PUT', path, inputData, 'catalog').then((result)=> {
90 {intOperations = result.data.interfaces[0].operations};
91 this.context.interface = { interfaceUniqueId : result.data.interfaces[0].uniqueId,
92 interfaceType : result.data.interfaces[0].type,
93 operationUniqueId : Object.keys(intOperations)[0]
98 When('I want to get an Operation by Id', function () {
99 let path = '/catalog/'+ this.context.component.type + '/' + this.context.component.uniqueId + '/interfaces/' +
100 this.context.interface.interfaceUniqueId + '/operations/' +this.context.interface.operationUniqueId ;
101 return util.request(this.context, 'GET', path, null, 'catalog').then((result)=> {
103 {intOperations = result.data.interfaces[0].operations};
104 this.context.interface = { interfaceUniqueId : result.data.interfaces[0].uniqueId,
105 interfaceType : result.data.interfaces[0].type,
106 operationUniqueId : Object.keys(intOperations)[0]
112 When('I want to list Operations', function () {
113 let path = '/catalog/'+ this.context.component.type + '/' + this.context.component.uniqueId + '/filteredDataByParams?include=interfaces';
114 return util.request(this.context, 'GET', path, null, 'catalog').then((result)=> {
119 When('I want to delete an Operation', function() {
120 let path = '/catalog/'+ this.context.component.type + '/'+ this.context.component.uniqueId +'/interfaces/' +
121 this.context.interface.interfaceUniqueId + '/operations/' +this.context.interface.operationUniqueId ;
122 return util.request(this.context, 'DELETE', path, null, 'catalog');
126 When('I want to checkin this component', function () {
127 let path = '/catalog/'+ this.context.component.type + '/' + this.context.component.uniqueId + '/lifecycleState/CHECKIN' ;
128 let inputData = {userRemarks: 'checkin'};
129 return util.request(this.context, 'POST', path, inputData, 'catalog').then((result)=> {
130 this.context.component = {uniqueId : result.data.uniqueId, type : this.context.component.type};
135 Then('I want to submit this component', function () {
136 let path = '/catalog/'+ this.context.component.type + '/' + this.context.component.uniqueId + '/lifecycleState/certificationRequest' ;
137 let inputData = {userRemarks: 'submit'};
138 return util.request(this.context, 'POST', path, inputData, 'catalog').then((result)=> {
139 this.context.component = {uniqueId : result.data.uniqueId};
143 Then('I want to certify this component', function () {
144 let path = '/catalog/'+ this.context.component.type +'/' + this.context.component.uniqueId + '/lifecycleState/certify' ;
145 let inputData = {userRemarks: 'certify'};
146 return util.request(this.context, 'POST', path, inputData, 'catalog').then((result)=> {
147 this.context.component = {uniqueId : result.data.uniqueId};