use of org.openmrs.EncounterType in project openmrs-core by openmrs.
the class EncounterTypeValidatorTest method validate_shouldFailIfEncounterTypeNameIsDuplicate.
/**
* @see EncounterTypeValidator#validate(Object, Errors)
*/
@Test
public void validate_shouldFailIfEncounterTypeNameIsDuplicate() {
Assert.assertNotNull(Context.getEncounterService().getEncounterType("Scheduled"));
EncounterType newEncounterType = new EncounterType();
newEncounterType.setName("Scheduled");
Errors errors = new BindException(newEncounterType, "encounterType");
new EncounterTypeValidator().validate(newEncounterType, errors);
Assert.assertTrue(errors.hasFieldErrors("name"));
}
use of org.openmrs.EncounterType in project openmrs-core by openmrs.
the class EncounterTypeValidatorTest method validate_shouldFailValidationIfNameIsNullOrEmptyOrWhitespace.
/**
* @see EncounterTypeValidator#validate(Object,Errors)
*/
@Test
public void validate_shouldFailValidationIfNameIsNullOrEmptyOrWhitespace() {
EncounterType type = new EncounterType();
type.setName(null);
type.setDescription("Aaaaah");
Errors errors = new BindException(type, "type");
new EncounterTypeValidator().validate(type, errors);
Assert.assertTrue(errors.hasFieldErrors("name"));
type.setName("");
errors = new BindException(type, "type");
new EncounterTypeValidator().validate(type, errors);
Assert.assertTrue(errors.hasFieldErrors("name"));
type.setName(" ");
errors = new BindException(type, "type");
new EncounterTypeValidator().validate(type, errors);
Assert.assertTrue(errors.hasFieldErrors("name"));
}
use of org.openmrs.EncounterType in project openmrs-core by openmrs.
the class EncounterTypeValidatorTest method validate_shouldFailValidationIfFieldLengthsAreNotCorrect.
/**
* @see EncounterTypeValidator#validate(Object,Errors)
*/
@Test
public void validate_shouldFailValidationIfFieldLengthsAreNotCorrect() {
EncounterType type = new EncounterType();
type.setName(StringUtils.repeat("longer than 50 chars", 6));
type.setDescription(StringUtils.repeat("longer than 1024 chars", 120));
type.setRetireReason(StringUtils.repeat("longer than 255 chars", 27));
Errors errors = new BindException(type, "type");
new EncounterTypeValidator().validate(type, errors);
Assert.assertTrue(errors.hasFieldErrors("name"));
Assert.assertTrue(errors.hasFieldErrors("description"));
Assert.assertTrue(errors.hasFieldErrors("retireReason"));
}
use of org.openmrs.EncounterType in project openmrs-core by openmrs.
the class EncounterTypeValidatorTest method validate_shouldPassValidationIfDescriptionIsNullOrEmptyOrWhitespace.
/**
* @see EncounterTypeValidator#validate(Object,Errors)
*/
@Test
public void validate_shouldPassValidationIfDescriptionIsNullOrEmptyOrWhitespace() {
EncounterType type = new EncounterType();
type.setName("CLOSE");
type.setDescription(null);
Errors errors = new BindException(type, "type");
new EncounterTypeValidator().validate(type, errors);
Assert.assertFalse(errors.hasFieldErrors("description"));
type.setDescription("");
errors = new BindException(type, "type");
new EncounterTypeValidator().validate(type, errors);
Assert.assertFalse(errors.hasFieldErrors("description"));
type.setDescription(" ");
errors = new BindException(type, "type");
new EncounterTypeValidator().validate(type, errors);
Assert.assertFalse(errors.hasFieldErrors("description"));
}
use of org.openmrs.EncounterType in project openmrs-core by openmrs.
the class EncounterTypeValidatorTest method validate_shouldPassValidationIfAllRequiredFieldsHaveProperValues.
/**
* @see EncounterTypeValidator#validate(Object,Errors)
*/
@Test
public void validate_shouldPassValidationIfAllRequiredFieldsHaveProperValues() {
EncounterType type = new EncounterType();
type.setName("CLOSE");
type.setDescription("Aaaaah");
Errors errors = new BindException(type, "type");
new EncounterTypeValidator().validate(type, errors);
Assert.assertFalse(errors.hasErrors());
}
Aggregations