use of io.spine.validate.ConstraintViolation in project core-java by SpineEventEngine.
the class MessageValidatorShould method provide_one_valid_violation_if_number_is_less_than_decimal_min.
@Test
public void provide_one_valid_violation_if_number_is_less_than_decimal_min() {
minDecimalNumberTest(LESS_THAN_MIN, /*inclusive=*/
true, /*valid=*/
false);
assertEquals(1, violations.size());
final ConstraintViolation violation = firstViolation();
assertEquals(LESS_THAN_MIN_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_number_is_less_than_min.
@Test
public void provide_one_valid_violation_if_number_is_less_than_min() {
final MinNumberFieldValue msg = MinNumberFieldValue.newBuilder().setValue(LESS_THAN_MIN).build();
validate(msg);
assertEquals(1, violations.size());
final ConstraintViolation violation = firstViolation();
assertEquals(LESS_THAN_MIN_MSG, format(violation.getMsgFormat(), violation.getParam(0)));
assertFieldPathIs(violation, VALUE);
assertTrue(violation.getViolationList().isEmpty());
}
use of io.spine.validate.ConstraintViolation in project core-java by SpineEventEngine.
the class MessageValidatorShould method checkErrorMessage.
private void checkErrorMessage(String expectedMessage) {
final ConstraintViolation constraintViolation = firstViolation();
assertEquals(expectedMessage, constraintViolation.getMsgFormat());
}
use of io.spine.validate.ConstraintViolation 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());
}
use of io.spine.validate.ConstraintViolation in project core-java by SpineEventEngine.
the class ValidatorShould method validate_command_and_return_violations_if_context_is_NOT_valid.
@Test
public void validate_command_and_return_violations_if_context_is_NOT_valid() {
final Command command = TestActorRequestFactory.newInstance(ValidatorShould.class).createCommand(createProjectMessage(), Time.getCurrentTime());
final Command commandWithoutContext = command.toBuilder().setContext(CommandContext.getDefaultInstance()).build();
final List<ConstraintViolation> violations = validator.validate(CommandEnvelope.of(commandWithoutContext));
assertEquals(1, violations.size());
}
Aggregations