Skip to content

Add unit tests for OpenmrsUtil.isStringInArray#5754

Open
varshithreddybokka4444-netizen wants to merge 4 commits into
openmrs:masterfrom
varshithreddybokka4444-netizen:test-isStringInArray
Open

Add unit tests for OpenmrsUtil.isStringInArray#5754
varshithreddybokka4444-netizen wants to merge 4 commits into
openmrs:masterfrom
varshithreddybokka4444-netizen:test-isStringInArray

Conversation

@varshithreddybokka4444-netizen

Copy link
Copy Markdown

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
Copy Markdown
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
Copy Markdown
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);

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.

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

sonarqubecloud Bot commented Mar 4, 2026

Copy link
Copy Markdown

@Test
public void nullSafeEqualsIgnoreCase_shouldBeCaseInsensitive() {
assertTrue(OpenmrsUtil.nullSafeEqualsIgnoreCase("equal", "Equal"));
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Add a blank line before a new test starts.

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.

i have now added the blank line, thank you for correcion.

public void isStringInArray_shouldHandleNullValuesInsideArray() {
String[] arr = {"a", null, "b"};
assertTrue(OpenmrsUtil.isStringInArray("a", arr));
assertFalse(OpenmrsUtil.isStringInArray("c", arr));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do we need this here? Feels like this test is doing two things at once.

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 correcting, i removed the line, please check now. Please sugest any more changes if needed.

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 59.26%. Comparing base (dcf1695) to head (5d65991).

Additional details and impacted files
@@            Coverage Diff            @@
##             master    #5754   +/-   ##
=========================================
  Coverage     59.26%   59.26%           
- Complexity     9251     9253    +2     
=========================================
  Files           686      686           
  Lines         37219    37219           
  Branches       5445     5445           
=========================================
  Hits          22056    22056           
- Misses        13201    13203    +2     
+ Partials       1962     1960    -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@wikumChamith

Copy link
Copy Markdown
Member

@varshithreddybokka4444-netizen can you resolve the merge conflicts?

@varshithreddybokka4444-netizen

Copy link
Copy Markdown
Author

will resolve the merge conflicts as fast as possible

@sonarqubecloud

Copy link
Copy Markdown

@varshithreddybokka4444-netizen

Copy link
Copy Markdown
Author

@wikumChamith i resolved conflicts, please check and suggest the changes if any

@ibacher

ibacher commented Jul 17, 2026

Copy link
Copy Markdown
Member

@varshithreddybokka4444-netizen It doesn't look like a couple of the updates you made landed. Can you ensure you've properly pushed to your branch?

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.

6 participants