/*
 * Copyright © 2016-2017 European Support Limited
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
const {Then, When, Given} = require('cucumber');
const assert = require('assert');
const util = require('../cucumber-common/utils/Utils.js');

/**
 * @module VLM
 * @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>
 *     Input data  will be taken from the 'resources/json/createVLM.json' file.
 *@exampleFile Example_VLM.feature
 * @step I want to create a VLM
 **/
When('I want to create a VLM', function()  {
	let inputData = util.getJSONFromFile('resources/json/createVLM.json');
	inputData.vendorName = util.random();
	let path = '/vendor-license-models';
	return util.request(this.context, 'POST', path, inputData).then(result => {
		this.context.item ={id : result.data.itemId, versionId: result.data.version.id};
		this.context.vlm = {id : result.data.itemId, name : inputData.vendorName};
	});
});

/**
 * @module VLM
 * @exampleFile Example_VLM.feature
 * @step I want to submit this VLM
 **/
Then('I want to submit this VLM', function()  {
	let inputData = {action: 'Submit'};
	let path = '/vendor-license-models/' + this.context.item.id + '/versions/' + this.context.item.versionId + '/actions';
	return util.request(this.context, 'PUT', path, inputData);
});

/**
 * @module VLM
 * @exampleFile DeleteVLMDraft.feature
 * @step I want to delete this VLM
 **/
Then('I want to delete this VLM', function()  {
	let path = '/vendor-license-models/' + this.context.item.id ;
	return util.request(this.context, 'DELETE', path);
});


/**
 * @module VLM
 * @exampleFile ArchiveItem.feature
 * @step I want to list Archived VLMs
 **/
Then('I want to list Archived VLMs', function()  {
	let path = '/vendor-license-models/?Status=ARCHIVED';
	return util.request(this.context, 'GET', path);
});

/**
 * @module VLM
 * @exampleFile ArchiveItem.feature
 * @step I want to list Active VLMs
 **/
Then('I want to list Active VLMs', function()  {
	let path = '/vendor-license-models';
	return util.request(this.context, 'GET', path);
});


