package org.fundacionjala.automation.scenario.steps.admin.location;

import org.fundacionjala.automation.framework.pages.admin.home.AdminPage;
import org.fundacionjala.automation.framework.pages.admin.login.LoginPage;
import org.fundacionjala.automation.framework.utils.api.managers.LocationAPIManager;
import org.fundacionjala.automation.framework.utils.api.objects.admin.Location;
import org.fundacionjala.automation.framework.utils.common.BrowserManager;
import org.fundacionjala.automation.framework.utils.common.PropertiesReader;

import cucumber.api.java.en.Given;

public class LocationGivenSteps {
	
	@Given("^I am logged as \"([^\"]*)\" with password \"([^\"]*)\"$")
	public void logInWithAnAccount(String userName, 
				       String password) throws Throwable {
		
		BrowserManager.openBrowser();
		LoginPage loginPage = new LoginPage();
		AdminPage adminPage = new AdminPage();
		
		loginPage
			.setUserName(userName)
			.setPassword(password)
			.clickOnSigInButton();
		adminPage.leftMenu.clickOnEmailServerButton();
	}
	
	@Given("^I have a location added with name: \"([^\"]*)\", display name \"([^\"]*)\" and description \"([^\"]*)\"$")
	public void addLocation(String name, 
				String displayName, 
				String description) throws Throwable {
		try {
			LocationAPIManager.postRequest(PropertiesReader.getServiceURL() 
					+ "/locations", 
					new Location(name, displayName, "", "", description));

			
		} catch (Exception e) {
		}
		}
}

package org.fundacionjala.automation.scenario.steps.admin.location;

import org.fundacionjala.automation.framework.pages.admin.login.LoginPage;
import org.fundacionjala.automation.framework.utils.api.managers.LocationAPIManager;
import org.fundacionjala.automation.framework.utils.api.objects.admin.Location;
import org.fundacionjala.automation.framework.utils.common.BrowserManager;
import org.fundacionjala.automation.framework.utils.common.PropertiesReader;

import cucumber.api.java.en.Given;

public class LocationGivenSteps {
	
	@Given("^I am logged as \"([^\"]*)\" with password \"([^\"]*)\"$")
	public void logInWithAnAccount(String userName, 
				       String password) throws Throwable {
		
		BrowserManager.openBrowser();
		LoginPage loginPage = new LoginPage();
		
		loginPage
			.setUserName(userName)
			.setPassword(password)
			.clickOnSigInButton();
	}
	
	@Given("^I have a location added with name: \"([^\"]*)\", display name \"([^\"]*)\" and description \"([^\"]*)\"$")
	public void addLocation(String name, 
				String displayName, 
				String description) throws Throwable {
		try {
			LocationAPIManager.postRequest(PropertiesReader.getServiceURL() 
					+ "/locations", 
					new Location(name, displayName, "", "", description));

			
		} catch (Exception e) {
		}
		}
}

Fix Scenario: LocationGivenSteps login with an account method fixed