Skip to content

Add unit tests for OpenmrsUtil.isStringInArray#5754

Open
varshithreddybokka4444-netizen wants to merge 2 commits intoopenmrs:masterfrom
varshithreddybokka4444-netizen:test-isStringInArray
Open

Add unit tests for OpenmrsUtil.isStringInArray#5754
varshithreddybokka4444-netizen wants to merge 2 commits intoopenmrs:masterfrom
varshithreddybokka4444-netizen:test-isStringInArray

Conversation

@varshithreddybokka4444-netizen

Description of what I changed

Added unit tests for OpenmrsUtil.isStringInArray to cover standard and edge cases, including:

  • when the string exists in the array
  • when the string does not exist
  • null string input
  • null array input
  • arrays containing null values

These tests document and lock the expected behavior of the utility method.

Issue I worked on

N/A – test-only internal improvement (no JIRA issue required)

Checklist: I completed these to help reviewers :)

  • My IDE is configured to follow the code style of this project.

  • I have added tests to cover my changes.

  • I ran mvn clean package right before creating this pull request.

    Note: The modified tests were run successfully via IntelliJ. Full test suite will be executed by CI.

  • All new and existing tests passed.

  • My pull request is based on the latest changes of the master branch.

@varshithreddybokka4444-netizen
Copy link
Author

Hi, this is my first contribution to OpenMRS.
Please let me know if any changes are required.
Thanks!

* @see OpenmrsUtil#isStringInArray(String, String[])
*/
@Test
public void isStringInArray_shouldReturnFalseIfStringIsNull() {
Copy link
Member

Choose a reason for hiding this comment

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

Two additional cases to consider:

String[] arr = {"a", null, "b"};
OpenmrsUtil.isStringInArray(null, arr);
OpenmrsUtil.isStringInArray(null, null);

Choose a reason for hiding this comment

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

Thanks for the suggestion! I’ve added tests to cover both of these cases.
Please let me know if any further adjustments are needed.

@sonarqubecloud
Copy link

sonarqubecloud bot commented Feb 6, 2026

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.

3 participants

Comments