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());
}
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);
}
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);
}
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);
}
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());
}
Aggregations