Implement simple orchestrated email notification pattern - #2
Conversation
|
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f303c3a25c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| assertEquals("hold-list-created", renderer.templatePath); | ||
| assertEquals("HL-123", renderer.model.get("holdListId")); | ||
| assertEquals(1, publisher.published.size()); | ||
| assertEquals("Hold list created", publisher.published.getFirst().subject()); |
There was a problem hiding this comment.
Avoid Java 21-only List#getFirst in Java 17 test code
This assertion uses List#getFirst(), which is only available on Java 21+; the project explicitly targets Java 17 in pom.xml, so test compilation will fail in the configured runtime once dependencies resolve. Please switch to a Java 17-compatible access pattern (for example get(0)) so the test suite can compile and run.
Useful? React with 👍 / 👎.
| if (!candidate.payloadType().isInstance(payload)) { | ||
| throw new IllegalArgumentException( | ||
| "Payload type mismatch for " + type + ". Expected " | ||
| + candidate.payloadType().getSimpleName() + " but got " + payload.getClass().getSimpleName() |
There was a problem hiding this comment.
Guard null payload before building mismatch error message
When notify is called with a null payload, isInstance(payload) returns false and this branch evaluates payload.getClass(), which throws NullPointerException instead of the intended IllegalArgumentException. That turns a controlled validation failure into an unexpected runtime error for callers that may pass nulls.
Useful? React with 👍 / 👎.
Motivation
Description
NotificationPropertiesand aNotificationCatalogwrapper to loadnotifications.email.<TYPE>entries fromapplication.yml.EmailNotificationOrchestratorwhich looks up config, resolves aNotificationModelBuilderregistry, builds the template model, uses aTemplateRendererto render HTML, constructsEmailPublicationRequest, and forwards it to anEmailPublicationPublisherinterface.NotificationModelBuilder<T>strategy interface and two concrete builders (HoldListCreatedModelBuilder,HoldListRemovedModelBuilder) plus example payload records to show how to extend the system.TemplateRenderer+ThymeleafTemplateRenderer,EmailPublicationPublisher+ placeholderLoggingEmailPublicationPublisher, example Thymeleaf templates, and example domain usage inHoldListDomainService.Testing
NotificationCatalogTest(config lookup and missing-config behavior) andEmailNotificationOrchestratorTest(render+publish happy path, disabled behavior, and payload-type mismatch guard).mvn test, but execution failed due to environment/network dependency resolution (Maven Central returned HTTP 403 while resolving the Spring Boot parent POM), so tests could not be executed in this environment.Codex Task