
net.serenitybdd.screenplay.questions.QuestionHints 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.questions;
import net.serenitybdd.core.Serenity;
import net.serenitybdd.core.pages.WebElementState;
import net.serenitybdd.screenplay.Question;
import org.hamcrest.Matcher;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import static java.util.Arrays.stream;
public class QuestionHints {
public static Set> fromAssertion(Matcher matcher) {
return stream(matcher.getClass().getInterfaces())
.filter(QuestionHint.class::isAssignableFrom)
.map( matcherInterface -> ((Class extends QuestionHint>) matcherInterface) )
.collect(Collectors.toSet());
}
public static HintAdder addHints(Set> hints) {
return new HintAdder(hints);
}
public static class HintAdder {
private final Set> hints;
public HintAdder(Set> hints) {
this.hints = hints;
}
public void to(Question question) {
if (question instanceof AcceptsHints) {
((AcceptsHints) question).apply(hints);
}
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy