public static Validator toValidator(final String leftBrace, final String rightBrace, final MethodCall method) {
Preconditions.checkNotNull(method);
MethodUtils.getParameterValueWithName(leftBrace, rightBrace, method, "Search").ifPresent(value -> {
if ("Headers".equals(value) || "Body".equals(value))
logger.error("The value \"" + value + "\" for the \"Search\" option has not been taken under account for the LR function with name : "
+ method.getName());
});
MethodUtils.getParameterValueWithName(leftBrace, rightBrace, method, "SaveCount").ifPresent(value -> logger.warn(
"The option \"" + value + "\" for the the LR function with name \"" + method.getName() + "\" has not been taken under account"));
Optional<String> textPfx = MethodUtils.getParameterStartingWith(method, "TextPfx");
if (textPfx.isPresent()) {
String prefix = MethodUtils.getValueAndVerifyRestrictionForBoundary(leftBrace, rightBrace, method, textPfx);
String suffix = MethodUtils.getValueAndVerifyRestrictionForBoundary(leftBrace, rightBrace, method,
MethodUtils.getParameterStartingWith(method, "TextSfx"));
String regex = "\\Q" + prefix + "\\E.*\\Q" + suffix + "\\E";
return ImmutableRegexpValidator.builder().name(method.getName() + "_" + Integer.toString(currentID++)).haveToContains(
NOTFOUND.equals(MethodUtils.getParameterValueWithName(leftBrace, rightBrace, method, "Fail").orElse(
NOTFOUND))).validationRegex(regex).build();
}
String exactMatch = MethodUtils.getValueAndVerifyRestrictionForBoundary(leftBrace, rightBrace, method,
MethodUtils.getParameterStartingWith(method, "Text"));
return ImmutableTextValidator.builder().name(method.getName() + "_" + Integer.toString(currentID++)).haveToContains(NOTFOUND.equals(
MethodUtils.getParameterValueWithName(leftBrace, rightBrace, method, "Fail").orElse(NOTFOUND))).validationText(
exactMatch).build();
}
}