use of org.openmrs.PersonAttributeType in project openmrs-core by openmrs.
the class PersonServiceTest method purgePersonAttributeType_shouldDeletePersonAttributeTypeFromDatabase.
/**
* @see PersonService#purgePersonAttributeType(PersonAttributeType)
*/
@Test
public void purgePersonAttributeType_shouldDeletePersonAttributeTypeFromDatabase() 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);
assertNotNull(pat.getId());
service.purgePersonAttributeType(pat);
PersonAttributeType deletedPersonAttributeType = service.getPersonAttributeType(pat.getId());
Assert.assertNull(deletedPersonAttributeType);
}
use of org.openmrs.PersonAttributeType in project openmrs-core by openmrs.
the class PersonServiceTest method shouldRetirePersonAttributeType.
@Test
public void shouldRetirePersonAttributeType() {
PersonAttributeType pat = personService.getPersonAttributeType(UNRETIRED_PERSON_ATTRIBUTE_TYPE);
assertFalse("need an unretired PersonAttributeType", pat.getRetired());
String retireReason = "reason";
personService.retirePersonAttributeType(pat, retireReason);
PersonAttributeType retiredPat = personService.getPersonAttributeType(UNRETIRED_PERSON_ATTRIBUTE_TYPE);
assertTrue(retiredPat.getRetired());
assertThat(retiredPat.getRetiredBy(), is(Context.getAuthenticatedUser()));
assertThat(retiredPat.getRetireReason(), is(retireReason));
assertNotNull(retiredPat.getDateRetired());
}
use of org.openmrs.PersonAttributeType in project openmrs-core by openmrs.
the class PersonServiceTest method shouldFailToRetirePersonAttributeTypeIfGivenReasonIsEmpty.
@Test(expected = APIException.class)
public void shouldFailToRetirePersonAttributeTypeIfGivenReasonIsEmpty() {
PersonAttributeType pat = personService.getPersonAttributeType(UNRETIRED_PERSON_ATTRIBUTE_TYPE);
personService.retirePersonAttributeType(pat, "");
}
use of org.openmrs.PersonAttributeType in project openmrs-core by openmrs.
the class PersonServiceTest method getPersonAttributeTypeByUuid_shouldFindObjectGivenValidUuid.
/**
* @see PersonService#getPersonAttributeTypeByUuid(String)
*/
@Test
public void getPersonAttributeTypeByUuid_shouldFindObjectGivenValidUuid() throws Exception {
String uuid = "b3b6d540-a32e-44c7-91b3-292d97667518";
PersonAttributeType personAttributeType = Context.getPersonService().getPersonAttributeTypeByUuid(uuid);
Assert.assertEquals(1, (int) personAttributeType.getPersonAttributeTypeId());
}
use of org.openmrs.PersonAttributeType in project openmrs-core by openmrs.
the class PersonServiceTest method getAllPersonAttributeTypes_shouldReturnAllPersonAttributeTypesIncludingRetiredWhenIncludeRetiredIsTrue.
/**
* @see PersonService#getAllPersonAttributeTypes(null)
*/
@Test
public void getAllPersonAttributeTypes_shouldReturnAllPersonAttributeTypesIncludingRetiredWhenIncludeRetiredIsTrue() throws Exception {
executeDataSet("org/openmrs/api/include/PersonServiceTest-createRetiredPersonAttributeType.xml");
// TODO: is this the correct way? or should we loop to find a retired type and then perform the following?
List<PersonAttributeType> attributeTypes = Context.getPersonService().getAllPersonAttributeTypes(true);
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);
}
Aggregations