use of org.springframework.validation.Errors in project openmrs-core by openmrs.
the class PersonAttributeTypeValidatorTest method validate_shouldPassValidationIfDescriptionIsNullOrEmptyOrWhitespace.
/**
* @see PersonAttributeTypeValidator#validate(Object,Errors)
*/
@Test
public void validate_shouldPassValidationIfDescriptionIsNullOrEmptyOrWhitespace() {
PersonAttributeType type = new PersonAttributeType();
type.setName("name");
type.setDescription(null);
Errors errors = new BindException(type, "type");
new PersonAttributeTypeValidator().validate(type, errors);
Assert.assertFalse(errors.hasFieldErrors("description"));
type.setDescription("");
errors = new BindException(type, "type");
new PersonAttributeTypeValidator().validate(type, errors);
Assert.assertFalse(errors.hasFieldErrors("description"));
type.setDescription(" ");
errors = new BindException(type, "type");
new PersonAttributeTypeValidator().validate(type, errors);
Assert.assertFalse(errors.hasFieldErrors("description"));
}
use of org.springframework.validation.Errors in project openmrs-core by openmrs.
the class PersonAttributeTypeValidatorTest method validate_shouldFailValidationIfFormatIsEmpty.
/**
* @see PersonAttributeTypeValidator#validate(Object,Errors)
*/
@Test
public void validate_shouldFailValidationIfFormatIsEmpty() {
PersonAttributeType type = new PersonAttributeType();
type.setName("Zodiac");
type.setDescription("Zodiac Description");
type.setFormat("");
Errors errors = new BindException(type, "patObj");
new PersonAttributeTypeValidator().validate(type, errors);
Assert.assertTrue(errors.hasFieldErrors("format"));
}
use of org.springframework.validation.Errors in project openmrs-core by openmrs.
the class PersonAttributeTypeValidatorTest method validate_shouldFailValidationIfFieldLengthsAreNotCorrect.
/**
* @see PersonAttributeTypeValidator#validate(Object,Errors)
*/
@Test
public void validate_shouldFailValidationIfFieldLengthsAreNotCorrect() {
PersonAttributeType type = new PersonAttributeType();
type.setName("too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text");
type.setFormat("too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text");
type.setRetireReason("too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text");
Errors errors = new BindException(type, "patObj");
new PersonAttributeTypeValidator().validate(type, errors);
Assert.assertTrue(errors.hasFieldErrors("name"));
Assert.assertTrue(errors.hasFieldErrors("format"));
Assert.assertTrue(errors.hasFieldErrors("retireReason"));
}
use of org.springframework.validation.Errors in project openmrs-core by openmrs.
the class PrivilegeValidatorTest method validate_shouldFailValidationIfPrivilegeIsNullOrEmptyOrWhitespace.
/**
* @see PrivilegeValidator#validate(Object,Errors)
*/
@Test
public void validate_shouldFailValidationIfPrivilegeIsNullOrEmptyOrWhitespace() {
Privilege priv = new Privilege();
priv.setPrivilege(null);
priv.setDescription("some text");
Errors errors = new BindException(priv, "priv");
new PrivilegeValidator().validate(priv, errors);
Assert.assertTrue(errors.hasFieldErrors("privilege"));
priv.setPrivilege("");
errors = new BindException(priv, "priv");
new PrivilegeValidator().validate(priv, errors);
Assert.assertTrue(errors.hasFieldErrors("privilege"));
priv.setPrivilege(" ");
errors = new BindException(priv, "priv");
new PrivilegeValidator().validate(priv, errors);
Assert.assertTrue(errors.hasFieldErrors("privilege"));
}
use of org.springframework.validation.Errors in project openmrs-core by openmrs.
the class PrivilegeValidatorTest method validate_shouldFailValidationIfFieldLengthsAreNotCorrect.
/**
* @see PrivilegeValidator#validate(Object,Errors)
*/
@Test
public void validate_shouldFailValidationIfFieldLengthsAreNotCorrect() {
Privilege priv = new Privilege();
priv.setPrivilege("too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text");
priv.setDescription("too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text");
Errors errors = new BindException(priv, "priv");
new PrivilegeValidator().validate(priv, errors);
Assert.assertTrue(errors.hasFieldErrors("privilege"));
Assert.assertTrue(errors.hasFieldErrors("description"));
}
Aggregations