use of org.openmrs.PersonName in project openmrs-core by openmrs.
the class PersonSaveHandlerTest method handle_shouldIgnoreBlankAddresses.
/**
* @see PersonSaveHandler#handle(Person,User, Date,String)
*/
@Test
public void handle_shouldIgnoreBlankAddresses() {
PersonSaveHandler handler = new PersonSaveHandler();
Person person = new Person();
PersonName personName = new PersonName("John", "", "Smith");
person.addName(personName);
person.setGender("M");
PersonAddress personAddress = new PersonAddress();
personAddress.setAddress1(" ");
person.addAddress(personAddress);
handler.handle(person, null, null, null);
Assert.assertEquals(0, person.getAddresses().size());
}
use of org.openmrs.PersonName in project openmrs-core by openmrs.
the class PatientValidatorTest method validate_shouldPassValidationIfFieldLengthsAreCorrect.
/**
* @see PatientValidator#validate(Object,Errors)
*/
@Override
@Test
public void validate_shouldPassValidationIfFieldLengthsAreCorrect() {
PatientIdentifierType patientIdentifierType = Context.getPatientService().getAllPatientIdentifierTypes(false).get(0);
Patient patient = new Patient();
PersonName pName = new PersonName();
pName.setGivenName("Tom");
pName.setMiddleName("E.");
pName.setFamilyName("Patient");
patient.addName(pName);
patient.setGender("male");
PersonAddress pAddress = new PersonAddress();
pAddress.setAddress1("123 My street");
pAddress.setAddress2("Apt 402");
pAddress.setCityVillage("Anywhere city");
pAddress.setCountry("Some Country");
Set<PersonAddress> pAddressList = patient.getAddresses();
pAddressList.add(pAddress);
patient.setAddresses(pAddressList);
patient.addAddress(pAddress);
PatientIdentifier patientIdentifier1 = new PatientIdentifier();
patientIdentifier1.setLocation(new Location(1));
patientIdentifier1.setIdentifier("012345678");
patientIdentifier1.setDateCreated(new Date());
patientIdentifier1.setIdentifierType(patientIdentifierType);
patient.addIdentifier(patientIdentifier1);
patient.setVoidReason("voidReason");
Errors errors = new BindException(patient, "patient");
validator.validate(patient, errors);
Assert.assertFalse(errors.hasErrors());
}
use of org.openmrs.PersonName in project openmrs-core by openmrs.
the class PersonNameValidatorTest method setUp.
@Before
public void setUp() {
validator = new PersonNameValidator();
personName = new PersonName();
errors = new BindException(personName, "personName");
Context.getAdministrationService().saveGlobalProperty(new GlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_PATIENT_NAME_REGEX, "^[a-zA-Z \\-]+$"));
}
use of org.openmrs.PersonName in project openmrs-core by openmrs.
the class PersonByNameComparatorTest method comparePersonsByName_shouldNotBeCaseSensitive.
@Test
public void comparePersonsByName_shouldNotBeCaseSensitive() {
Person person1 = new Person();
person1.addName(new PersonName("GIVENNAME", "MIDDLENAME", "FAMILYNAME"));
Person person2 = new Person();
person2.addName(new PersonName("givenName", "middleName", "familyName"));
int actualValue = PersonByNameComparator.comparePersonsByName(person1, person2);
Assert.assertTrue("Expected zero but it was: " + actualValue, actualValue == 0);
}
use of org.openmrs.PersonName in project openmrs-core by openmrs.
the class PersonByNameComparatorTest method comparePersonsByName_shouldReturnPositiveIfPersonNameForPerson1ComesAfterThatOfPerson2.
/**
* @see PersonByNameComparator#comparePersonsByName(Person,Person)
*/
@Test
public void comparePersonsByName_shouldReturnPositiveIfPersonNameForPerson1ComesAfterThatOfPerson2() {
Person person1 = new Person();
person1.addName(new PersonName("givenName", "middleNamf", "familyName"));
Person person2 = new Person();
person2.addName(new PersonName("givenName", "middleName", "familyName"));
int actualValue = PersonByNameComparator.comparePersonsByName(person1, person2);
Assert.assertTrue("Expected a positive value but it was: " + actualValue, actualValue > 0);
}
Aggregations