use of org.openmrs.PersonName in project openmrs-core by openmrs.
the class PersonServiceTest method getPersonNameByUuid_shouldFindObjectGivenValidUuid.
/**
* @see PersonService#getPersonNameByUuid(String)
*/
@Test
public void getPersonNameByUuid_shouldFindObjectGivenValidUuid() throws Exception {
String uuid = "399e3a7b-6482-487d-94ce-c07bb3ca3cc7";
PersonName personName = Context.getPersonService().getPersonNameByUuid(uuid);
Assert.assertEquals(2, (int) personName.getPersonNameId());
}
use of org.openmrs.PersonName in project openmrs-core by openmrs.
the class PersonServiceTest method parsePersonName_shouldParseFourPersonName.
/**
* @see PersonService#parsePersonName(String)
*/
@Test
public void parsePersonName_shouldParseFourPersonName() throws Exception {
PersonName pname = Context.getPersonService().parsePersonName("John David Alex Smith");
assertEquals("John", pname.getGivenName());
assertEquals("David", pname.getMiddleName());
assertEquals("Alex", pname.getFamilyName());
assertEquals("Smith", pname.getFamilyName2());
}
use of org.openmrs.PersonName in project openmrs-core by openmrs.
the class PersonServiceTest method getPersonNameById_shouldNotFindAnyObjectGivenInvalidId.
@Test
public void getPersonNameById_shouldNotFindAnyObjectGivenInvalidId() throws Exception {
PersonName personName = Context.getPersonService().getPersonName(-1);
Assert.assertNull(personName);
}
use of org.openmrs.PersonName in project openmrs-core by openmrs.
the class PersonServiceTest method savePerson_shouldNotSetThePreferredNameAndAddressIfTheyAlreadyExist.
/**
* @see PersonService#savePerson(Person)
*/
@Test
public void savePerson_shouldNotSetThePreferredNameAndAddressIfTheyAlreadyExist() throws Exception {
Person person = new Person();
person.setGender("M");
PersonName name = new PersonName("givenName", "middleName", "familyName");
PersonName preferredName = new PersonName("givenName", "middleName", "familyName");
preferredName.setPreferred(true);
person.addName(name);
person.addName(preferredName);
PersonAddress address = new PersonAddress();
address.setAddress1("some address");
PersonAddress preferredAddress = new PersonAddress();
preferredAddress.setAddress1("another address");
preferredAddress.setPreferred(true);
person.addAddress(address);
person.addAddress(preferredAddress);
personService.savePerson(person);
assertTrue(preferredName.getPreferred());
assertTrue(preferredAddress.getPreferred());
Assert.assertFalse(name.getPreferred());
Assert.assertFalse(address.getPreferred());
}
use of org.openmrs.PersonName in project openmrs-core by openmrs.
the class UserServiceTest method userWithValidPerson.
private User userWithValidPerson() {
Person person = new Person();
person.addName(new PersonName("jane", "sue", "doe"));
person.setGender("F");
return new User(person);
}
Aggregations