use of org.openmrs.FieldType in project openmrs-core by openmrs.
the class FieldValidatorTest method validate_shouldFailValidationIfNameIsEmpty.
/**
* @see FieldValidator#validate(Object,Errors)
*/
@Test
public void validate_shouldFailValidationIfNameIsEmpty() {
Field ff = new Field();
ff.setName("");
FieldType ft = new FieldType();
Boolean retired = Boolean.FALSE;
ft.setId(0xdeadcafe);
ff.setFieldType(ft);
ff.setRetired(retired);
Boolean multiple = Boolean.FALSE;
ff.setSelectMultiple(multiple);
Errors errors = new BindException(ff, "name");
new FieldValidator().validate(ff, errors);
Assert.assertTrue(errors.hasFieldErrors("name"));
}
use of org.openmrs.FieldType in project openmrs-core by openmrs.
the class FieldValidatorTest method validate_shouldFailValidationIfNameIsNull.
/**
* @see FieldValidator#validate(Object,Errors)
*/
@Test
public void validate_shouldFailValidationIfNameIsNull() {
Field ff = new Field();
ff.setName(null);
FieldType ft = new FieldType();
Boolean retired = Boolean.FALSE;
ft.setId(0xdeadcafe);
ff.setFieldType(ft);
ff.setRetired(retired);
Boolean multiple = Boolean.FALSE;
ff.setSelectMultiple(multiple);
Errors errors = new BindException(ff, "name");
new FieldValidator().validate(ff, errors);
Assert.assertTrue(errors.hasFieldErrors("name"));
}
use of org.openmrs.FieldType in project openmrs-core by openmrs.
the class FieldValidatorTest method validate_shouldPassValidationIfFieldLengthsAreCorrect.
/**
* @see FieldValidator#validate(Object,Errors)
*/
@Test
public void validate_shouldPassValidationIfFieldLengthsAreCorrect() {
Field ff = new Field();
FieldType ft = new FieldType();
Boolean retired = Boolean.FALSE;
ft.setId(0xdeadcafe);
ff.setFieldType(ft);
ff.setName("name");
ff.setRetired(retired);
Boolean multiple = Boolean.FALSE;
ff.setSelectMultiple(multiple);
ff.setTableName("tableName");
ff.setAttributeName("attributeName");
ff.setRetireReason("retireReason");
Errors errors = new BindException(ff, "field");
new FieldValidator().validate(ff, errors);
Assert.assertFalse(errors.hasErrors());
}
use of org.openmrs.FieldType in project openmrs-core by openmrs.
the class FieldValidatorTest method validate_shouldFailValidationIfRetiredIsNull.
/**
* @see FieldValidator#validate(Object,Errors)
*/
@Test
public void validate_shouldFailValidationIfRetiredIsNull() {
Field ff = new Field();
ff.setName("good");
FieldType ft = new FieldType();
ft.setFieldTypeId(0xdeadcafe);
ff.setFieldType(ft);
ff.setName("valid");
Boolean retired = null;
ff.setRetired(retired);
Boolean multiple = Boolean.TRUE;
ff.setSelectMultiple(multiple);
Errors errors = new BindException(ff, "retired");
new FieldValidator().validate(ff, errors);
Assert.assertTrue(errors.hasFieldErrors("retired"));
}
use of org.openmrs.FieldType in project openmrs-core by openmrs.
the class FieldTypeValidatorTest method validate_shouldPassValidationIfFieldLengthsAreCorrect.
/**
* @see FieldTypeValidator#validate(Object,Errors)
*/
@Test
public void validate_shouldPassValidationIfFieldLengthsAreCorrect() {
FieldType type = new FieldType();
type.setName("soccer");
Errors errors = new BindException(type, "type");
new FieldTypeValidator().validate(type, errors);
Assert.assertFalse(errors.hasErrors());
}
Aggregations