CI Test for get all interface lifecycle types
[sdc.git] / cucumber-js-test-apis-ci / stepDefinitions / VLM_steps.js
1 /*
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  */
16 const {Then, When, Given} = require('cucumber');
17 const assert = require('assert');
18 const 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  **/
27 When('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  **/
42 Then('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
48 /**
49  * @module VLM
50  * @exampleFile DeleteVLMDraft.feature
51  * @step I want to delete this VLM
52  **/
53 Then('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
58
59 /**
60  * @module VLM
61  * @exampleFile ArchiveItem.feature
62  * @step I want to list Archived VLMs
63  **/
64 Then('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  **/
74 Then('I want to list Active VLMs', function()  {
75         let path = '/vendor-license-models';
76         return util.request(this.context, 'GET', path);
77 });
78
79