package me.alb_i986.selenium.tinafw.sample.tests;

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

import me.alb_i986.selenium.tinafw.domain.User;
import me.alb_i986.selenium.tinafw.sample.tasks.*;
import me.alb_i986.selenium.tinafw.tasks.*;
import static me.alb_i986.selenium.tinafw.tasks.BDDWebTask.*;

public class SampleWebTest {

	private User user;
	
	@Before
	public void before() {
		user = new User();
		user.openBrowser();
	}
	

	@Test
	public void testSearch() {
		user.doTask(
			new BDDWebTask(
				given(
					new OnMyAboutMePage()
				),
				when(
					new Search()
						.forQuery("paolo")
				),
				then(
					new CanCompliment()
						.theGuy(2)
						.with("love")
				)
			)
		);
	}
	
	@Test
	public void testMyPage() {
		user.doTask(
			new BDDWebTask(
				given(
					new OnMyAboutMePage()
				),
				null,
				then(
					new VerifyBio()
						.matches(".*Genuinely driven by Passion.*"),
					new VerifySocialIcons()
						.isDisplayed("github")
						.isDisplayed("linkedin")
				)
			)
		);
	}
	
	@After
	public void after() {
		user.closeBrowser();
	}
	
}

@@ -48,57 +48,8 @@
 s;%0A%0A
-import org.junit.After;%0Aimport org.junit.Before;%0A
 impo
@@ -67,16 +67,16 @@
 t.Test;%0A
+
 %0Aimport 
@@ -207,24 +207,79 @@
 fw.tasks.*;%0A
+import me.alb_i986.selenium.tinafw.tests.JunitWebTest;%0A
 import stati
@@ -356,16 +356,37 @@
 WebTest 
+extends JunitWebTest 
 %7B%0A%0A%09priv
@@ -408,13 +408,15 @@
 %09%0A%09@
-Befor
+Overrid
 e%0A%09p
@@ -443,24 +443,96 @@
 %7B%0A%09%09
-user = new User(
+super.before();%0A%09%09user = new User();%0A%09%09browserManager.registerBrowsers(user.getBrowser()
 );%0A%09
@@ -1145,65 +1145,6 @@
 %7D%0A%09%0A
-%09@After%0A%09public void after() %7B%0A%09%09user.closeBrowser();%0A%09%7D%0A%09%0A
 %7D%0A

update SampleWebTest to use JunitWebTest