package at.fhj.swd13.pse.test.gui;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import at.fhj.swd13.pse.test.base.SeleniumBaseTestCase;
import at.fhj.swd13.pse.test.gui.pageobjects.HomePage;
import at.fhj.swd13.pse.test.gui.pageobjects.LoginPage;
import at.fhj.swd13.pse.test.gui.pageobjects.UserList;
import at.fhj.swd13.pse.test.gui.pageobjects.UserPage;


public class UserSearchIT extends SeleniumBaseTestCase {
	private HomePage homepage;
	private LoginPage loginPage;

	@Before
	public void init() {
		loginPage = new LoginPage(driver, BASE_URL);
		homepage = loginPage.login("florian.genser", "12345678");
	}
	
	@After
	public void tearDown() throws Exception {
		homepage.logout();
		super.tearDown();
	}
	
	/**
	 * PSE2015-9: Als angemeldeter Benutzer des Systems möchte ich nach anderen Benutzern des Systems suchen können
	 */
	@Test
	public void testSearchUser() {
		UserList userList = homepage.searchUser("ei");
		verifyEquals(2, userList.getUsers().size());
		
		UserPage userPage = userList.openUserPage(1);
		verifyEquals("Teiniker", userPage.getUserLastName());
	}


	/**
	 * PSE2015-10: Als angemeldeter Benutzer des Systems möchte ich die Profile anderer Benutzer des Systems anschauen können
	 */
	@Test
	public void testViewUser() {
		UserList userList = homepage.searchUser("Angelo");
		verifyEquals(1, userList.getUsers().size());
		
		UserPage userPage = userList.openUserPage(0);
		verifyEquals("Angelo", userPage.getUserLastName());
		verifyEquals("Franz", userPage.getUserFirstName());
		verifyEquals("franz.angelo@edu.fh-joanneum.at", userPage.getUserEmailAddress());
		verifyEquals("Team 2", userPage.getUserDepartment());
		verifyEquals("A", userPage.getUserBuilding());
		verifyEquals("-2", userPage.getUserFloor());
		verifyEquals("666", userPage.getUserRoomNumber());
		verifyEquals("+436767067828", userPage.getUserPhoneNumberMobile());
	}
}

@@ -29,16 +29,55 @@
 t.gui;%0A%0A
+import java.util.concurrent.TimeUnit;%0A%0A
 import o
@@ -139,16 +139,143 @@
 it.Test;
+%0Aimport org.openqa.selenium.WebDriver;%0Aimport org.openqa.selenium.WebElement;%0Aimport org.openqa.selenium.firefox.FirefoxDriver;
 %0A%0Aimport
@@ -694,16 +694,125 @@
 nit() %7B%0A
+%09%09WebDriver driver = new FirefoxDriver();%0A%09%09driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);%0A
 %09%09loginP
@@ -1601,24 +1601,187 @@
 (%22Angelo%22);%0A
+%09%09%0A%09%09String test = %22%22;%0A%09%09for (WebElement user : userList.getUsers())%0A%09%09%09test += user.getText();%0A%09%09%0A%09%09System.out.println(%22********************* Users: %5Cn%22 + test);%0A
 %09%09verifyEqua

Insert debug message