Search in sources :

Example 1 with EnclosedMessageFieldValue

use of io.spine.test.validate.msg.EnclosedMessageFieldValue 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 EnclosedMessageFieldValue

use of io.spine.test.validate.msg.EnclosedMessageFieldValue 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 EnclosedMessageFieldValue

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

the class MessageValidatorShould method find_out_that_enclosed_message_field_is_NOT_valid.

@Test
public void find_out_that_enclosed_message_field_is_NOT_valid() {
    final RequiredStringFieldValue enclosedMsg = RequiredStringFieldValue.getDefaultInstance();
    final EnclosedMessageFieldValue msg = EnclosedMessageFieldValue.newBuilder().setOuterMsgField(enclosedMsg).build();
    validate(msg);
    assertIsValid(false);
}
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)

Aggregations

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