package me.alb_i986.selenium.tinafw.tasks;

import me.alb_i986.selenium.tinafw.domain.User;
import me.alb_i986.selenium.tinafw.pages.Page;

/**
 * A WebTask is supposed to implement a Given, When, or Then step.
 * See also
 * <a href="http://martinfowler.com/bliki/GivenWhenThen.html" target="new">
 * http://martinfowler.com/bliki/GivenWhenThen.html
 * </a>.
 * <p>
 * A WebTask uses page objects to carry on its logic.
 * It is supposed to be data unaware. Test data should be stored
 * in test classes.
 * <p>
 * WebTask makes it easy to chain steps sequentially, in a way that
 * each task can continue the navigation from the page the
 * previous task was visiting.
 * <p>
 * @see CompositeWebTask
 */
public interface WebTask {

	/**
	 * Perform this task as the user {@link #getUser()}.
	 * Precondition: the user must have already been set
	 * (see {@link #setUser(User)}).
	 * 
	 * @param initialPage the page it is displayed before this task starts
	 * @return the last page that is displayed after this task finishes
	 */
	public Page doTask(Page initialPage);
	
	/**
	 * @param user the user this task will run as.
	 * @return this
	 */
	public WebTask setUser(User user);

	/**
	 * @return the user that this task runs as
	 */
	public User getUser();
	
}

@@ -169,195 +169,217 @@
  to 
+s
 im
-plement a Given, When, or Then step.%0A * See also%0A * %3Ca href=%22http://martinfowler.com/bliki/GivenWhenThen.html%22 target=%22new%22%3E%0A * http://martinfowler.com/bliki/GivenWhenThen.html
+ulate a user interaction with the SUT.%0A * E.g.:%0A * %3Cul%3E%0A * %3Cli%3Eopen the browser%3C/li%3E%0A * %3Cli%3Enavigate to some URL of the SUT%3C/li%3E%0A * %3Cli%3Elogin%3C/li%3E%0A * %3Cli%3Eclick buttons, links, fill forms, etc.%3C/li%3E
 %0A * %3C/
-a%3E.
+ul%3E
 %0A * 
@@ -384,18 +384,16 @@
 * %3Cp%3E%0A *
- A
  WebTask
@@ -447,255 +447,1160 @@
  is 
-supposed to be data unaware. Test data should be stored%0A * in test classes.%0A * %3Cp%3E%0A * WebTask makes it easy to chain steps sequentially, in a way that%0A * each task can continue the navigation from the page the%0A * previous task was visiting.
+the gate between the layer 'tests' and 'pages', the one%0A * that makes for maintainable test suites.%0A * In fact, it allows for sharing code among tests.%0A * Each concrete WebTask should be as fine-grained as possible:%0A * the finer, the more reusable, the better.%0A * Fine-grained WebTask's can be then chained together, thanks to%0A * %7B@link CompositeWebTask%7D.%0A * Each WebTask in a chain is able to continue the interaction with the SUT%0A * from the page the previous task was visiting.%0A * %3Cp%3E%0A * Concrete WebTask's should be parametrized by fields: they%0A * should define a field for each piece of test data they need, along with a%0A * %3Ca href=%22http://martinfowler.com/bliki/FluentInterface.html%22 target=%22new%22%3E%0A * fluent%3C/a%3E setter method.%0A * Test data should be stored (statically, i.e. hardcoded, or dynamically,%0A * e.g. in a DB) in test classes and passed to WebTask's via the fluent setter methods. %0A * %3Cp%3E%0A * It is best to think of a WebTask as a %0A * %3Ca href=%22http://martinfowler.com/bliki/GivenWhenThen.html%22 target=%22new%22%3E%0A * Given, When, or Then step%3C/a%3E.%0A * Please, see also%0A * %3Ca href=%22http://dannorth.net/introducing-bdd/%22 target=%22new%22%3EBDD%3C/a%3E. 
 %0A * 
-%3Cp%3E
 %0A * 

update javadocs in WebTask