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) {
		}
		}
}

@@ -66,82 +66,8 @@
 n;%0A%0A
-import org.fundacionjala.automation.framework.pages.admin.home.AdminPage;%0A
 impo
@@ -772,49 +772,8 @@
 ();%0A
-%09%09AdminPage adminPage = new AdminPage();%0A
 %09%09%0A%09
@@ -865,57 +865,8 @@
 ();%0A
-%09%09adminPage.leftMenu.clickOnEmailServerButton();%0A
 %09%7D%0A%09

Fix Scenario: LocationGivenSteps login with an account method fixed