use of org.mule.runtime.api.el.ValidationResult in project mule by mulesoft.
the class DefaultExpressionManager method validate.
@Override
public ValidationResult validate(String expression) {
if (!muleContext.getConfiguration().isValidateExpressions()) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Validate expressions is turned off, no checking done for: " + expression);
}
return new DefaultValidationResult(true, null);
}
final StringBuilder message = new StringBuilder();
try {
parser.validate(expression);
final AtomicBoolean valid = new AtomicBoolean(true);
if (expression.contains(DEFAULT_EXPRESSION_PREFIX)) {
parser.parse(token -> {
if (valid.get()) {
ValidationResult result = expressionLanguage.validate(token);
if (!result.isSuccess()) {
valid.compareAndSet(true, false);
message.append(token).append(" is invalid\n");
message.append(result.errorMessage().orElse(""));
}
}
return null;
}, expression);
} else {
return expressionLanguage.validate(expression);
}
} catch (IllegalArgumentException e) {
return failure(e.getMessage(), expression);
}
if (message.length() > 0) {
return failure(message.toString());
}
return success();
}
use of org.mule.runtime.api.el.ValidationResult in project mule by mulesoft.
the class AssertionMessageProcessor method start.
@Override
public void start() throws InitialisationException {
ValidationResult result = this.expressionManager.validate(expression);
if (!result.isSuccess()) {
throw new InvalidExpressionException(expression, result.errorMessage().orElse("Invalid exception"));
}
latch = new CountDownLatch(count);
addAssertion(getRootContainerLocation().toString(), this);
}
use of org.mule.runtime.api.el.ValidationResult in project mule by mulesoft.
the class ResponseAssertionMessageProcessor method start.
@Override
public void start() throws InitialisationException {
super.start();
ValidationResult result = this.expressionManager.validate(responseExpression);
if (!result.isSuccess()) {
throw new InvalidExpressionException(expression, result.errorMessage().orElse("Invalid expression"));
}
responseLatch = new CountDownLatch(responseCount);
addAssertion(getLocation().getRootContainerName(), this);
}
Aggregations