Skip to content

Commit 14ee1bf

Browse files
committedApr 30, 2013
Merging commit for: Add JUnit test for not getting voided
PatientIdentifier in HibernatePatientDAO.getPatientIdentifiers - TRUNK-3200 author:akolodziejski
1 parent 7cc9370 commit 14ee1bf

File tree

3 files changed

+27
-3
lines changed

3 files changed

+27
-3
lines changed
 

‎api/src/main/java/org/openmrs/api/db/PatientDAO.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,16 @@ public List<Patient> getPatients(String name, String identifier, List<PatientIde
6969

7070
/**
7171
* @see org.openmrs.api.PatientService#getPatientIdentifiers(java.lang.String, java.util.List,
72-
* java.util.List, java.util.List, java.lang.Boolean)
72+
* java.util.List, java.util.List, java.lang.Boolean)
7373
*
7474
* @should return all matching non voided patient identifiers if is preferred is set to null
7575
* @should return all matching non voided patient identifiers if is preferred is set to true
7676
* @should return all matching non voided patient identifiers if is preferred is set to false
7777
* @should fetch all patient identifiers belong to given patient
7878
* @should fetch all patient identifiers belong to given patients
7979
* @should fetch patient identifiers that equals given identifier
80-
* @should not fetch patient identifiers that partially matches given identifier
80+
* @should not fetch patient identifiers that partially matches given identifier
81+
* @should not get voided patient identifiers
8182
*/
8283
public List<PatientIdentifier> getPatientIdentifiers(String identifier,
8384
List<PatientIdentifierType> patientIdentifierTypes, List<Location> locations, List<Patient> patients,

‎api/src/main/java/org/openmrs/api/db/hibernate/HibernatePatientDAO.java

-1
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,6 @@ public List<PatientIdentifier> getPatientIdentifiers(String identifier,
251251
criteria.createAlias("patient", "patient");
252252
criteria.add(Expression.eq("patient.voided", false));
253253

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

‎api/src/test/java/org/openmrs/api/db/PatientDAOTest.java

+24
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,30 @@ public void getPatientIdentifiers_shouldLimitByResultsByLocation() throws Except
279279
Assert.assertEquals(1, patientIdentifiers.size());
280280
Assert.assertEquals("12345K", patientIdentifiers.get(0).getIdentifier());
281281
}
282+
283+
/**
284+
* @see PatientDAO#getPatientIdentifiers(String,List,List,List,Boolean)
285+
* @verifies not get voided patient identifiers
286+
*/
287+
@Test
288+
public void getPatientIdentifiers_shouldNotGetVoidedPatientIdentifiers()
289+
throws Exception {
290+
291+
292+
List<PatientIdentifier> patientIdentifiers
293+
= dao.getPatientIdentifiers(null, new ArrayList<PatientIdentifierType>(),
294+
new ArrayList<Location>(), new ArrayList<Patient>(), null);
295+
296+
//standartTestDataset.xml contains 5 non-voided identifiers
297+
298+
Assert.assertEquals(5, patientIdentifiers.size());
299+
300+
Assert.assertFalse(patientIdentifiers.get(0).isVoided());
301+
Assert.assertFalse(patientIdentifiers.get(1).isVoided());
302+
Assert.assertFalse(patientIdentifiers.get(2).isVoided());
303+
Assert.assertFalse(patientIdentifiers.get(3).isVoided());
304+
Assert.assertFalse(patientIdentifiers.get(4).isVoided());
305+
}
282306

283307
/**
284308
* @see PatientDAO#getPatientIdentifiers(String,List,List,List,Boolean)

0 commit comments

Comments
 (0)
Please sign in to comment.