use of com.redhat.service.smartevents.infra.validations.ValidationResult in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class TransformationTemplateConstraintValidator method isValid.
@Override
public boolean isValid(String transformationTemplate, ConstraintValidatorContext context) {
if (transformationTemplate == null) {
return true;
}
ValidationResult validationResult = transformationEvaluatorFactory.validate(transformationTemplate);
if (validationResult.isValid()) {
return true;
}
context.disableDefaultConstraintViolation();
HibernateConstraintValidatorContext hibernateContext = context.unwrap(HibernateConstraintValidatorContext.class);
hibernateContext.addMessageParameter(ERROR_PARAM, validationResult.getMessage());
hibernateContext.buildConstraintViolationWithTemplate(TRANSFORMATION_TEMPLATE_MALFORMED_ERROR).addConstraintViolation();
return false;
}
use of com.redhat.service.smartevents.infra.validations.ValidationResult in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class TransformationEvaluatorFactoryQuteTest method validateInvalidTemplate.
@Test
public void validateInvalidTemplate() {
TransformationEvaluatorFactoryQute factory = new TransformationEvaluatorFactoryQute();
String template = "Hi {key how are you?";
ValidationResult result = factory.validate(template);
assertThat(result).isNotNull();
assertThat(result.isValid()).isFalse();
assertThat(result.getMessage()).isNotBlank();
}
use of com.redhat.service.smartevents.infra.validations.ValidationResult in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class SendToBridgeActionValidatorTest method assertIsInvalid.
private void assertIsInvalid(Action action, String errorMessage) {
ValidationResult validationResult = validator.isValid(action);
assertThat(validationResult.isValid()).isFalse();
if (errorMessage == null) {
assertThat(validationResult.getMessage()).isNull();
} else {
assertThat(validationResult.getMessage()).startsWith(errorMessage);
}
}
use of com.redhat.service.smartevents.infra.validations.ValidationResult in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class SlackActionValidatorTest method assertIsValid.
private void assertIsValid(Action action) {
ValidationResult validationResult = validator.isValid(action);
assertThat(validationResult.isValid()).isTrue();
}
use of com.redhat.service.smartevents.infra.validations.ValidationResult in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class SlackActionValidatorTest method assertIsInvalid.
private void assertIsInvalid(Action action, String errorMessage) {
ValidationResult validationResult = validator.isValid(action);
assertThat(validationResult.isValid()).isFalse();
if (errorMessage == null) {
assertThat(validationResult.getMessage()).isNull();
} else {
assertThat(validationResult.getMessage()).startsWith(errorMessage);
}
}
Aggregations