Skip to content

[ES-2798] added testcase to increase the sonarqube coverage#1621

Open
KashiwalHarsh wants to merge 2 commits intomosip:developfrom
Infosys:ES-2798
Open

[ES-2798] added testcase to increase the sonarqube coverage#1621
KashiwalHarsh wants to merge 2 commits intomosip:developfrom
Infosys:ES-2798

Conversation

@KashiwalHarsh
Copy link

@KashiwalHarsh KashiwalHarsh commented Jan 29, 2026

Summary by CodeRabbit

  • Tests

    • Expanded unit test coverage across services for enum behavior, request validation, authorization/config handling, and token/authorization logic.
  • Chores

    • Cleaned up unused imports and minor test formatting.
  • Refactor

    • Simplified exception classes and message accessors, adjusting constructors and access patterns.

@coderabbitai
Copy link

coderabbitai bot commented Jan 29, 2026

Walkthrough

Adds new unit tests (ActionTest, expanded AuthorizationServiceTest, and others), removes several unused imports, and changes exception classes: InvalidRequestException now has a no-arg constructor with fixed error code and DpopNonceMissingException removes an overridden getMessage() in favor of a Lombok-generated getter.

Changes

Cohort / File(s) Summary
New enum tests
esignet-integration-api/src/test/java/io/mosip/esignet/api/util/ActionTest.java
Adds Action enum tests: values(), valueOf(), getModule() non-null checks, module-specific mappings, and enum name assertions.
Expanded service tests
oidc-service-impl/src/test/java/io/mosip/esignet/services/AuthorizationServiceTest.java
Adds extensive tests for ClientDetail.getAdditionalConfig covering many types, defaults, and edge cases.
Minor test edits / imports
esignet-service/src/test/java/io/mosip/esignet/advice/DpopValidationFilterTest.java, esignet-service/src/test/java/io/mosip/esignet/controllers/ClientMgmtV2ControllerParameterizedTest.java, oidc-service-impl/src/test/java/io/mosip/esignet/services/OAuthServiceTest.java, oidc-service-impl/src/test/java/io/mosip/esignet/services/TokenServiceTest.java
Adds/imports for assertions/JSON factories in tests and removes unused imports; minor formatting changes.
Exception behavior & API changes
esignet-core/src/main/java/io/mosip/esignet/core/exception/InvalidRequestException.java, esignet-core/src/main/java/io/mosip/esignet/core/exception/DpopNonceMissingException.java
InvalidRequestException constructor changed from (String errorCode) to no-arg and removed getErrorCode(); DpopNonceMissingException removed explicit getMessage() and added Lombok @Getter on message field.
Runtime code cleanup & behavior tweak
esignet-service/src/main/java/io/mosip/esignet/advice/DpopValidationFilter.java
Removed unused import; when multiple Authorization headers on USERINFO endpoint, throws new InvalidRequestException() (no-arg) instead of passing error code.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~30 minutes

Poem

🐰 I hopped through enums, one by one,

Checked modules, names, and value run.
Exceptions trimmed and tests all sown,
Coverage sprouted from seeds we've thrown.
A tiny rabbit cheers: code well-grown 🥕✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the primary objective of the pull request, which is to add test cases to increase SonarQube code coverage.

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

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

@KashiwalHarsh KashiwalHarsh changed the title added testcase to increase the sonarqube coverage [ES-2798] added testcase to increase the sonarqube coverage Jan 30, 2026
}

@Test
public void testInvalidRequestException_constructorAndGetErrorCode() {
Copy link
Contributor

Choose a reason for hiding this comment

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

This testcase adds no value and has no relation to DpopValidation.

}

@Test
void clientDetailCreateRequestV3_constructorWithNullAdditionalConfig_shouldSetNullAdditionalConfig() {
Copy link
Contributor

Choose a reason for hiding this comment

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

This testcase also adds no value. Check if we are using its constructor anywhere, if not then just remove the constructor.

Signed-off-by: Harsh Kashiwal <[email protected]>
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.

2 participants