use of io.spine.test.validate.msg.PatternStringFieldValue in project core-java by SpineEventEngine.
the class MessageValidatorShould method find_out_that_string_matches_to_regex_pattern.
/*
* String pattern option tests.
*/
@Test
public void find_out_that_string_matches_to_regex_pattern() {
final PatternStringFieldValue msg = PatternStringFieldValue.newBuilder().setEmail("valid.email@mail.com").build();
validate(msg);
assertIsValid(true);
}
use of io.spine.test.validate.msg.PatternStringFieldValue in project core-java by SpineEventEngine.
the class MessageValidatorShould method provide_one_valid_violation_if_string_does_not_match_to_regex_pattern.
@Test
public void provide_one_valid_violation_if_string_does_not_match_to_regex_pattern() {
final PatternStringFieldValue msg = PatternStringFieldValue.newBuilder().setEmail("invalid.email").build();
validate(msg);
assertEquals(1, violations.size());
final ConstraintViolation violation = firstViolation();
assertEquals("String must match the regular expression '%s'.", violation.getMsgFormat());
assertEquals("^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$", firstViolation().getParam(0));
assertFieldPathIs(violation, "email");
assertTrue(violation.getViolationList().isEmpty());
}
use of io.spine.test.validate.msg.PatternStringFieldValue in project core-java by SpineEventEngine.
the class MessageValidatorShould method find_out_that_string_does_not_match_to_regex_pattern.
@Test
public void find_out_that_string_does_not_match_to_regex_pattern() {
final PatternStringFieldValue msg = PatternStringFieldValue.newBuilder().setEmail("invalid email").build();
validate(msg);
assertIsValid(false);
}
Aggregations