Skip to content

New notification on study creation#244

Merged
antoinebhs merged 6 commits intomainfrom
new-notif-study-creation
Apr 29, 2026
Merged

New notification on study creation#244
antoinebhs merged 6 commits intomainfrom
new-notif-study-creation

Conversation

@antoinebhs
Copy link
Copy Markdown
Contributor

@antoinebhs antoinebhs commented Apr 27, 2026

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 27, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 24051ed8-d6c9-42ef-b534-4b3781a96f5a

📥 Commits

Reviewing files that changed from the base of the PR and between c5a900d and 6fa7b56.

📒 Files selected for processing (2)
  • src/main/java/org/gridsuite/directory/server/services/ConsumerService.java
  • src/test/java/org/gridsuite/directory/server/DirectoryTest.java

📝 Walkthrough

Walkthrough

Replaced the UPDATE_TYPE_STUDIES update-type handling with a single UPDATE_TYPE_STUDY_CREATION_FINISHED constant. consumeStudyUpdate now checks updateType == UPDATE_TYPE_STUDY_CREATION_FINISHED (and studyUuidHeader != null) before calling directoryService.studyUpdated(...). Tests updated to use the new constant and a wildcard static import.

Changes

Cohort / File(s) Summary
Consumer update handling
src/main/java/org/gridsuite/directory/server/services/ConsumerService.java
Removed UPDATE_TYPE_STUDIES; added UPDATE_TYPE_STUDY_CREATION_FINISHED. consumeStudyUpdate now checks UPDATE_TYPE_STUDY_CREATION_FINISHED and studyUuidHeader != null before invoking directoryService.studyUpdated(UUID.fromString(...), error, userId).
Tests — study update notification
src/test/java/org/gridsuite/directory/server/DirectoryTest.java
Test testStudyUpdateNotification changed to send HEADER_UPDATE_TYPE = UPDATE_TYPE_STUDY_CREATION_FINISHED. Switched specific static imports from ConsumerService to a wildcard static import for constants.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: introducing a new notification mechanism specifically for study creation events by replacing the generic studies update handler with a dedicated study creation finished notification.
Description check ✅ Passed The description is minimal but related to the changeset, referencing a companion PR in the study-server repository that provides context for the notification changes.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ 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.

❤️ Share
Review rate limit: 0/1 reviews remaining, refill in 60 minutes.

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (2)
src/test/java/org/gridsuite/directory/server/DirectoryTest.java (1)

1289-1340: Missing test coverage for UPDATE_TYPE_STUDY_CREATION_FAILED.

The test only exercises the UPDATE_TYPE_STUDY_CREATED path. The failure scenario (UPDATE_TYPE_STUDY_CREATION_FAILED) is not covered. Consider adding a test case that:

  1. Uses UPDATE_TYPE_STUDY_CREATION_FAILED as the update type
  2. Includes an error message in the HEADER_ERROR
  3. Verifies that directoryService.studyUpdated() is called with the error message

This 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_TYPE is defined both here in ConsumerService.java (line 36) and in NotificationService.java (line 30). Since the class already statically imports from NotificationService (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

📥 Commits

Reviewing files that changed from the base of the PR and between f0c3668 and 26a33a7.

📒 Files selected for processing (2)
  • src/main/java/org/gridsuite/directory/server/services/ConsumerService.java
  • src/test/java/org/gridsuite/directory/server/DirectoryTest.java

Comment thread src/main/java/org/gridsuite/directory/server/services/ConsumerService.java Outdated
@antoinebhs antoinebhs force-pushed the new-notif-study-creation branch from 26a33a7 to dbce77a Compare April 27, 2026 16:19
@antoinebhs antoinebhs changed the title New notifications on study creation New notification on study creation Apr 28, 2026
@antoinebhs antoinebhs requested a review from EtienneLt April 28, 2026 13:53
Copy link
Copy Markdown
Contributor

@EtienneLt EtienneLt left a comment

Choose a reason for hiding this comment

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

code OK test OK

@sonarqubecloud
Copy link
Copy Markdown

@antoinebhs antoinebhs merged commit 9972b80 into main Apr 29, 2026
5 checks passed
@antoinebhs antoinebhs deleted the new-notif-study-creation branch April 29, 2026 15:31
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