Search in sources :

Example 6 with PersonAttributeType

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);
}
Also used : PersonAttributeType(org.openmrs.PersonAttributeType) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 7 with PersonAttributeType

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);
}
Also used : PersonAttributeType(org.openmrs.PersonAttributeType) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 8 with PersonAttributeType

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);
}
Also used : PersonAttributeType(org.openmrs.PersonAttributeType) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 9 with PersonAttributeType

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");
}
Also used : PersonAttributeType(org.openmrs.PersonAttributeType) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 10 with PersonAttributeType

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);
}
Also used : PersonAttributeType(org.openmrs.PersonAttributeType) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Aggregations

PersonAttributeType (org.openmrs.PersonAttributeType)40 Test (org.junit.Test)33 BaseContextSensitiveTest (org.openmrs.test.BaseContextSensitiveTest)33 BindException (org.springframework.validation.BindException)7 Errors (org.springframework.validation.Errors)7 PersonAttribute (org.openmrs.PersonAttribute)4 Location (org.openmrs.Location)3 PatientIdentifierType (org.openmrs.PatientIdentifierType)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 Patient (org.openmrs.Patient)2 ImportPatientFromWebService (org.openmrs.module.importpatientfromws.api.ImportPatientFromWebService)2 RemoteServerConfiguration (org.openmrs.module.importpatientfromws.api.RemoteServerConfiguration)2 DLD (ca.uhn.hl7v2.model.v25.datatype.DLD)1 IS (ca.uhn.hl7v2.model.v25.datatype.IS)1 File (java.io.File)1 URL (java.net.URL)1 Random (java.util.Random)1 Ignore (org.junit.Ignore)1 GlobalProperty (org.openmrs.GlobalProperty)1