// Path: src/samples/journey-pattern-sample/src/main/java/net/serenitybdd/demos/todos/questions/DisplayedItems.java
// @Subject("the displayed todo items")
// public class DisplayedItems implements Question<List<String>> {
// 
//     @Override
//     public List<String> answeredBy(Actor actor) {
//         return Text.of(ToDoList.TODO_ITEMS).viewedBy(actor).asList();
//     }
// }
// 
// Path: src/samples/journey-pattern-sample/src/main/java/net/serenitybdd/demos/todos/questions/TheRemainingItemCount.java
// public class TheRemainingItemCount implements Question<Integer> {
//     public static TheRemainingItemCount value() {
//         return new TheRemainingItemCount();
//     }
// 
//     @Override
//     public Integer answeredBy(Actor actor) {
//         return Text.of(TodoCounter.ITEM_COUNT)
//                    .viewedBy(actor)
//                    .asInteger();
//     }
// }
// 
// Path: src/samples/journey-pattern-sample/src/main/java/net/serenitybdd/demos/todos/tasks/AddTodoItems.java
// public class AddTodoItems implements Task {
// 
//     private final List<String> todos;
// 
//     protected AddTodoItems(List<String> items) { this.todos = ImmutableList.copyOf(items); }
// 
//     @Step("{0} adds the todo items called #todos")
//     public <T extends Actor> void performAs(T actor) {
//         todos.forEach(
//                 todo -> actor.attemptsTo(AddATodoItem.called(todo))
//         );
//     }
// 
//     public static AddTodoItems called(String... items) {
//         return Instrumented.instanceOf(AddTodoItems.class).withProperties(asList(items));
//     }
// }
// 
// Path: src/samples/journey-pattern-sample/src/main/java/net/serenitybdd/demos/todos/tasks/DeleteAnItem.java
// public class DeleteAnItem implements Task {
// 
//     private final String itemName;
// 
//     protected DeleteAnItem(String itemName) {
//         this.itemName = itemName;
//     }
// 
//     @Step("{0} deletes the item '#itemName'")
//     public <T extends Actor> void performAs(T theActor) {
//         Target deleteButton = TodoListItem.DELETE_ITEM_BUTTON.of(itemName);
//         theActor.attemptsTo(JSClick.on(deleteButton));
//     }
// 
//     public static DeleteAnItem called(String itemName) {
//         return instrumented(DeleteAnItem.class, itemName);
//     }
// }
// 
// Path: src/samples/journey-pattern-sample/src/main/java/net/serenitybdd/demos/todos/tasks/OpenTheApplication.java
// public class OpenTheApplication implements Task {
// 
//     private ApplicationHomePage applicationHomePage;
// 
//     public static OpenTheApplication onTheHomePage() {
//         return instrumented(OpenTheApplication.class);
//     }
//     @Step("{0} opens the application on the home page")
//     public <T extends Actor> void performAs(T actor) {
//         actor.attemptsTo(Open.browserOn().the(applicationHomePage));
//     }
// }


import net.serenitybdd.demos.todos.questions.DisplayedItems;
import net.serenitybdd.demos.todos.questions.TheRemainingItemCount;
import net.serenitybdd.demos.todos.tasks.AddTodoItems;
import net.serenitybdd.demos.todos.tasks.DeleteAnItem;
import net.serenitybdd.demos.todos.tasks.OpenTheApplication;
import net.serenitybdd.junit.runners.SerenityRunner;
import net.serenitybdd.screenplay.Actor;
import net.serenitybdd.screenplay.abilities.BrowseTheWeb;
import net.thucydides.core.annotations.Managed;
import net.thucydides.core.annotations.Steps;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.openqa.selenium.WebDriver;
import static net.serenitybdd.screenplay.GivenWhenThen.*;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.Matchers.contains;
package net.serenitybdd.demos.todos.features.maintain_my_todo_list;



@RunWith(SerenityRunner.class)
public class DeleteTodos {

    @Managed
    private
    WebDriver hisBrowser;

    private Actor james = Actor.named("James");

    @Steps
    private
    DisplayedItems theDisplayedItems;

    @Before
    public void jamesCanBrowseTheWeb() {
        james.can(BrowseTheWeb.with(hisBrowser));
    }

    @Test
    public void deleted_items_should_be_removed_from_the_list() {


        givenThat(james).wasAbleTo(OpenTheApplication.onTheHomePage());
// Path: src/samples/journey-pattern-sample/src/main/java/net/serenitybdd/demos/todos/questions/DisplayedItems.java
// @Subject("the displayed todo items")
// public class DisplayedItems implements Question<List<String>> {
// 
//     @Override
//     public List<String> answeredBy(Actor actor) {
//         return Text.of(ToDoList.TODO_ITEMS).viewedBy(actor).asList();
//     }
// }
// 
// Path: src/samples/journey-pattern-sample/src/main/java/net/serenitybdd/demos/todos/questions/TheRemainingItemCount.java
// public class TheRemainingItemCount implements Question<Integer> {
//     public static TheRemainingItemCount value() {
//         return new TheRemainingItemCount();
//     }
// 
//     @Override
//     public Integer answeredBy(Actor actor) {
//         return Text.of(TodoCounter.ITEM_COUNT)
//                    .viewedBy(actor)
//                    .asInteger();
//     }
// }
// 
// Path: src/samples/journey-pattern-sample/src/main/java/net/serenitybdd/demos/todos/tasks/AddTodoItems.java
// public class AddTodoItems implements Task {
// 
//     private final List<String> todos;
// 
//     protected AddTodoItems(List<String> items) { this.todos = ImmutableList.copyOf(items); }
// 
//     @Step("{0} adds the todo items called #todos")
//     public <T extends Actor> void performAs(T actor) {
//         todos.forEach(
//                 todo -> actor.attemptsTo(AddATodoItem.called(todo))
//         );
//     }
// 
//     public static AddTodoItems called(String... items) {
//         return Instrumented.instanceOf(AddTodoItems.class).withProperties(asList(items));
//     }
// }
// 
// Path: src/samples/journey-pattern-sample/src/main/java/net/serenitybdd/demos/todos/tasks/DeleteAnItem.java
// public class DeleteAnItem implements Task {
// 
//     private final String itemName;
// 
//     protected DeleteAnItem(String itemName) {
//         this.itemName = itemName;
//     }
// 
//     @Step("{0} deletes the item '#itemName'")
//     public <T extends Actor> void performAs(T theActor) {
//         Target deleteButton = TodoListItem.DELETE_ITEM_BUTTON.of(itemName);
//         theActor.attemptsTo(JSClick.on(deleteButton));
//     }
// 
//     public static DeleteAnItem called(String itemName) {
//         return instrumented(DeleteAnItem.class, itemName);
//     }
// }
// 
// Path: src/samples/journey-pattern-sample/src/main/java/net/serenitybdd/demos/todos/tasks/OpenTheApplication.java
// public class OpenTheApplication implements Task {
// 
//     private ApplicationHomePage applicationHomePage;
// 
//     public static OpenTheApplication onTheHomePage() {
//         return instrumented(OpenTheApplication.class);
//     }
//     @Step("{0} opens the application on the home page")
//     public <T extends Actor> void performAs(T actor) {
//         actor.attemptsTo(Open.browserOn().the(applicationHomePage));
//     }
// }


// Path: src/samples/journey-pattern-sample/src/test/java/net/serenitybdd/demos/todos/features/maintain_my_todo_list/DeleteTodos.java
import net.serenitybdd.demos.todos.questions.DisplayedItems;
import net.serenitybdd.demos.todos.questions.TheRemainingItemCount;
import net.serenitybdd.demos.todos.tasks.AddTodoItems;
import net.serenitybdd.demos.todos.tasks.DeleteAnItem;
import net.serenitybdd.demos.todos.tasks.OpenTheApplication;
import net.serenitybdd.junit.runners.SerenityRunner;
import net.serenitybdd.screenplay.Actor;
import net.serenitybdd.screenplay.abilities.BrowseTheWeb;
import net.thucydides.core.annotations.Managed;
import net.thucydides.core.annotations.Steps;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.openqa.selenium.WebDriver;
import static net.serenitybdd.screenplay.GivenWhenThen.*;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.Matchers.contains;

package net.serenitybdd.demos.todos.features.maintain_my_todo_list;



@RunWith(SerenityRunner.class)
public class DeleteTodos {

    @Managed
    private
    WebDriver hisBrowser;

    private Actor james = Actor.named("James");

    @Steps
    private
    DisplayedItems theDisplayedItems;

    @Before
    public void jamesCanBrowseTheWeb() {
        james.can(BrowseTheWeb.with(hisBrowser));
    }

    @Test
    public void deleted_items_should_be_removed_from_the_list() {


        givenThat(james).wasAbleTo(OpenTheApplication.onTheHomePage());
        andThat(james).wasAbleTo(AddTodoItems.called("Walk the dog", "Put out the garbage"));