use of org.openmrs.PersonName in project openmrs-core by openmrs.
the class PersonServiceTest method parsePersonName_shouldParseTwoPersonNameWithoutComma.
/**
* @see PersonService#parsePersonName(String)
*/
@Test
public void parsePersonName_shouldParseTwoPersonNameWithoutComma() throws Exception {
PersonName pname2 = Context.getPersonService().parsePersonName("John Doe");
assertEquals("Doe", pname2.getFamilyName());
assertEquals("John", pname2.getGivenName());
}
use of org.openmrs.PersonName in project openmrs-core by openmrs.
the class PersonServiceTest method voidPersonName_shouldVoidPersonNameWithTheGivenReason.
/**
* @see PersonService#voidPersonName(org.openmrs.PersonName, String)
*/
@Test
public void voidPersonName_shouldVoidPersonNameWithTheGivenReason() throws Exception {
executeDataSet("org/openmrs/api/include/PersionServiceTest-voidUnvoidPersonName.xml");
PersonName personName = Context.getPersonService().getPersonNameByUuid("5e6571cc-c7f2-41de-b289-f55f8fe79c6f");
Assert.assertFalse(personName.getVoided());
PersonName voidedPersonName = Context.getPersonService().voidPersonName(personName, "Test Voiding PersonName");
assertTrue(voidedPersonName.getVoided());
Assert.assertNotNull(voidedPersonName.getVoidedBy());
Assert.assertNotNull(voidedPersonName.getDateVoided());
Assert.assertEquals(voidedPersonName.getVoidReason(), "Test Voiding PersonName");
}
use of org.openmrs.PersonName in project openmrs-core by openmrs.
the class PersonServiceTest method getPersonNameById_shouldFindObjectGivenValidId.
@Test
public void getPersonNameById_shouldFindObjectGivenValidId() throws Exception {
PersonName personName = Context.getPersonService().getPersonName(2);
Assert.assertEquals(2, (int) personName.getId());
}
use of org.openmrs.PersonName in project openmrs-core by openmrs.
the class PersonServiceTest method parsePersonName_shouldNotFailWhenEndingWithWhitespace.
/**
* @see PersonService#parsePersonName(String)
*/
@Test
public void parsePersonName_shouldNotFailWhenEndingWithWhitespace() throws Exception {
PersonName pname = Context.getPersonService().parsePersonName("John ");
assertEquals("John", pname.getGivenName());
}
use of org.openmrs.PersonName in project openmrs-core by openmrs.
the class PersonServiceTest method savePerson_shouldSetThePreferredNameAndAddressIfNoneIsSpecified.
/**
* @see PersonService#savePerson(Person)
*/
@Test
public void savePerson_shouldSetThePreferredNameAndAddressIfNoneIsSpecified() throws Exception {
Person person = new Person();
person.setGender("M");
PersonName name = new PersonName("givenName", "middleName", "familyName");
person.addName(name);
PersonAddress address = new PersonAddress();
address.setAddress1("some address");
person.addAddress(address);
personService.savePerson(person);
assertTrue(name.getPreferred());
assertTrue(address.getPreferred());
}
Aggregations