✅ fixed UserService unit test#13997
Conversation
|
Warning Review limit reached
More reviews will be available in 24 minutes and 53 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughTest assertions in ChangesUserFacadeEjbTest assertion updates
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 4❌ Failed checks (2 warnings, 2 inconclusive)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 |
…RMAS-Project into fix/13830-national-user-cannot-be-responsible-user
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
sormas-backend/src/test/java/de/symeda/sormas/backend/user/UserFacadeEjbTest.java (1)
322-327:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winAssert identity of the new 4th result, not just count
Line 322 increases expected size, but Lines 324-327 don’t verify who the newly included user is. This can pass with an unintended extra user. Add an explicit assertion for the expected national-level user UUID/reference.
Proposed test hardening
assertEquals(4, userReferenceDtos.size()); List<String> userReferenceUUIDs = userReferenceDtos.stream().map(u -> u.getUuid()).collect(Collectors.toList()); assertTrue(userReferenceUUIDs.contains(surveilanceOfficerDefault.getUuid())); assertTrue(userReferenceUUIDs.contains(surveilanceSupervisorDefault.getUuid())); assertTrue(userReferenceUUIDs.contains(adminSupervisorDefault.getUuid())); + assertTrue(userReferenceUUIDs.contains(nationalAdmin.getUuid())); assertFalse(userReferenceUUIDs.contains(adminSupervisorOther.getUuid()));🤖 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 `@sormas-backend/src/test/java/de/symeda/sormas/backend/user/UserFacadeEjbTest.java` around lines 322 - 327, The test asserts that userReferenceDtos has size 4 on line 322 and verifies several specific users are included in userReferenceUUIDs, but does not explicitly verify the identity of the new 4th user that was added. Add an assertion (assertTrue) to verify that the expected national-level user's UUID is contained in the userReferenceUUIDs list, ensuring the newly included user is the intended one and not just any arbitrary user.
🤖 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
`@sormas-backend/src/test/java/de/symeda/sormas/backend/user/UserFacadeEjbTest.java`:
- Around line 399-402: The assertion at line 401 in the getUserRefsByDistrict
test only verifies that exactly one user reference is returned using hasSize(1),
but does not verify which user is actually returned. This allows the test to
pass even if the wrong user with the wrong right or wrong jurisdiction is
returned. Add an additional assertion after the hasSize check to verify that the
returned userReferenceDtos contains the expected user by asserting on the user's
ID or other identifying properties, so that the test will fail if the incorrect
user is matched or if the right/jurisdiction filtering is broken.
---
Outside diff comments:
In
`@sormas-backend/src/test/java/de/symeda/sormas/backend/user/UserFacadeEjbTest.java`:
- Around line 322-327: The test asserts that userReferenceDtos has size 4 on
line 322 and verifies several specific users are included in userReferenceUUIDs,
but does not explicitly verify the identity of the new 4th user that was added.
Add an assertion (assertTrue) to verify that the expected national-level user's
UUID is contained in the userReferenceUUIDs list, ensuring the newly included
user is the intended one and not just any arbitrary user.
🪄 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: defaults
Review profile: CHILL
Plan: Pro
Run ID: 3b28b20e-2faf-4aaf-831f-6fdb0f2106f7
📒 Files selected for processing (1)
sormas-backend/src/test/java/de/symeda/sormas/backend/user/UserFacadeEjbTest.java
| userReferenceDtos = getUserFacade().getUserRefsByDistrict(rdcf.district, Disease.CORONAVIRUS, UserRight.EXTERNAL_MESSAGE_ACCESS); | ||
|
|
||
| assertFalse(userReferenceDtos.isEmpty()); | ||
| assertThat(userReferenceDtos, hasSize(1)); | ||
|
|
There was a problem hiding this comment.
Strengthen EXTERNAL_MESSAGE_ACCESS assertion with expected user
The new non-empty expectation at Line 401 only checks size. Please also assert which user is returned so this test fails on wrong-right/wrong-jurisdiction matches.
Proposed assertion update
userReferenceDtos = getUserFacade().getUserRefsByDistrict(rdcf.district, Disease.CORONAVIRUS, UserRight.EXTERNAL_MESSAGE_ACCESS);
assertThat(userReferenceDtos, hasSize(1));
+ assertThat(userReferenceDtos, hasItem(equalTo(nationalAdmin.toReference())));📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| userReferenceDtos = getUserFacade().getUserRefsByDistrict(rdcf.district, Disease.CORONAVIRUS, UserRight.EXTERNAL_MESSAGE_ACCESS); | |
| assertFalse(userReferenceDtos.isEmpty()); | |
| assertThat(userReferenceDtos, hasSize(1)); | |
| userReferenceDtos = getUserFacade().getUserRefsByDistrict(rdcf.district, Disease.CORONAVIRUS, UserRight.EXTERNAL_MESSAGE_ACCESS); | |
| assertThat(userReferenceDtos, hasSize(1)); | |
| assertThat(userReferenceDtos, hasItem(equalTo(nationalAdmin.toReference()))); |
🤖 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
`@sormas-backend/src/test/java/de/symeda/sormas/backend/user/UserFacadeEjbTest.java`
around lines 399 - 402, The assertion at line 401 in the getUserRefsByDistrict
test only verifies that exactly one user reference is returned using hasSize(1),
but does not verify which user is actually returned. This allows the test to
pass even if the wrong user with the wrong right or wrong jurisdiction is
returned. Add an additional assertion after the hasSize check to verify that the
returned userReferenceDtos contains the expected user by asserting on the user's
ID or other identifying properties, so that the test will fail if the incorrect
user is matched or if the right/jurisdiction filtering is broken.
|
already fixed |
Fixes #13830
Summary by CodeRabbit