All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.serenitybdd.screenplay.AnonymousPerformable Maven / Gradle / Ivy

There is a newer version: 4.2.9
Show newest version
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);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy