New notification on study creation#244
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughReplaced the Changes
🚥 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. 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. Review rate limit: 0/1 reviews remaining, refill in 60 minutes.Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
src/test/java/org/gridsuite/directory/server/DirectoryTest.java (1)
1289-1340: Missing test coverage forUPDATE_TYPE_STUDY_CREATION_FAILED.The test only exercises the
UPDATE_TYPE_STUDY_CREATEDpath. The failure scenario (UPDATE_TYPE_STUDY_CREATION_FAILED) is not covered. Consider adding a test case that:
- Uses
UPDATE_TYPE_STUDY_CREATION_FAILEDas the update type- Includes an error message in the
HEADER_ERROR- Verifies that
directoryService.studyUpdated()is called with the error messageThis ensures both branches of the new update type handling are validated.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/test/java/org/gridsuite/directory/server/DirectoryTest.java` around lines 1289 - 1340, Add a new test (or extend testStudyUpdateNotification) that sends a message with HEADER_UPDATE_TYPE set to UPDATE_TYPE_STUDY_CREATION_FAILED and a non-empty HEADER_ERROR, then assert the broker outputs and verify directoryService.studyUpdated(...) was invoked with the study UUID and the error message; locate the message send in testStudyUpdateNotification (the MessageBuilder block), duplicate/adjust it to use UPDATE_TYPE_STUDY_CREATION_FAILED and HEADER_ERROR, and add a Mockito.verify call for directoryService.studyUpdated(studyUuid, "<expectedError>") (or equivalent) to confirm the failure branch is exercised.src/main/java/org/gridsuite/directory/server/services/ConsumerService.java (1)
36-36: Duplicate constant definition.
HEADER_UPDATE_TYPEis defined both here inConsumerService.java(line 36) and inNotificationService.java(line 30). Since the class already statically imports fromNotificationService(line 27), consider removing this duplicate and using the imported constant to avoid confusion about which constant is being referenced.♻️ Proposed refactor to remove duplicate constant
public class ConsumerService { private static final Logger LOGGER = LoggerFactory.getLogger(ConsumerService.class); private static final String CATEGORY_BROKER_INPUT = ConsumerService.class.getName() + ".input-broker-messages"; - public static final String HEADER_UPDATE_TYPE = "updateType"; public static final String HEADER_ELEMENT_UUID = "elementUuid";🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/main/java/org/gridsuite/directory/server/services/ConsumerService.java` at line 36, Remove the duplicate constant HEADER_UPDATE_TYPE from ConsumerService and use the statically imported constant from NotificationService instead: delete the field declaration public static final String HEADER_UPDATE_TYPE = "updateType" in ConsumerService and ensure all references in ConsumerService use the imported HEADER_UPDATE_TYPE (from NotificationService) so there is a single source of truth.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/main/java/org/gridsuite/directory/server/services/ConsumerService.java`:
- Around line 77-81: The if condition's operator precedence lets
UPDATE_TYPE_STUDY_CREATED pass even when studyUuidHeader is null, causing
UUID.fromString(studyUuidHeader) in the directoryService.studyUpdated(...) call
to NPE; change the condition to group the two update-type checks together and
then require studyUuidHeader non-null (i.e., ensure
(UPDATE_TYPE_STUDY_CREATED.equals(updateType) ||
UPDATE_TYPE_STUDY_CREATION_FAILED.equals(updateType)) && studyUuidHeader !=
null) so both branches only call UUID.fromString when studyUuidHeader is
present.
---
Nitpick comments:
In `@src/main/java/org/gridsuite/directory/server/services/ConsumerService.java`:
- Line 36: Remove the duplicate constant HEADER_UPDATE_TYPE from ConsumerService
and use the statically imported constant from NotificationService instead:
delete the field declaration public static final String HEADER_UPDATE_TYPE =
"updateType" in ConsumerService and ensure all references in ConsumerService use
the imported HEADER_UPDATE_TYPE (from NotificationService) so there is a single
source of truth.
In `@src/test/java/org/gridsuite/directory/server/DirectoryTest.java`:
- Around line 1289-1340: Add a new test (or extend testStudyUpdateNotification)
that sends a message with HEADER_UPDATE_TYPE set to
UPDATE_TYPE_STUDY_CREATION_FAILED and a non-empty HEADER_ERROR, then assert the
broker outputs and verify directoryService.studyUpdated(...) was invoked with
the study UUID and the error message; locate the message send in
testStudyUpdateNotification (the MessageBuilder block), duplicate/adjust it to
use UPDATE_TYPE_STUDY_CREATION_FAILED and HEADER_ERROR, and add a Mockito.verify
call for directoryService.studyUpdated(studyUuid, "<expectedError>") (or
equivalent) to confirm the failure branch is exercised.
🪄 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: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: f4daf527-5463-4876-99d1-151d9c79b2c2
📒 Files selected for processing (2)
src/main/java/org/gridsuite/directory/server/services/ConsumerService.javasrc/test/java/org/gridsuite/directory/server/DirectoryTest.java
26a33a7 to
dbce77a
Compare
|



PR Summary
See gridsuite/study-server#981