Search in sources :

Example 96 with PersonName

use of org.openmrs.PersonName in project openmrs-core by openmrs.

the class ProviderByPersonNameComparatorTest method compareProvidersByPersonName_shouldNotFailIfProvider2HasNoAssociatedPerson.

@Test
public void compareProvidersByPersonName_shouldNotFailIfProvider2HasNoAssociatedPerson() {
    Person person1 = new Person();
    person1.addName(new PersonName("givenName", "middleName", "familyName"));
    Provider provider1 = new Provider();
    provider1.setPerson(person1);
    Provider provider2 = new Provider();
    int actualValue = new ProviderByPersonNameComparator().compare(provider1, provider2);
    Assert.assertTrue("Expected a negative value but it was: " + actualValue, actualValue < 0);
}
Also used : PersonName(org.openmrs.PersonName) Person(org.openmrs.Person) Provider(org.openmrs.Provider) Test(org.junit.Test)

Example 97 with PersonName

use of org.openmrs.PersonName in project openmrs-core by openmrs.

the class ProviderByPersonNameComparatorTest method compareProvidersByPersonsName_shouldReturnNegativeIfPersonNameForProvider1ComesBeforeThatOfProvider2.

/**
 * @see PersonByNameComparator#comparePersonsByName(org.openmrs.Person, org.openmrs.Person)
 */
@Test
public void compareProvidersByPersonsName_shouldReturnNegativeIfPersonNameForProvider1ComesBeforeThatOfProvider2() {
    Person person1 = new Person();
    person1.addName(new PersonName("givenName", "middleName", "familyName"));
    Provider provider1 = new Provider();
    provider1.setPerson(person1);
    Person person2 = new Person();
    person2.addName(new PersonName("givenName", "middleNamf", "familyName"));
    Provider provider2 = new Provider();
    provider2.setPerson(person2);
    int actualValue = new ProviderByPersonNameComparator().compare(provider1, provider2);
    Assert.assertTrue("Expected a negative value but it was: " + actualValue, actualValue < 0);
}
Also used : PersonName(org.openmrs.PersonName) Person(org.openmrs.Person) Provider(org.openmrs.Provider) Test(org.junit.Test)

Example 98 with PersonName

use of org.openmrs.PersonName in project openmrs-core by openmrs.

the class ProviderByPersonNameComparatorTest method compareProvidersByPersonName_shouldReturnZeroIfTheGivenNameMiddleNameAndFamilyNameMatch.

/**
 * @see PersonByNameComparator#comparePersonsByName(Person,Person)
 */
@Test
public void compareProvidersByPersonName_shouldReturnZeroIfTheGivenNameMiddleNameAndFamilyNameMatch() {
    Person person1 = new Person();
    person1.addName(new PersonName("givenName", "middleName", "familyName"));
    Provider provider1 = new Provider();
    provider1.setPerson(person1);
    Person person2 = new Person();
    person2.addName(new PersonName("givenName", "middleName", "familyName"));
    Provider provider2 = new Provider();
    provider2.setPerson(person2);
    int actualValue = new ProviderByPersonNameComparator().compare(provider1, provider2);
    Assert.assertTrue("Expected zero but it was: " + actualValue, actualValue == 0);
}
Also used : PersonName(org.openmrs.PersonName) Person(org.openmrs.Person) Provider(org.openmrs.Provider) Test(org.junit.Test)

Example 99 with PersonName

use of org.openmrs.PersonName in project openmrs-core by openmrs.

the class UserByNameComparatorTest method compare_shouldSortUsersByPersonNames.

/**
 * This tests sorting with the {@link UserByNameComparator} given a set of users with
 * personNames
 *
 * @see UserByNameComparator#compare(User,User)
 */
@Test
public void compare_shouldSortUsersByPersonNames() {
    Person person1 = new Person();
    person1.addName(new PersonName("givenName", "middleName", "familyName"));
    User user1 = new User(person1);
    Person person2 = new Person();
    person2.addName(new PersonName("givenName", "middleNamf", "familyName"));
    User user2 = new User(person2);
    Person person3 = new Person();
    person3.addName(new PersonName("givenName", "middleNamg", "familyName"));
    User user3 = new User(person3);
    Person person4 = new Person();
    person4.addName(new PersonName("givenName", "middleNamh", "familyName"));
    User user4 = new User(person4);
    List<User> listToSort = new ArrayList<>();
    // add the users randomly
    listToSort.add(user3);
    listToSort.add(user1);
    listToSort.add(user4);
    listToSort.add(user2);
    // sort the list with userByNameComparator
    listToSort.sort(new UserByNameComparator());
    // make sure that the users are sorted in the expected order
    Iterator<User> it = listToSort.iterator();
    Assert.assertTrue("Expected user1 to be the first in the sorted user list but wasn't", user1.equals(it.next()));
    Assert.assertTrue("Expected user2 to be the second in the sorted user list but wasn't", user2.equals(it.next()));
    Assert.assertTrue("Expected user3 to be the third in the sorted user list but wasn't", user3.equals(it.next()));
    Assert.assertTrue("Expected user4 to be the fourth in the sorted user list but wasn't", user4.equals(it.next()));
}
Also used : PersonName(org.openmrs.PersonName) User(org.openmrs.User) ArrayList(java.util.ArrayList) Person(org.openmrs.Person) Test(org.junit.Test)

Example 100 with PersonName

use of org.openmrs.PersonName in project openmrs-core by openmrs.

the class PersonServiceTest method parsePersonName_shouldNotFailWhenEndingWithAComma.

/**
 * @see PersonService#parsePersonName(String)
 */
@Test
public void parsePersonName_shouldNotFailWhenEndingWithAComma() throws Exception {
    PersonName pname = Context.getPersonService().parsePersonName("John,");
    assertEquals("John", pname.getGivenName());
}
Also used : PersonName(org.openmrs.PersonName) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Aggregations

PersonName (org.openmrs.PersonName)108 Test (org.junit.Test)81 BaseContextSensitiveTest (org.openmrs.test.BaseContextSensitiveTest)57 Patient (org.openmrs.Patient)41 Person (org.openmrs.Person)39 Date (java.util.Date)26 PatientIdentifier (org.openmrs.PatientIdentifier)19 PersonAddress (org.openmrs.PersonAddress)19 User (org.openmrs.User)17 PatientServiceImplTest (org.openmrs.api.impl.PatientServiceImplTest)17 PatientIdentifierType (org.openmrs.PatientIdentifierType)13 Location (org.openmrs.Location)12 ArrayList (java.util.ArrayList)9 BaseModuleContextSensitiveTest (org.openmrs.test.BaseModuleContextSensitiveTest)9 PersonMergeLog (org.openmrs.person.PersonMergeLog)8 PersonAttribute (org.openmrs.PersonAttribute)7 PatientAndMatchQuality (org.openmrs.module.registrationcore.api.search.PatientAndMatchQuality)7 BindException (org.springframework.validation.BindException)7 Errors (org.springframework.validation.Errors)6 Provider (org.openmrs.Provider)5