2 * Copyright © 2016-2018 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 {When} = require('cucumber');
17 const _ = require('lodash');
18 const util = require('../cucumber-common/utils/Utils.js');
19 _.templateSettings.interpolate = /{([\s\S]+?)}/g;
21 function getPath(path, context) {
22 let compiled = _.template(path);
23 return compiled(context);
27 * @description makes a GET request to the given path (path is appended after the "onboarding-api/v1.0" prefix)<br>
28 * @exampleFile Example_Rest_Calls.feature
29 * @step I want to get path {string}
31 When('I want to get path {string}', function(string) {
32 let path = getPath(string, this.context);
33 return util.request(this.context, 'GET', path);
38 * @description makes a DELETE request to the given path and appends the saved property (path is appended after the "onboarding-api/v1.0" prefix)<br>
39 * @exampleFile Example_Rest_Calls.feature
40 * @step I want to delete for path {string} with the value from saved property {string}
42 When('I want to delete for path {string} with the value from saved property {string}', function(string, string2) {
43 let path = getPath(string, this.context);
44 path += '/' + this.context[string2];
45 return util.request(this.context, 'DELETE', path);
50 * @description makes a DELETE request to the given path and appends the saved property (path is appended after the "onboarding-api/v1.0" prefix)<br>
51 * @exampleFile Example_Rest_Calls.feature
52 * @step I want to delete for path {string} with the value from saved property {string}
54 When('I want to delete for path {string}', function (string) {
55 let path = getPath(string, this.context);
56 //path += '/' + this.context[string2];
57 return util.request(this.context, 'DELETE', path);
62 * @description makes a PUT request to the given path and sends the input data from the context (path is appended after the "onboarding-api/v1.0" prefix)<br>
63 * @exampleFile Example_Rest_Calls.feature
64 * @step I want to update for path {string} with the input data from the context
66 When('I want to update for path {string} with the input data from the context', function(string) {
67 let path = getPath(string, this.context);
68 return util.request(this.context, 'PUT', path, this.context.inputData);
73 * @description makes a POST request to the given path and sends the input data from the context (path is appended after the "onboarding-api/v1.0" prefix)<br>
74 * @exampleFile Example_Rest_Calls.feature
75 * @step I want to create for path {string} with the input data from the context
77 When('I want to create for path {string} with the input data from the context', function(string) {
78 let path = getPath(string, this.context);
79 return util.request(this.context, 'POST', path, this.context.inputData);