blob: ea753137899d15830a51f180e1238529998dcc29 [file] [log] [blame]
ilanap637206b2018-02-04 17:06:22 +02001/*
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, Given} = require('cucumber');
17const assert = require('assert');
18const util = require('./Utils.js');
19
20/**
21 * @module VLM
22 * @description Creates a new VLM with a random name and saves the id and versionId on the context item object and the context vlm object<br>
23 * Input data will be taken from the 'resources/json/createVLM.json' file.
24 *@exampleFile Example_VLM.feature
25 * @step I want to create a VLM
26 **/
27When('I want to create a VLM', function() {
28 let inputData = util.getJSONFromFile('resources/json/createVLM.json');
29 inputData.vendorName = util.random();
30 let path = '/vendor-license-models';
31 return util.request(this.context, 'POST', path, inputData).then(result => {
32 this.context.item ={id : result.data.itemId, versionId: result.data.version.id};
33 this.context.vlm = {id : result.data.itemId, name : inputData.vendorName};
34 });
35});
36
37/**
38 * @module VLM
39 * @exampleFile Example_VLM.feature
40 * @step I want to submit this VLM
41 **/
42Then('I want to submit this VLM', function() {
43 let inputData = {action: 'Submit'};
44 let path = '/vendor-license-models/' + this.context.item.id + '/versions/' + this.context.item.versionId + '/actions';
45 return util.request(this.context, 'PUT', path, inputData);
46});
47
ayalabenaad27812018-02-18 10:03:22 +020048/**
49 * @module VLM
50 * @exampleFile DeleteVLMDraft.feature
51 * @step I want to delete this VLM
52 **/
53Then('I want to delete this VLM', function() {
54 let path = '/vendor-license-models/' + this.context.item.id ;
55 return util.request(this.context, 'DELETE', path);
56});
57