feat(jans-fido2): add Fido2MetricsAggregation unit tests#14219
feat(jans-fido2): add Fido2MetricsAggregation unit tests#14219imran-ishaq wants to merge 1 commit into
Conversation
Signed-off-by: imran <imranishaq7071@gmail.com>
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
|
Error: Hi @imran-ishaq, You did not reference an open issue in your PR. I attempted to create an issue for you. |
|



Prepare
Description
Adds JUnit 5 test coverage for Fido2MetricsAggregation — the ORM entity that stores hourly/daily/weekly/monthly summary rows for the FIDO2 metrics feature. Most of the class is plain getters/setters, but the small computed surface (4-arg constructor id composition, getPeriod() derivation, null-safe Number coercion, Integer→Long map widening, incrementMetric accumulator, and the equals/hashCode contract) was completely untested. The new test class locks each of those behaviors. Test-only change; no production code or pom.xml changes. Step 7 of the FIDO2 metrics test rollout.
Target issue
Fido2MetricsAggregation (jans-fido2/model/src/main/java/io/jans/fido2/model/metric/Fido2MetricsAggregation.java) carries six small bits of computed behavior that downstream aggregation/analytics code silently depends on, and none of them is tested today:
Silent failure modes — wrong aggregation totals, dropped Integer→Long conversions, NPE against partially-loaded ORM entries, or a refactor of getPeriod() that swaps indexOf("") for split("") or lastIndexOf("_") — would corrupt every downstream summary without any compile-time signal.
This PR is step 7 of the FIDO2 metrics test rollout.
closes #14220
Implementation Details
Adds a single new JUnit 5 test class — jans-fido2/model/src/test/java/io/jans/fido2/model/metric/Fido2MetricsAggregationTest.java — with 12 grouped @test methods, one per spec'd behavior group:
Design choices worth flagging:
Scope:
Local verification: mvn -pl model -am test from jans-fido2/ runs the new class alongside the existing two (Fido2MetricsConstantsTest and Fido2UserMetricsRateCalculationsTest). Test class runtime is well under 1 second — no I/O, no Thread.sleep, no async.
Test and Document the changes
Static code analysis has been run locally and issues have been fixed
Relevant unit and integration tests have been added/updated
Relevant documentation has been updated if any (i.e. user guides, installation and configuration guides, technical design docs etc)
I confirm that there is no impact on the docs due to the code changes in this PR.
Closes #14220,