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');
21 When('I want to create a VF', function() {
22 let inputData = util.getJSONFromFile('resources/json/operation/createVF.json');
24 inputData.name = util.random();
25 inputData.tags[0] = util.random();
27 var type = "resources";
28 let path = '/catalog/' + type;
29 return util.request(this.context, 'POST', path, inputData, false, 'catalog').then(result => {
30 this.context.component = {uniqueId : result.data.uniqueId, type : type, id : result.data.inputs[0].uniqueId};
34 When('I want to create a Service', function() {
35 let inputData = util.getJSONFromFile('resources/json/operation/createService.json');
37 inputData.name = util.random();
38 inputData.tags[0] = util.random();
40 var type = "services";
41 let path = '/catalog/' + type;
42 return util.request(this.context, 'POST', path, inputData, false, 'catalog').then(result => {
43 this.context.component = {uniqueId : result.data.uniqueId, type : type, id : result.data.inputs[0].uniqueId};
49 var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
51 for (var i = 0; i < 5; i++)
52 text += possible.charAt(Math.floor(Math.random() * possible.length));
57 When('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');
61 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();
67 return util.request(this.context, 'POST', path, inputData, false, 'catalog').then(result => {
68 this.context.operation = {uniqueId : result.data.uniqueId, operationType : result.data.operationType};
72 When('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();
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};
83 When('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');
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();
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};
100 When('I want to list Operations', function () {
101 let path = '/catalog/'+ this.context.component.type + '/' + this.context.component.uniqueId + '/filteredDataByParams?include=interfaces';
102 return util.request(this.context, 'GET', path, null, false, 'catalog').then((result)=> {
106 When('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;
108 return util.request(this.context, 'GET', path, null, false, 'catalog').then((result)=> {
109 this.context.operation = {uniqueId : result.data.uniqueId, operationType : result.data.operationType};
113 When('I want to update an Operation', function () {
114 let inputData = util.getJSONFromFile('resources/json/operation/updateOperation.json');
115 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();
121 return util.request(this.context, 'PUT', path, inputData, false, 'catalog').then((result)=> {
122 this.context.operation = {uniqueId : result.data.uniqueId, operationType : result.data.operationType};
127 When('I want to delete an Operation', function() {
128 let path = '/catalog/'+ this.context.component.type + '/'+ this.context.component.uniqueId +'/interfaceOperations/' + this.context.operation.uniqueId;
129 return util.request(this.context, 'DELETE', path, null, false, 'catalog');
133 When('I want to checkin this component', function () {
134 let path = '/catalog/'+ this.context.component.type + '/' + this.context.component.uniqueId + '/lifecycleState/CHECKIN' ;
135 let inputData = {userRemarks: 'checkin'};
136 return util.request(this.context, 'POST', path, inputData, false, 'catalog').then((result)=> {
137 this.context.component = {uniqueId : result.data.uniqueId, type : this.context.component.type};
142 Then('I want to submit this component', function () {
143 let path = '/catalog/'+ this.context.component.type + '/' + this.context.component.uniqueId + '/lifecycleState/certificationRequest' ;
144 let inputData = {userRemarks: 'submit'};
145 return util.request(this.context, 'POST', path, inputData, false, 'catalog').then((result)=> {
146 this.context.component = {uniqueId : result.data.uniqueId};
150 Then('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'};
153 return util.request(this.context, 'POST', path, inputData, false, 'catalog').then((result)=> {
154 this.context.component = {uniqueId : result.data.uniqueId};