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 { setWorldConstructor } = require('cucumber');
17 const _ = require('lodash');
19 let config = require('../config.json');
22 localConfig = require('../devConfig.json');
25 localConfig = require('../jenkinsConfig.json');
27 console.error("no env configuration was found!");
31 config = _.merge(config, localConfig);
32 var {setDefaultTimeout} = require('cucumber');
37 * @description Context that is used per feature file and can be accessed as 'this.context' in all steps.<Br>
39 * Contains the following items:<br>
40 * <li>this.context.server <ul>REST server and onboarding prefix including version. set either in configuration file or from the command line or SERVER environment variable</ul>
41 * <li>this.context <ul>Object with properties that were saved in the steps.</ul>
42 * <li>this.context.inputdata <ul><b>Automatically updated with the last responseData from the Rest call</b><br>Object with properties that were prepares in the steps.</ul>
43 * <li>this.context.responseData <ul>Response from the last REST call.</ul>
46 constructor(options) {
48 this.context.headers = {};
50 for (typeName in config) {
51 this.context.headers[typeName] = {};
52 if (config[typeName].user) {
53 this.context.headers[typeName]['USER_ID'] = config[typeName].user;
57 this.context.item = {id: null, versionId: null, componentId: null};
59 this.context.shouldFail = false;
60 this.context.errorCode = null;
61 this.context.inputData = null;
62 this.context.responseData = null;
64 this.context.defaultServerType = 'workflow';
68 let context = this.context;
69 this.context.getUrlForType = (function(type) {
70 var _server = context.server;
72 return function(type) {
73 let typeData = _config["workflow"];
74 let _url = _config.protocol + '://' +
75 typeData.server + ':' +
82 setDefaultTimeout(60 * 1000);
87 setWorldConstructor(CustomWorld);