
net.serenitybdd.screenplay.conditions.ConditionalPerformable Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of serenity-screenplay Show documentation
Show all versions of serenity-screenplay Show documentation
Support for the User Journey pattern in Serenity
package net.serenitybdd.screenplay.conditions;
import com.google.common.collect.Maps;
import net.serenitybdd.screenplay.Actor;
import net.serenitybdd.screenplay.Performable;
import net.serenitybdd.screenplay.SilentPerformable;
import java.util.Map;
public abstract class ConditionalPerformable implements Performable {
protected final Map outcomeToPerform;
public ConditionalPerformable() {
this.outcomeToPerform = Maps.newHashMap();
outcomeToPerform.put(true, new SilentPerformable());
outcomeToPerform.put(false, new SilentPerformable());
}
public ConditionalPerformable andIfSo(Performable taskToPerform) {
outcomeToPerform.put(true, taskToPerform);
return this;
}
public ConditionalPerformable otherwise(Performable taskToPerform) {
outcomeToPerform.put(false, taskToPerform);
return this;
}
@Override
public void performAs(T actor) {
actor.attemptsTo(outcomeToPerform.get(evaluatedConditionFor(actor)));
}
protected abstract Boolean evaluatedConditionFor(Actor actor);
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy