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

import org.junit.After;
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;

public class UserChangePassword extends SeleniumBaseTestCase {

	private static HomePage homepage = null;

	/**
	 * PSE2015-12: Als angemeldeter Benutzer des Systems möchte ich mein Passwort ändern können
	 */
	@Test
	public void testChangePasswordLoginWithNewPassword() {
		LoginPage loginPage;
		final String username = "angelofr13";
		final String oldPassword = "12345678";
		final String newPassword = "87654321";

		loginPage = new LoginPage(driver, BASE_URL);
		homepage = loginPage.login(username, oldPassword);

		homepage.changePassword(oldPassword, newPassword);
		homepage.logout();

		homepage = loginPage.login(username, newPassword);

		verifyEquals(homepage.getLoggedInUser(), username);

	}
/* not working so far
	@Test
	public void testChangePasswordLoginWithOldPassword() {
		HomePage homepage;
		NotLoggedInPage notLoggedInPage;
		final String username = "loeflerm13";
		final String oldPassword = "12345678";
		final String newPassword = "87654321";

		loginPage = new LoginPage(driver, BASE_URL);
		homepage = loginPage.login(username, oldPassword);

		homepage.changePassword(oldPassword, newPassword);
		loginPage = loginPage.logout();

		notLoggedInPage = loginPage.loginInWrongPassword(username, oldPassword);

		verifyTrue(notLoggedInPage.pagePresent());

	}*/

	@After
	public void logoutAfter() {
		if (homepage != null)
			homepage.logout();
	}

}

@@ -48,21 +48,20 @@
 g.junit.
-After
+Test
 ;%0D%0Aimpor
@@ -66,26 +66,34 @@
 ort org.
-junit.Test
+openqa.selenium.By
 ;%0D%0A%0D%0Aimp
@@ -336,16 +336,17 @@
 private 
+ 
 static H
@@ -371,16 +371,63 @@
  null;%0D%0A
+%09private  static LoginPage loginPage = null;%0D%0A%09
 %0D%0A%09/**%0D%0A
@@ -595,32 +595,8 @@
  %7B%0D%0A
-%09%09LoginPage loginPage;%0D%0A
 %09%09fi
@@ -1015,35 +1015,38 @@
 );%0D%0A
+%09%09
 %0D%0A%09
-%7D%0D%0A/* not working so far
+%09homepage.logout();%0D%0A%0D%0A%09%7D
 %0D%0A%09@
@@ -1114,62 +1114,8 @@
 %0D%0A%09%09
-HomePage homepage;%0D%0A%09%09NotLoggedInPage notLoggedInPage;
 %0D%0A%09%09
@@ -1403,26 +1403,13 @@
 %0D%0A%09%09
-loginPage = loginP
+homep
 age.
@@ -1427,56 +1427,23 @@
 %0D%0A%09%09
-notLoggedInPage = loginPage.loginInWrongPassword
+loginPage.login
 (use
@@ -1472,20 +1472,25 @@
 %0D%0A%09%09
-verifyTrue(n
+// forwarded to N
 otLo
@@ -1499,123 +1499,90 @@
 edIn
+ 
 Page
-.pagePresent());%0D%0A%0D%0A%09%7D*/%0D%0A%0D%0A%09@After%0D%0A%09public void logoutAfter() %7B%0D%0A%09%09if (homepage != null)%0D%0A%09%09%09homepage.logout(
+%0D%0A%09%09verifyEquals(1, driver.findElements(By.linkText(%22Doors of Durin%22)).size()
 );%0D%0A

Test for password change added