blob: 9990bf2717a9a9bb4b384cec7c7bbff76f589997 [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');
ilanap061ca932019-08-04 10:16:33 +030018const util = require('../cucumber-common/utils/Utils.js');
ilanap637206b2018-02-04 17:06:22 +020019
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
ayalaben705fc2b2018-03-15 15:59:25 +020058
59/**
60 * @module VLM
61 * @exampleFile ArchiveItem.feature
62 * @step I want to list Archived VLMs
63 **/
64Then('I want to list Archived VLMs', function() {
65 let path = '/vendor-license-models/?Status=ARCHIVED';
66 return util.request(this.context, 'GET', path);
67});
68
69/**
70 * @module VLM
71 * @exampleFile ArchiveItem.feature
72 * @step I want to list Active VLMs
73 **/
74Then('I want to list Active VLMs', function() {
75 let path = '/vendor-license-models';
76 return util.request(this.context, 'GET', path);
77});
78
79