Skip to content

TRUNK-6598: Add missing unit test for containingAnyFormField in HibernateFormDAO#5983

Open
ShrutiSocrates wants to merge 6 commits intoopenmrs:masterfrom
ShrutiSocrates:TRUNK-add-containingAnyFormField-test
Open

TRUNK-6598: Add missing unit test for containingAnyFormField in HibernateFormDAO#5983
ShrutiSocrates wants to merge 6 commits intoopenmrs:masterfrom
ShrutiSocrates:TRUNK-add-containingAnyFormField-test

Conversation

@ShrutiSocrates
Copy link
Copy Markdown

TRUNK-6598: Add missing unit test for containingAnyFormField in HibernateFormDAO

Description of what I changed

Added a missing unit test for the containingAnyFormField functionality in HibernateFormDAO as indicated by the TODO comment on line 499.

Issue I worked on

see https://issues.openmrs.org/browse/TRUNK-6598

Checklist: I completed these to help reviewers :)

  • My IDE is configured to follow the code style
  • I have added tests to cover my changes
  • I ran mvn clean package
  • All new and existing tests passed
  • My pull request is based on latest master

Add unit test for containingAnyFormField in HibernateFormDAO
// Assert at least one form contains this form field
assertTrue(forms.size() > 0);
}
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Are there any edge cases where multiple form fields exist but none match? It might be useful to include such scenarios in the tests.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Good point. You're right—we should cover the scenario with multiple
non-existent fields

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Thank you for the suggestion! I have committed it directly.

Copy link
Copy Markdown

@EDSONZ-WASSWA EDSONZ-WASSWA Mar 31, 2026

Choose a reason for hiding this comment

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

Nice work! @ShrutiSocrates .. I see there is thorough test coverage for the containingAnyFormField functionality as the ticket required....Looks good
Just one thing the comment "//A would-be fix for that" should be removed before merge

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Thank you for the approval and feedback! The "//A would-be fix for that" comment
has been removed.

Copy link
Copy Markdown

@VarshithReddy2006 VarshithReddy2006 left a comment

Choose a reason for hiding this comment

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

Suggested adding additional edge case coverage for test scenarios.

Copy link
Copy Markdown

@NitinKumar1-1 NitinKumar1-1 left a comment

Choose a reason for hiding this comment

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

Looks good to me
Agree with the suggestion about adding an edge case for non-matching form fields.

Copy link
Copy Markdown

@chaiwat123431 chaiwat123431 left a comment

Choose a reason for hiding this comment

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

Good addition. Filling in a TODO with a meaningful test is exactly the kind of contribution that improves long-term maintainability. The test covers the happy path well. Consider also adding an edge case where no form fields match, to verify the method returns an empty result rather than throwing an exception.

Add edge case tests for containingAnyFormField
@ShrutiSocrates
Copy link
Copy Markdown
Author

Thank you for the feedback!

I have added an edge case to verify the method returns an empty result when no form fields match rather
than throwing an exception.

Please review when you get a chance!

…OTest.java


Add edge case for multiple non-existent form fields

Co-authored-by: EDSON <[email protected]>
@ShrutiSocrates
Copy link
Copy Markdown
Author

Suggested adding additional edge case coverage for test scenarios.

Good point! I have added this edge case covering multiple non-existent form fields that return an empty list.

@sonarqubecloud
Copy link
Copy Markdown

// Assert at least one form contains this form field
assertTrue(forms.size() > 0);
}
}
Copy link
Copy Markdown

@EDSONZ-WASSWA EDSONZ-WASSWA Mar 31, 2026

Choose a reason for hiding this comment

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

Nice work! @ShrutiSocrates .. I see there is thorough test coverage for the containingAnyFormField functionality as the ticket required....Looks good
Just one thing the comment "//A would-be fix for that" should be removed before merge

@ShrutiSocrates
Copy link
Copy Markdown
Author

Thank you so much @EDSONZ-WASSWA for the approval and feedback! I will remove the "//A would-be fix for that" comment right away.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants