SWATCH-3246: fix subscription configuration properties and add subscription sync component tests#6243
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (5)
✅ Files skipped from review due to trivial changes (2)
🚧 Files skipped from review as they are similar to previous changes (3)
📝 WalkthroughWalkthroughThis PR extends the swatch-contracts test suite with comprehensive coverage for subscription synchronization and capacity reporting. It introduces a capacity-query API overload supporting time-range parameters, Wiremock stubs for mocking upstream search responses, and six new contract tests that validate reconciliation behavior and daily capacity calculations across various upstream state scenarios. ChangesSubscription Sync Testing
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 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 |
|
⛏️ Workflow Run 🧪 JUnit
Details
|
||||||||||||||
7696725 to
177dac1
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
swatch-contracts/ct/java/tests/SubscriptionsSyncComponentTest.java (1)
159-159: 💤 Low valueConsider referencing the configuration value or adding a clarifying comment.
The hardcoded
61assumesSUBSCRIPTION_IGNORE_STARTING_LATER_THANis configured to 60 days. If that configuration changes, this test boundary won't automatically adjust.💡 Optional improvement
Add a comment to explain the magic number:
Subscription subscription = givenExistingSubscription(ACTIVE_SUBSCRIPTION_START, REPORT_END); - OffsetDateTime farFutureStart = clock.now().plusDays(61); + // 61 days exceeds SUBSCRIPTION_IGNORE_STARTING_LATER_THAN (60d) threshold + OffsetDateTime farFutureStart = clock.now().plusDays(61); Subscription upstreamFarFutureStart =🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@swatch-contracts/ct/java/tests/SubscriptionsSyncComponentTest.java` at line 159, Test uses a magic number (61) for the future offset which assumes SUBSCRIPTION_IGNORE_STARTING_LATER_THAN is 60 days; update the test so farFutureStart is computed from the authoritative configuration (referencing the SUBSCRIPTION_IGNORE_STARTING_LATER_THAN constant or config accessor) instead of hardcoding 61, or if that isn't feasible add a clarifying comment next to the farFutureStart assignment noting it is intentionally one day past SUBSCRIPTION_IGNORE_STARTING_LATER_THAN to test the boundary, referencing clock.now() and SUBSCRIPTION_IGNORE_STARTING_LATER_THAN in the comment.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@swatch-contracts/TEST_PLAN.md`:
- Around line 907-909: Update the test plan to use the correct HTTP method for
the subscriptions sync endpoint: change the described request from PUT to POST
for /api/swatch-contracts/internal/rpc/subscriptions/sync; reference the OpenAPI
operation (post in openapi.yaml) and the implementation symbol
ContractsSwatchService.syncAllSubscriptions() which calls
.post(SYNC_ALL_SUBSCRIPTIONS_ENDPOINT) to ensure the documentation matches the
code.
---
Nitpick comments:
In `@swatch-contracts/ct/java/tests/SubscriptionsSyncComponentTest.java`:
- Line 159: Test uses a magic number (61) for the future offset which assumes
SUBSCRIPTION_IGNORE_STARTING_LATER_THAN is 60 days; update the test so
farFutureStart is computed from the authoritative configuration (referencing the
SUBSCRIPTION_IGNORE_STARTING_LATER_THAN constant or config accessor) instead of
hardcoding 61, or if that isn't feasible add a clarifying comment next to the
farFutureStart assignment noting it is intentionally one day past
SUBSCRIPTION_IGNORE_STARTING_LATER_THAN to test the boundary, referencing
clock.now() and SUBSCRIPTION_IGNORE_STARTING_LATER_THAN in the comment.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: ff863466-ca68-43bf-8d65-029335c8ccce
📒 Files selected for processing (8)
swatch-contracts/TEST_PLAN.mdswatch-contracts/ct/java/api/ContractsSwatchService.javaswatch-contracts/ct/java/api/SearchApiStubs.javaswatch-contracts/ct/java/domain/Offering.javaswatch-contracts/ct/java/domain/Product.javaswatch-contracts/ct/java/domain/Subscription.javaswatch-contracts/ct/java/tests/SubscriptionsSyncComponentTest.javaswatch-contracts/deploy/clowdapp.yaml
✅ Files skipped from review due to trivial changes (1)
- swatch-contracts/deploy/clowdapp.yaml
🚧 Files skipped from review as they are similar to previous changes (4)
- swatch-contracts/ct/java/domain/Offering.java
- swatch-contracts/ct/java/domain/Product.java
- swatch-contracts/ct/java/domain/Subscription.java
- swatch-contracts/ct/java/api/SearchApiStubs.java
177dac1 to
42b34ae
Compare
Mantzounis
left a comment
There was a problem hiding this comment.
question: I noticed the additions in domain are not called by any tests, what is the reason for adding them
I had thought to keep those methods because it was very useful during the investigation, but I'm fine removing them, we can always add it back when it's really used. |
42b34ae to
26a0e9b
Compare
|
@Sgitario I'm fine with keeping them there if they are useful for debugging but we should document the decision in a comment to remember its intentional |
no problem, just removed it. we can always add it back, it's not super complicated. |
Mantzounis
left a comment
There was a problem hiding this comment.
thanks for the updates! lgtm.
|
IQE Tests: PASSED --
|
Jira issue: SWATCH-3246
## Changes
The problem is that in clowdapp.yaml, we use SUBSCRIPTION_IGNORE_EXPIRED_OLDER_THAN=2M and SUBSCRIPTION_IGNORE_STARTING_LATER_THAN=2M.
In Spring, these properties standed for 2 months because it uses a custom duration parser, but in Quarkus, 2M stands for 2 minutes.
The fix is to represent the duration in days: 60d.
Testing
Added four scenarios to extend our coverage for the subscription sync scenario:
Summary by CodeRabbit
Release Notes
New Features
Tests