Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TRUNK-3204 : Add JUnit test for getting by null/true/false isPreferred i... #231

Merged
merged 1 commit into from
Mar 25, 2013

Conversation

akolodziejski
Copy link
Contributor

3 test written based on data in standardTestDatabase.xml file.

public void getPatientIdentifiers_shouldLimitByResultsByPreferredAndNonPreferredIdentifier() throws Exception {

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens here if you pass in null, instead of the empty collections, i think it should be able to work

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you are passing in null for the isPreferred argument, i think the test name should mention this, i.e the test name should be something like:
getPatientIdentifiers_shouldReturnAllMatchingNonVoidedPatientIdentifiersIfIsPreferredIsSetToNull()
And preferrably use the behavior test plugin https://wiki.openmrs.org/display/docs/Generate+Test+Case+Plugin to generate these tests

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I saw implementation of HibernatePatienDAO::getPatientIdentifiers. And there is assumption that parameter with type collection is not null ( directly invoke size() method on collection).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is right, and it is because in PatientServiceImpl they are set to empty lists if they are null, so you don't have to do it too when calling the method.

…d in HibernatePatientDAO.getPatientIdentifiers

TRUNK-3204: Add JUnit test for getting by null/true/false isPreferred in HibernatePatientDAO.getPatientIdentifiers

TRUNK-3204: Add JUnit test for getting by null/true/false isPreferred in HibernatePatientDAO.getPatientIdentifiers

TRUNK-3204: Add JUnit test for getting by null/true/false isPreferred in HibernatePatientDAO.getPatientIdentifiers
rkorytkowski added a commit that referenced this pull request Mar 25, 2013
TRUNK-3204 : Add JUnit test for getting by null/true/false isPreferred i...
@rkorytkowski rkorytkowski merged commit 2252d65 into openmrs:master Mar 25, 2013
RandilaP pushed a commit to RandilaP/openmrs-core that referenced this pull request Jul 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants