net.serenitybdd.screenplay.AnonymousPerformable Maven / Gradle / Ivy
package net.serenitybdd.screenplay;
import net.serenitybdd.core.steps.HasCustomFieldValues;
import net.serenitybdd.annotations.Step;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class AnonymousPerformable implements Performable, HasCustomFieldValues {
private String title;
private Map fieldValues = new HashMap();
private List steps;
public AnonymousPerformable() {}
public AnonymousPerformable(String title, List steps) {
this.title = title;
this.steps = steps;
}
@Override
@Step("!#title")
public void performAs(T actor) {
actor.attemptsTo(steps.toArray(new Performable[]{}));
}
public void setFieldValue(String fieldName, Object fieldValue) {
fieldValues.put(fieldName, fieldValue);
}
@Override
public String toString() {
return title;
}
@Override
public Map getCustomFieldValues() {
return new HashMap<>(fieldValues);
}
}