/** * Get givenName on the Person this user account belongs to * * @see Person#getGivenName() */ public String getGivenName() { return getPerson() == null ? null : getPerson().getGivenName(); }
@Test public void getPatients_shouldReturnOnlyPatients() { Person person = personService.getPerson(501); assertThat(person.getIsPatient(), is(false)); List<Patient> patients = patientService.getPatients(person.getGivenName()); assertThat(patients, is(empty())); }
/** * @see HibernatePersonDAO#getPeople(String, Boolean) */ @Test public void getPeople_shouldGetMultiplePeopleByFamilyName() { List<Person> people = hibernatePersonDAO.getPeople("kilo", false); logPeople(people); Assert.assertEquals(2, people.size()); Assert.assertEquals("kilo", people.get(0).getFamilyName()); Assert.assertEquals("kilo", people.get(1).getFamilyName()); Assert.assertTrue(people.get(0).getGivenName() != people.get(1).getGivenName()); }
/** * @see HibernatePersonDAO#getPeople(String, Boolean) */ @Test public void getPeople_shouldGetMultiplePeopleBySingleName() { List<Person> people = hibernatePersonDAO.getPeople("Baggins", false); logPeople(people); Assert.assertEquals(2, people.size()); Assert.assertEquals("Baggins", people.get(0).getFamilyName()); Assert.assertEquals("Baggins", people.get(1).getFamilyName()); Assert.assertFalse(people.get(0).getGivenName().equalsIgnoreCase(people.get(1).getGivenName())); }
/** * @see HibernatePersonDAO#getPeople(String, Boolean) */ @Test public void getPeople_shouldGetMultiplePeopleByMultipleNames() { List<Person> people = hibernatePersonDAO.getPeople("Bilbo Frodo", false); logPeople(people); Assert.assertEquals(2, people.size()); Assert.assertEquals("Baggins", people.get(0).getFamilyName()); Assert.assertEquals("Baggins", people.get(1).getFamilyName()); Assert.assertFalse(people.get(0).getGivenName().equalsIgnoreCase(people.get(1).getGivenName())); }
/** * @see HibernatePersonDAO#getPeople(String, Boolean) */ @Test public void getPeople_shouldGetMultiplePeopleByGivenName() { List<Person> people = hibernatePersonDAO.getPeople("alpha", false); logPeople(people); Assert.assertEquals(2, people.size()); Assert.assertEquals("alpha", people.get(0).getGivenName()); Assert.assertEquals("alpha", people.get(1).getGivenName()); Assert.assertTrue(people.get(0).getMiddleName() != people.get(1).getMiddleName()); }
/** * @see HibernatePersonDAO#getPeople(String, Boolean) */ @Test public void getPeople_shouldGetMultiplePeopleByNameAndAttribute() { List<Person> people = hibernatePersonDAO .getPeople( "Bilbo Baggins Story Teller Master Thief Porridge Honey Frodo Baggins Ring Bearer Mushroom Pie Gandalf Wizard Beer", false); logPeople(people); Assert.assertEquals(2, people.size()); Assert.assertEquals("Baggins", people.get(0).getFamilyName()); Assert.assertEquals("Baggins", people.get(1).getFamilyName()); Assert.assertFalse(people.get(0).getGivenName().equalsIgnoreCase(people.get(1).getGivenName())); }
/** * @see HibernatePersonDAO#getPeople(String, Boolean) */ @Test public void getPeople_shouldGetOnePersonByFamilyName2() { List<Person> people = hibernatePersonDAO.getPeople("mike", false); logPeople(people); Assert.assertEquals(1, people.size()); Assert.assertEquals("alpha", people.get(0).getGivenName()); }
/** * @see HibernatePersonDAO#getPeople(String, Boolean) */ @Test public void getPeople_shouldGetOnePersonByRandomCaseName() { List<Person> people = hibernatePersonDAO.getPeople("fRoDo", false); logPeople(people); Assert.assertEquals(1, people.size()); Assert.assertEquals("Frodo Ansilon", people.get(0).getGivenName()); }
/** * @see HibernatePersonDAO#getPeople(String, Boolean) */ @Test public void getPeople_shouldGetOnePersonByMultipleNameParts() { List<Person> people = hibernatePersonDAO.getPeople("echo india mike", false); logPeople(people); Assert.assertEquals(1, people.size()); Assert.assertEquals("alpha", people.get(0).getGivenName()); }
/** * @see HibernatePersonDAO#getPeople(String, Boolean) */ @Test public void getPeople_shouldGetSingleDeadPerson() { List<Person> people = hibernatePersonDAO.getPeople("dead-charlie", true); logPeople(people); Assert.assertEquals(1, people.size()); Assert.assertEquals("dead-charlie", people.get(0).getGivenName()); }
/** * @see HibernatePersonDAO#getPeople(String, Boolean) */ @Test public void getPeople_shouldGetOnePersonByGivenName() { List<Person> people = hibernatePersonDAO.getPeople("bravo", false); logPeople(people); Assert.assertEquals(1, people.size()); Assert.assertEquals("bravo", people.get(0).getGivenName()); }
/** * @see HibernatePersonDAO#getPeople(String, Boolean) */ @Test public void getPeople_shouldGetOnePersonByName() { List<Person> people = hibernatePersonDAO.getPeople("Bilbo", false); logPeople(people); Assert.assertEquals(1, people.size()); Assert.assertEquals("Bilbo Odilon", people.get(0).getGivenName()); }
/** * @see HibernatePersonDAO#getPeople(String, Boolean) */ @Test public void getPeople_shouldGetMultiplePeopleBySingleAttribute() { globalPropertiesTestHelper.setGlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_PERSON_ATTRIBUTE_SEARCH_MATCH_MODE, OpenmrsConstants.GLOBAL_PROPERTY_PERSON_ATTRIBUTE_SEARCH_MATCH_ANYWHERE); Assert.assertTrue(personAttributeHelper.personAttributeExists("Senior ring bearer")); List<Person> people = hibernatePersonDAO.getPeople("Senior ring bearer", false); logPeople(people); Assert.assertEquals(2, people.size()); Assert.assertEquals("Baggins", people.get(0).getFamilyName()); Assert.assertEquals("Baggins", people.get(1).getFamilyName()); Assert.assertFalse(people.get(0).getGivenName().equalsIgnoreCase(people.get(1).getGivenName())); }
/** * @see HibernatePersonDAO#getPeople(String, Boolean) */ @Test public void getPeople_shouldGetOnePersonByNameAndAttribute() { Assert.assertTrue(personAttributeHelper.personAttributeExists("Story teller")); List<Person> people = hibernatePersonDAO.getPeople("Bilbo Story Teller", false); logPeople(people); Assert.assertEquals(1, people.size()); Assert.assertEquals("Bilbo Odilon", people.get(0).getGivenName()); }
/** * @see HibernatePersonDAO#getPeople(String, Boolean) */ @Test public void getPeople_shouldGetOnePersonByNameAndVoidedAttribute() { Assert.assertTrue(personAttributeHelper.voidedPersonAttributeExists("Master Thief")); List<Person> people = hibernatePersonDAO.getPeople("Frodo Master Thief", false); logPeople(people); Assert.assertEquals(1, people.size()); Assert.assertEquals("Frodo Ansilon", people.get(0).getGivenName()); }
/** * @see HibernatePersonDAO#getPeople(String, Boolean) */ @Test public void getPeople_shouldGetMultiplePeopleByMultipleAttributes() { globalPropertiesTestHelper.setGlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_PERSON_ATTRIBUTE_SEARCH_MATCH_MODE, OpenmrsConstants.GLOBAL_PROPERTY_PERSON_ATTRIBUTE_SEARCH_MATCH_ANYWHERE); Assert.assertTrue(personAttributeHelper.personAttributeExists("Senior ring bearer")); Assert.assertTrue(personAttributeHelper.personAttributeExists("Story teller")); List<Person> people = hibernatePersonDAO.getPeople("Story Bearer", false); logPeople(people); Assert.assertEquals(2, people.size()); Assert.assertEquals("Baggins", people.get(0).getFamilyName()); Assert.assertEquals("Baggins", people.get(1).getFamilyName()); Assert.assertFalse(people.get(0).getGivenName().equalsIgnoreCase(people.get(1).getGivenName())); }
/** * @see HibernatePersonDAO#getPeople(String, Boolean) */ @Test public void getPeople_shouldGetOnePersonByRandomCaseAttribute() { globalPropertiesTestHelper.setGlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_PERSON_ATTRIBUTE_SEARCH_MATCH_MODE, OpenmrsConstants.GLOBAL_PROPERTY_PERSON_ATTRIBUTE_SEARCH_MATCH_ANYWHERE); Assert.assertTrue(personAttributeHelper.personAttributeExists("Story teller")); List<Person> people = hibernatePersonDAO.getPeople("sToRy TeLlEr", false); logPeople(people); Assert.assertEquals(1, people.size()); Assert.assertEquals("Bilbo Odilon", people.get(0).getGivenName()); }
/** * @see HibernatePersonDAO#getPeople(String, Boolean) */ @Test public void getPeople_shouldGetOnePersonByAttribute() { globalPropertiesTestHelper.setGlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_PERSON_ATTRIBUTE_SEARCH_MATCH_MODE, OpenmrsConstants.GLOBAL_PROPERTY_PERSON_ATTRIBUTE_SEARCH_MATCH_ANYWHERE); Assert.assertTrue(personAttributeHelper.personAttributeExists("Story teller")); List<Person> people = hibernatePersonDAO.getPeople("Story Teller", false); logPeople(people); Assert.assertEquals(1, people.size()); Assert.assertEquals("Bilbo Odilon", people.get(0).getGivenName()); }
/** * @see HibernatePersonDAO#getPeople(String, Boolean) */ @Test public void getPeople_shouldGetOnePersonBySearchingForAMixOfAttributeAndVoidedAttribute() { globalPropertiesTestHelper.setGlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_PERSON_ATTRIBUTE_SEARCH_MATCH_MODE, OpenmrsConstants.GLOBAL_PROPERTY_PERSON_ATTRIBUTE_SEARCH_MATCH_ANYWHERE); Assert.assertTrue(personAttributeHelper.personAttributeExists("Story teller")); Assert.assertFalse(personAttributeHelper.voidedPersonAttributeExists("Story teller")); Assert.assertTrue(personAttributeHelper.voidedPersonAttributeExists("Master thief")); List<Person> people = hibernatePersonDAO.getPeople("Story Thief", false); logPeople(people); Assert.assertEquals(1, people.size()); Assert.assertEquals("Bilbo Odilon", people.get(0).getGivenName()); }