Search in sources :

Example 1 with RequiredStringFieldValue

use of io.spine.test.validate.msg.RequiredStringFieldValue in project core-java by SpineEventEngine.

the class MessageValidatorShould method provide_valid_violations_if_enclosed_message_field_is_not_valid.

@Test
public void provide_valid_violations_if_enclosed_message_field_is_not_valid() {
    final RequiredStringFieldValue enclosedMsg = RequiredStringFieldValue.getDefaultInstance();
    final EnclosedMessageFieldValue msg = EnclosedMessageFieldValue.newBuilder().setOuterMsgField(enclosedMsg).build();
    validate(msg);
    assertEquals(1, violations.size());
    final ConstraintViolation violation = firstViolation();
    assertEquals("Message must have valid properties.", violation.getMsgFormat());
    assertFieldPathIs(violation, OUTER_MSG_FIELD);
    final List<ConstraintViolation> innerViolations = violation.getViolationList();
    assertEquals(1, innerViolations.size());
    final ConstraintViolation innerViolation = innerViolations.get(0);
    assertEquals(NO_VALUE_MSG, innerViolation.getMsgFormat());
    assertFieldPathIs(innerViolation, OUTER_MSG_FIELD, VALUE);
    assertTrue(innerViolation.getViolationList().isEmpty());
}
Also used : ConstraintViolation(io.spine.validate.ConstraintViolation) EnclosedMessageFieldValue(io.spine.test.validate.msg.EnclosedMessageFieldValue) CustomMessageRequiredStringFieldValue(io.spine.test.validate.msg.CustomMessageRequiredStringFieldValue) RequiredStringFieldValue(io.spine.test.validate.msg.RequiredStringFieldValue) Test(org.junit.Test)

Example 2 with RequiredStringFieldValue

use of io.spine.test.validate.msg.RequiredStringFieldValue in project core-java by SpineEventEngine.

the class MessageValidatorShould method find_out_that_enclosed_message_field_is_valid.

/*
     * Enclosed message field validation option tests.
     */
@Test
public void find_out_that_enclosed_message_field_is_valid() {
    final RequiredStringFieldValue enclosedMsg = RequiredStringFieldValue.newBuilder().setValue(newUuid()).build();
    final EnclosedMessageFieldValue msg = EnclosedMessageFieldValue.newBuilder().setOuterMsgField(enclosedMsg).build();
    validate(msg);
    assertIsValid(true);
}
Also used : EnclosedMessageFieldValue(io.spine.test.validate.msg.EnclosedMessageFieldValue) CustomMessageRequiredStringFieldValue(io.spine.test.validate.msg.CustomMessageRequiredStringFieldValue) RequiredStringFieldValue(io.spine.test.validate.msg.RequiredStringFieldValue) Test(org.junit.Test)

Example 3 with RequiredStringFieldValue

use of io.spine.test.validate.msg.RequiredStringFieldValue in project core-java by SpineEventEngine.

the class MessageValidatorShould method find_out_that_required_String_field_is_set.

@Test
public void find_out_that_required_String_field_is_set() {
    final RequiredStringFieldValue validMsg = RequiredStringFieldValue.newBuilder().setValue(newUuid()).build();
    validate(validMsg);
    assertIsValid(true);
}
Also used : CustomMessageRequiredStringFieldValue(io.spine.test.validate.msg.CustomMessageRequiredStringFieldValue) RequiredStringFieldValue(io.spine.test.validate.msg.RequiredStringFieldValue) Test(org.junit.Test)

Example 4 with RequiredStringFieldValue

use of io.spine.test.validate.msg.RequiredStringFieldValue in project core-java by SpineEventEngine.

the class MessageValidatorShould method consider_field_is_valid_if_no_valid_option_set.

@Test
public void consider_field_is_valid_if_no_valid_option_set() {
    final RequiredStringFieldValue invalidEnclosedMsg = RequiredStringFieldValue.getDefaultInstance();
    final EnclosedMessageWithoutAnnotationFieldValue msg = EnclosedMessageWithoutAnnotationFieldValue.newBuilder().setOuterMsgField(invalidEnclosedMsg).build();
    validate(msg);
    assertIsValid(true);
}
Also used : EnclosedMessageWithoutAnnotationFieldValue(io.spine.test.validate.msg.EnclosedMessageWithoutAnnotationFieldValue) CustomMessageRequiredStringFieldValue(io.spine.test.validate.msg.CustomMessageRequiredStringFieldValue) RequiredStringFieldValue(io.spine.test.validate.msg.RequiredStringFieldValue) Test(org.junit.Test)

Example 5 with RequiredStringFieldValue

use of io.spine.test.validate.msg.RequiredStringFieldValue in project core-java by SpineEventEngine.

the class MessageValidatorShould method provide_one_valid_violation_if_required_field_is_not_set.

@Test
public void provide_one_valid_violation_if_required_field_is_not_set() {
    final RequiredStringFieldValue invalidMsg = RequiredStringFieldValue.getDefaultInstance();
    validate(invalidMsg);
    assertEquals(1, violations.size());
    final ConstraintViolation violation = firstViolation();
    assertEquals(NO_VALUE_MSG, violation.getMsgFormat());
    assertFieldPathIs(violation, VALUE);
    assertTrue(violation.getViolationList().isEmpty());
}
Also used : ConstraintViolation(io.spine.validate.ConstraintViolation) CustomMessageRequiredStringFieldValue(io.spine.test.validate.msg.CustomMessageRequiredStringFieldValue) RequiredStringFieldValue(io.spine.test.validate.msg.RequiredStringFieldValue) Test(org.junit.Test)

Aggregations

CustomMessageRequiredStringFieldValue (io.spine.test.validate.msg.CustomMessageRequiredStringFieldValue)7 RequiredStringFieldValue (io.spine.test.validate.msg.RequiredStringFieldValue)7 Test (org.junit.Test)7 EnclosedMessageFieldValue (io.spine.test.validate.msg.EnclosedMessageFieldValue)3 ConstraintViolation (io.spine.validate.ConstraintViolation)2 EnclosedMessageWithoutAnnotationFieldValue (io.spine.test.validate.msg.EnclosedMessageWithoutAnnotationFieldValue)1