use of org.openmrs.FieldType in project openmrs-core by openmrs.
the class FieldTypeValidatorTest method validate_shouldFailValidationIfNameIsNullOrEmptyOrWhitespace.
/**
* @see FieldTypeValidator#validate(Object,Errors)
*/
@Test
public void validate_shouldFailValidationIfNameIsNullOrEmptyOrWhitespace() {
FieldType type = new FieldType();
type.setName(null);
type.setDescription("Humba humba humba ...");
Errors errors = new BindException(type, "type");
new FieldTypeValidator().validate(type, errors);
Assert.assertTrue(errors.hasFieldErrors("name"));
type.setName("");
errors = new BindException(type, "type");
new FieldTypeValidator().validate(type, errors);
Assert.assertTrue(errors.hasFieldErrors("name"));
type.setName(" ");
errors = new BindException(type, "type");
new FieldTypeValidator().validate(type, errors);
Assert.assertTrue(errors.hasFieldErrors("name"));
}
use of org.openmrs.FieldType in project openmrs-core by openmrs.
the class FieldTypeValidatorTest method validate_shouldPassValidationIfAllRequiredFieldsHaveProperValues.
/**
* @see FieldTypeValidator#validate(Object,Errors)
*/
@Test
public void validate_shouldPassValidationIfAllRequiredFieldsHaveProperValues() {
FieldType type = new FieldType();
type.setName("soccer");
Errors errors = new BindException(type, "type");
new FieldTypeValidator().validate(type, errors);
Assert.assertFalse(errors.hasErrors());
}
use of org.openmrs.FieldType in project openmrs-core by openmrs.
the class FieldTypeValidatorTest method validate_shouldFailIfFieldTypeNameIsDuplicate.
/**
* @see org.openmrs.validator.FieldTypeValidator#validate(Object, Errors)
*/
@Test
public void validate_shouldFailIfFieldTypeNameIsDuplicate() {
FieldType type = new FieldType();
type.setName("some field type");
Errors errors = new BindException(type, "type");
new FieldTypeValidator().validate(type, errors);
Assert.assertTrue(errors.hasErrors());
}
Aggregations