Search in sources :

Example 11 with PersonAttributeType

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

Example 12 with PersonAttributeType

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

Example 13 with PersonAttributeType

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

Example 14 with PersonAttributeType

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

Example 15 with PersonAttributeType

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());
}
Also used : Errors(org.springframework.validation.Errors) PersonAttributeType(org.openmrs.PersonAttributeType) BindException(org.springframework.validation.BindException) 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