use of io.spine.validate.ConstraintViolation in project core-java by SpineEventEngine.
the class MessageValidatorShould method provide_one_valid_violation_if_number_is_greater_than_decimal_max.
@Test
public void provide_one_valid_violation_if_number_is_greater_than_decimal_max() {
maxDecimalNumberTest(GREATER_THAN_MAX, /*inclusive=*/
true, /*valid=*/
false);
assertEquals(1, violations.size());
final ConstraintViolation violation = firstViolation();
assertEquals(GREATER_MAX_MSG, format(violation.getMsgFormat(), violation.getParam(0), violation.getParam(1)));
assertFieldPathIs(violation, VALUE);
assertTrue(violation.getViolationList().isEmpty());
}
use of io.spine.validate.ConstraintViolation in project core-java by SpineEventEngine.
the class MessageValidatorShould method provide_one_valid_violation_if_entity_id_in_command_is_not_valid.
@Test
public void provide_one_valid_violation_if_entity_id_in_command_is_not_valid() {
validate(EntityIdMsgFieldValue.getDefaultInstance());
assertEquals(1, violations.size());
final ConstraintViolation violation = firstViolation();
assertEquals(NO_VALUE_MSG, violation.getMsgFormat());
assertFieldPathIs(violation, VALUE);
assertTrue(violation.getViolationList().isEmpty());
}
use of io.spine.validate.ConstraintViolation in project core-java by SpineEventEngine.
the class MessageValidatorShould method provide_one_valid_violation_if_integral_digit_count_is_greater_than_max.
@Test
public void provide_one_valid_violation_if_integral_digit_count_is_greater_than_max() {
digitsCountTest(INT_DIGIT_COUNT_GREATER_THAN_MAX, /*valid=*/
false);
assertEquals(1, violations.size());
final ConstraintViolation violation = firstViolation();
assertEquals("Number value is out of bounds, expected: <2 max digits>.<2 max digits>.", format(violation.getMsgFormat(), violation.getParam(0), violation.getParam(1)));
assertFieldPathIs(violation, VALUE);
assertTrue(violation.getViolationList().isEmpty());
}
use of io.spine.validate.ConstraintViolation in project core-java by SpineEventEngine.
the class ValidatorShould method validate_command_and_return_violations_if_message_is_NOT_valid.
@Test
public void validate_command_and_return_violations_if_message_is_NOT_valid() {
final Any invalidMessagePacked = AnyPacker.pack(CreateProject.getDefaultInstance());
final Command commandWithEmptyMessage = Command.newBuilder().setId(generateId()).setMessage(invalidMessagePacked).setContext(createCommandContext()).build();
final List<ConstraintViolation> violations = validator.validate(CommandEnvelope.of(commandWithEmptyMessage));
assertEquals(3, violations.size());
}
use of io.spine.validate.ConstraintViolation in project core-java by SpineEventEngine.
the class CommandValidatorViolationCheckShould method validate_command_and_return_violations_if_message_is_NOT_valid.
@Test
public void validate_command_and_return_violations_if_message_is_NOT_valid() {
final Any invalidMessagePacked = AnyPacker.pack(CmdCreateProject.getDefaultInstance());
final Command commandWithEmptyMessage = Command.newBuilder().setId(generateId()).setMessage(invalidMessagePacked).setContext(withRandomActor()).build();
final List<ConstraintViolation> violations = inspect(CommandEnvelope.of(commandWithEmptyMessage));
assertEquals(3, violations.size());
}
Aggregations