Skip to content

Commit

Permalink
Merging commit for: Add JUnit test for not getting voided
Browse files Browse the repository at this point in the history
PatientIdentifier in HibernatePatientDAO.getPatientIdentifiers -
TRUNK-3200 author:akolodziejski
  • Loading branch information
dkayiwa committed Apr 30, 2013
1 parent 7cc9370 commit 14ee1bf
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
5 changes: 3 additions & 2 deletions api/src/main/java/org/openmrs/api/db/PatientDAO.java
Expand Up @@ -69,15 +69,16 @@ public List<Patient> getPatients(String name, String identifier, List<PatientIde

/**
* @see org.openmrs.api.PatientService#getPatientIdentifiers(java.lang.String, java.util.List,
* java.util.List, java.util.List, java.lang.Boolean)
* java.util.List, java.util.List, java.lang.Boolean)
*
* @should return all matching non voided patient identifiers if is preferred is set to null
* @should return all matching non voided patient identifiers if is preferred is set to true
* @should return all matching non voided patient identifiers if is preferred is set to false
* @should fetch all patient identifiers belong to given patient
* @should fetch all patient identifiers belong to given patients
* @should fetch patient identifiers that equals given identifier
* @should not fetch patient identifiers that partially matches given identifier
* @should not fetch patient identifiers that partially matches given identifier
* @should not get voided patient identifiers
*/
public List<PatientIdentifier> getPatientIdentifiers(String identifier,
List<PatientIdentifierType> patientIdentifierTypes, List<Location> locations, List<Patient> patients,
Expand Down
Expand Up @@ -251,7 +251,6 @@ public List<PatientIdentifier> getPatientIdentifiers(String identifier,
criteria.createAlias("patient", "patient");
criteria.add(Expression.eq("patient.voided", false));

// TODO add junit test for not getting voided
// make sure the patient object isn't voided
criteria.add(Expression.eq("voided", false));

Expand Down
24 changes: 24 additions & 0 deletions api/src/test/java/org/openmrs/api/db/PatientDAOTest.java
Expand Up @@ -279,6 +279,30 @@ public void getPatientIdentifiers_shouldLimitByResultsByLocation() throws Except
Assert.assertEquals(1, patientIdentifiers.size());
Assert.assertEquals("12345K", patientIdentifiers.get(0).getIdentifier());
}

/**
* @see PatientDAO#getPatientIdentifiers(String,List,List,List,Boolean)
* @verifies not get voided patient identifiers
*/
@Test
public void getPatientIdentifiers_shouldNotGetVoidedPatientIdentifiers()
throws Exception {


List<PatientIdentifier> patientIdentifiers
= dao.getPatientIdentifiers(null, new ArrayList<PatientIdentifierType>(),
new ArrayList<Location>(), new ArrayList<Patient>(), null);

//standartTestDataset.xml contains 5 non-voided identifiers

Assert.assertEquals(5, patientIdentifiers.size());

Assert.assertFalse(patientIdentifiers.get(0).isVoided());
Assert.assertFalse(patientIdentifiers.get(1).isVoided());
Assert.assertFalse(patientIdentifiers.get(2).isVoided());
Assert.assertFalse(patientIdentifiers.get(3).isVoided());
Assert.assertFalse(patientIdentifiers.get(4).isVoided());
}

/**
* @see PatientDAO#getPatientIdentifiers(String,List,List,List,Boolean)
Expand Down

0 comments on commit 14ee1bf

Please sign in to comment.