use of org.openmrs.PersonAttributeType in project openmrs-core by openmrs.
the class PersonServiceTest method savePersonAttributeType_shouldSetTheDateCreatedAndCreatorOnNew.
/**
* @see PersonService#savePersonAttributeType(PersonAttributeType)
*/
@Test
public void savePersonAttributeType_shouldSetTheDateCreatedAndCreatorOnNew() throws Exception {
PersonService service = Context.getPersonService();
PersonAttributeType pat = new PersonAttributeType();
pat.setName("attr type name");
pat.setDescription("attr type desc");
pat.setFormat("java.lang.String");
service.savePersonAttributeType(pat);
assertEquals(1, pat.getCreator().getId().intValue());
assertNotNull(pat.getDateCreated());
}
use of org.openmrs.PersonAttributeType in project openmrs-core by openmrs.
the class PersonServiceTest method getAllPersonAttributeTypes_shouldReturnAllPersonAttributeTypesIncludingRetired.
/**
* @see PersonService#getAllPersonAttributeTypes()
*/
@Test
public void getAllPersonAttributeTypes_shouldReturnAllPersonAttributeTypesIncludingRetired() throws Exception {
executeDataSet("org/openmrs/api/include/PersonServiceTest-createRetiredPersonAttributeType.xml");
List<PersonAttributeType> attributeTypes = Context.getPersonService().getAllPersonAttributeTypes();
assertTrue("At least one element, otherwise no checking for retired will take place", attributeTypes.size() > 0);
boolean foundRetired = false;
for (PersonAttributeType personAttributeType : attributeTypes) {
if (personAttributeType.getRetired()) {
foundRetired = true;
break;
}
}
assertTrue("There should be at least one retired person attribute type found in the list", foundRetired);
}
use of org.openmrs.PersonAttributeType in project openmrs-core by openmrs.
the class PersonServiceTest method shouldFailToRetirePersonAttributeTypeIfGivenReasonIsNull.
@Test(expected = APIException.class)
public void shouldFailToRetirePersonAttributeTypeIfGivenReasonIsNull() {
PersonAttributeType pat = personService.getPersonAttributeType(UNRETIRED_PERSON_ATTRIBUTE_TYPE);
personService.retirePersonAttributeType(pat, null);
}
use of org.openmrs.PersonAttributeType in project openmrs-core by openmrs.
the class PersonServiceTest method unretirePersonAttributeType_shouldThrowAnErrorWhenTryingToUnretirePersonAttributeTypeWhilePersonAttributeTypesAreLocked.
@Test(expected = PersonAttributeTypeLockedException.class)
public void unretirePersonAttributeType_shouldThrowAnErrorWhenTryingToUnretirePersonAttributeTypeWhilePersonAttributeTypesAreLocked() {
createPersonAttributeTypeLockedGPAndSetValue("true");
PersonAttributeType pat = personService.getPersonAttributeType(RETIRED_PERSON_ATTRIBUTE_TYPE);
personService.unretirePersonAttributeType(pat);
}
use of org.openmrs.PersonAttributeType in project openmrs-core by openmrs.
the class PersonAttributeTypeValidatorTest method validate_shouldPassValidationIfAllFieldsAreCorreect.
/**
* @see PersonAttributeTypeValidator#validate(Object,Errors)
*/
@Test
public void validate_shouldPassValidationIfAllFieldsAreCorreect() {
PersonAttributeType type = new PersonAttributeType();
type.setName("Zodiac");
type.setFormat("java.lang.String");
type.setDescription("Zodiac Description");
Errors errors = new BindException(type, "patObj");
new PersonAttributeTypeValidator().validate(type, errors);
Assert.assertFalse(errors.hasErrors());
}
Aggregations