use of org.openmrs.Person in project openmrs-core by openmrs.
the class PatientServiceTest method shouldFetchAddressesForPersonsThatWereFirstFetchedAsPatients.
/**
* This test verifies that {@link PersonAddress}es are fetched correctly from the hibernate
* cache. (Or really, not fetched from the cache but instead are mapped with lazy=false. For
* some reason Hibernate isn't able to find objects in the cache if a parent object was the one
* that loaded them)
*
* @throws Exception
*/
@Test
public void shouldFetchAddressesForPersonsThatWereFirstFetchedAsPatients() throws Exception {
Person person = Context.getPersonService().getPerson(2);
Patient patient = Context.getPatientService().getPatient(2);
patient.getAddresses().size();
person.getAddresses().size();
}
use of org.openmrs.Person in project openmrs-core by openmrs.
the class PatientServiceTest method shouldFetchPersonAttributesForPersonsThatWereFirstFetchedAsPatients.
/**
* This test verifies that {@link PersonAttribute}s are fetched correctly from the hibernate
* cache. (Or really, not fetched from the cache but instead are mapped with lazy=false. For
* some reason Hibernate isn't able to find objects in the cache if a parent object was the one
* that loaded them)
*
* @throws Exception
*/
@Test
public void shouldFetchPersonAttributesForPersonsThatWereFirstFetchedAsPatients() throws Exception {
Person person = Context.getPersonService().getPerson(2);
Patient patient = Context.getPatientService().getPatient(2);
patient.getAttributes().size();
person.getAttributes().size();
}
use of org.openmrs.Person in project openmrs-core by openmrs.
the class PatientServiceTest method savePatient_shouldNotThrowNonUniqueObjectExceptionWhenCalledWithPersonPromotedToPatient.
/**
* https://tickets.openmrs.org/browse/TRUNK-3728
*
* @see PatientService#savePatient(Patient)
*/
@Test
public void savePatient_shouldNotThrowNonUniqueObjectExceptionWhenCalledWithPersonPromotedToPatient() throws Exception {
Person person = personService.getPerson(1);
Patient patient = patientService.getPatientOrPromotePerson(person.getPersonId());
PatientIdentifier patientIdentifier = new PatientIdentifier("some identifier", new PatientIdentifierType(2), new Location(1));
patientIdentifier.setPreferred(true);
patient.addIdentifier(patientIdentifier);
patientService.savePatient(patient);
}
use of org.openmrs.Person in project openmrs-core by openmrs.
the class UserDAOTest method getUsers_shouldEscapeSqlWildcardsInSearchPhrase.
@Test
public void getUsers_shouldEscapeSqlWildcardsInSearchPhrase() {
User u = new User();
u.setPerson(new Person());
u.getPerson().setGender("M");
// we used to also test %, but UserValidator actually doesn't allow that in usernames. TODO: remove the loop
String[] wildcards = new String[] { "_" };
// with the wildcards and carry out a search for that user
for (String wildcard : wildcards) {
PersonName name = new PersonName(wildcard + "cats", wildcard + "and", wildcard + "dogs");
name.setDateCreated(new Date());
u.addName(name);
u.setUsername(wildcard + "test" + wildcard);
Context.getUserService().createUser(u, "Openmr5xy");
// we expect only one matching name or or systemId to be returned
int size = dao.getUsers(wildcard + "ca", null, false, null, null).size();
assertEquals(1, size);
// if actually the search returned the matching name or system id
String userName = (dao.getUsers(wildcard + "ca", null, false, null, null).get(0).getUsername());
assertEquals("Test failed since no user containing the character " + wildcard + " was found, ", wildcard + "test" + wildcard, userName);
}
}
use of org.openmrs.Person in project openmrs-core by openmrs.
the class AuditableInterceptorTest method onFlushDirty_shouldAddPersonChangedByForPerson.
@Test
public void onFlushDirty_shouldAddPersonChangedByForPerson() {
AuditableInterceptor interceptor = new AuditableInterceptor();
Person person = new Person();
String[] propertyNames = new String[] { "personChangedBy" };
Object[] currentState = new Object[] { null };
interceptor.onFlushDirty(person, null, currentState, null, propertyNames, null);
Assert.assertNotNull(currentState[0]);
}
Aggregations