Deepen calendar time-window handling#43
Conversation
Pan14ek
left a comment
There was a problem hiding this comment.
Code Review Summary
Good refactor overall. The CalendarTimeWindow value object centralises validation cleanly, the EventConflictAnalyzer extraction removes duplication, the mutation-before-validation bug in update() is fixed, and the spoofable requesterId is now locked to the X-User-Id header.
Two things to address before merge:
- Missing regression test for a partial update where one timestamp is
nullin the DTO but the resolved pair is invalid (see inline comment onEventServiceImpl). BadRequestExceptionthrown from persisted entity data inEventConflictAnalyzer(see inline comment) — maps a data-integrity failure to HTTP 400.
One post-merge candidate: the now-redundant requesterId query param on the conflict endpoints (see inline comment on the controller).
c4e54c2 to
38f0185
Compare
|
Pan14ek
left a comment
There was a problem hiding this comment.
All review comments addressed — LGTM.
What changed since the first review:
EventConflictAnalyzer.windowOf()now throwsIllegalStateExceptionfor stored entities with invalid timestamps, correctly separating data-integrity failures from client errors.- Windows are now pre-computed via
.stream().map(this::windowOf).toList()before the O(n²) loop — a bonus improvement: each entity's window is built exactly once instead of potentially multiple times acrossaddConflictcalls. CalendarTimeWindow.overlapWith()has the invariant comment explaining why the direct constructor call is safe.update_throwsBadRequest_whenNewStartAtExceedsExistingEndAtcovers the missing partial-update regression path (newstartAtbeyond existingendAtwith anullDTOendAt).EventConflictAnalyzerTestadds twoIllegalStateExceptiontests for entities with invalid stored windows.
The redundant requesterId query param remains as a post-merge candidate — no objection.



Purpose
Deepen calendar event scheduling internals so create, update, list, conflict, and user-conflict flows use one validated time-window path and keep overlap analysis behind the event scheduling module interface.
Type
Changes
CalendarTimeWindowfor validated half-open event windows.EventConflictAnalyzerfor pairwise overlap detection and conflict DTO mapping.EventServiceImplto reuse the shared time-window path.X-User-Idto prevent spoofingrequesterId.Files changed
src/main/java/io/backend/lined/event/service/CalendarTimeWindow.javasrc/main/java/io/backend/lined/event/service/EventConflictAnalyzer.javasrc/main/java/io/backend/lined/event/service/EventServiceImpl.javasrc/main/java/io/backend/lined/event/api/EventController.javaX-User-Id.src/test/java/io/backend/lined/event/**Expected result
Checklist