Skip to content

Conversation

@Jagdish-Singh-Bisht
Copy link

This PR adds unit tests for the method OpenmrsUtil.getFileAsBytes(File file).

The test suite covers the following scenarios:

  1. Valid file → method returns correct byte array

  2. Empty file → method returns zero-length array

  3. Null input → method returns null (without throwing exception)

  4. Non-existent file → method handles exception internally and returns null

The tests help ensure correct behavior of file reading operations and improve code coverage for OpenmrsUtil.

Issue Link

https://issues.openmrs.org/browse/TRUNK-6470

What was changed

  • Added new JUnit test methods inside OpenmrsUtilTest.java

  • Covered both positive and negative test scenarios

  • Verified behavior using FileUtils and StandardCharsets

Testing Instructions

To run only these tests:

mvn -q -pl :openmrs-api -Dtest=OpenmrsUtilTest test

Checklist

  • My IDE is using Java 21

  • mvn clean install completes successfully

  • Tests pass on local environment

  • PR title follows OpenMRS naming conventions

Additional Notes

This PR does not modify production code.
It only improves test coverage for core utilities.

@Jagdish-Singh-Bisht
Copy link
Author

Hello, mentors

This PR adds unit tests for OpenmrsUtil.getFileAsBytes() as part of TRUNK-6470.
All tests pass locally with Java 21.
Kindly review the changes and approve the CI workflows.

Thank you!

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.

1 participant