net.serenitybdd.screenplay.formatting.StripRedundantTerms Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of serenity-journey Show documentation
Show all versions of serenity-journey Show documentation
Support for the User Journey pattern in Serenity
package net.serenitybdd.screenplay.formatting;
import com.google.common.collect.ImmutableList;
import java.util.List;
public class StripRedundantTerms {
private final static List REDUNDANT_HAMCREST_PREFIXES = ImmutableList.of("is ","be ");
public static String from(String expression) {
for (String prefix : REDUNDANT_HAMCREST_PREFIXES) {
expression = removePrefix(prefix, expression);
}
return expression;
}
private static String removePrefix(String prefix, String expression) {
if (expression.startsWith(prefix)) {
expression = expression.substring(3);
}
return expression;
}
}