Skip to content

Add unit test for null and empty boundary checks in APIUtil#13867

Open
SahanAdithya wants to merge 1 commit into
wso2:masterfrom
SahanAdithya:patch-1
Open

Add unit test for null and empty boundary checks in APIUtil#13867
SahanAdithya wants to merge 1 commit into
wso2:masterfrom
SahanAdithya:patch-1

Conversation

@SahanAdithya

Copy link
Copy Markdown

Purpose

This PR introduces a missing unit test case to APIUtilTest.java to validate boundary edge cases for the isSupportedFileType method.

Approach

Added testIsSupportedFileTypeWithNullAndEmpty() to verify that passing null or an empty string "" as arguments safely evaluates to false instead of triggering unexpected unhandled behavior, matching the surrounding test infrastructure styles.

@coderabbitai

coderabbitai Bot commented Jun 10, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 6f3efb66-30e7-430c-9ca5-7a010462c95f

📥 Commits

Reviewing files that changed from the base of the PR and between 72b16bb and b1d338c.

📒 Files selected for processing (1)
  • components/apimgt/org.wso2.carbon.apimgt.impl/src/test/java/org/wso2/carbon/apimgt/impl/utils/APIUtilTest.java

📝 Walkthrough

Walkthrough

A single JUnit test method is added to APIUtilTest.java to validate that APIUtil.isSupportedFileType() returns false when given null or empty string filenames. The test mocks the required ServiceReferenceHolder and configuration services to isolate the validation logic.

Changes

File Type Validation Test

Layer / File(s) Summary
Null and empty filename validation test
components/apimgt/org.wso2.carbon.apimgt.impl/src/test/java/org/wso2/carbon/apimgt/impl/utils/APIUtilTest.java
New test method with mocked service dependencies asserts that isSupportedFileType(null) and isSupportedFileType("") both return false, covering null/empty edge cases.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and concisely describes the main change: adding a unit test for boundary checks (null and empty values) in APIUtil.
Description check ✅ Passed The description is directly related to the changeset, explaining the purpose and approach of adding the new test for null and empty boundary cases in isSupportedFileType.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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