Search in sources :

Example 1 with PatternStringFieldValue

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);
}
Also used : PatternStringFieldValue(io.spine.test.validate.msg.PatternStringFieldValue) Test(org.junit.Test)

Example 2 with PatternStringFieldValue

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());
}
Also used : PatternStringFieldValue(io.spine.test.validate.msg.PatternStringFieldValue) ConstraintViolation(io.spine.validate.ConstraintViolation) Test(org.junit.Test)

Example 3 with PatternStringFieldValue

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);
}
Also used : PatternStringFieldValue(io.spine.test.validate.msg.PatternStringFieldValue) Test(org.junit.Test)

Aggregations

PatternStringFieldValue (io.spine.test.validate.msg.PatternStringFieldValue)3 Test (org.junit.Test)3 ConstraintViolation (io.spine.validate.ConstraintViolation)1