use of org.openmrs.PersonAttributeType in project openmrs-core by openmrs.
the class PersonServiceTest method savePersonAttributeType_shouldThrowAnErrorWhenTryingToSavePersonAttributeTypeWhilePersonAttributeTypesAreLocked.
/**
* @see PersonService#savePersonAttributeType(PersonAttributeType)
* @throws PersonAttributeTypeLockedException
*/
@Test(expected = PersonAttributeTypeLockedException.class)
public void savePersonAttributeType_shouldThrowAnErrorWhenTryingToSavePersonAttributeTypeWhilePersonAttributeTypesAreLocked() throws Exception {
PersonService ps = Context.getPersonService();
createPersonAttributeTypeLockedGPAndSetValue("true");
PersonAttributeType pat = ps.getPersonAttributeType(1);
pat.setDescription("New person attribute type");
ps.savePersonAttributeType(pat);
}
use of org.openmrs.PersonAttributeType in project openmrs-core by openmrs.
the class PersonServiceTest method getPersonAttributeTypes_shouldReturnUserAttributesWhenViewTypeHeaderAndUser.
@Test
public void getPersonAttributeTypes_shouldReturnUserAttributesWhenViewTypeHeaderAndUser() {
adminService.setGlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_PATIENT_HEADER_ATTRIBUTES, "1");
adminService.setGlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_USER_HEADER_ATTRIBUTES, "2");
PersonAttributeType birthplace = personService.getPersonAttributeType(2);
List<PersonAttributeType> result = personService.getPersonAttributeTypes(OpenmrsConstants.PERSON_TYPE.USER, PersonService.ATTR_VIEW_TYPE.HEADER);
assertThat(result, contains(birthplace));
assertEquals(result.size(), 1);
}
use of org.openmrs.PersonAttributeType in project openmrs-core by openmrs.
the class PersonServiceTest method getPersonAttributeTypes_shouldReturnPatientAttributesWhenViewTypeViewingAndPatient.
@Test
public void getPersonAttributeTypes_shouldReturnPatientAttributesWhenViewTypeViewingAndPatient() {
adminService.setGlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_PATIENT_VIEWING_ATTRIBUTES, "1");
adminService.setGlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_USER_VIEWING_ATTRIBUTES, "2");
PersonAttributeType race = personService.getPersonAttributeType(1);
List<PersonAttributeType> result = personService.getPersonAttributeTypes(OpenmrsConstants.PERSON_TYPE.PATIENT, PersonService.ATTR_VIEW_TYPE.VIEWING);
assertThat(result, contains(race));
assertEquals(result.size(), 1);
}
use of org.openmrs.PersonAttributeType in project openmrs-core by openmrs.
the class PersonServiceTest method shouldFailToRetirePersonAttributeTypeWhilePersonAttributeTypesAreLocked.
@Test(expected = PersonAttributeTypeLockedException.class)
public void shouldFailToRetirePersonAttributeTypeWhilePersonAttributeTypesAreLocked() {
createPersonAttributeTypeLockedGPAndSetValue("true");
PersonAttributeType pat = personService.getPersonAttributeType(UNRETIRED_PERSON_ATTRIBUTE_TYPE);
personService.retirePersonAttributeType(pat, "Retire test");
}
use of org.openmrs.PersonAttributeType in project openmrs-core by openmrs.
the class PersonServiceTest method getPersonAttributeType_shouldReturnNullWhenNoPersonAttributeWithTheGivenIdExist.
/**
* @see PersonService#getPersonAttributeType(Integer)
*/
@Test
public void getPersonAttributeType_shouldReturnNullWhenNoPersonAttributeWithTheGivenIdExist() throws Exception {
PersonAttributeType attributeType = Context.getPersonService().getPersonAttributeType(10000);
Assert.assertNull(attributeType);
}
Aggregations