From b80b105b5489b8a4c0e505ec631e7b5a04db55dd Mon Sep 17 00:00:00 2001 From: Sean Starkey Date: Tue, 2 Jun 2026 15:42:44 -0600 Subject: [PATCH] Revert "Cleanup" This reverts commit a9bb7423cab408223ced6f63042a58dd0e5b6047. --- .../notesvault/dto/CreateNoteRequest.java | 2 ++ .../notesvault/dto/NoteResponse.java | 2 ++ .../notesvault/dto/ShareNoteRequest.java | 2 ++ .../repository/NoteShareRepository.java | 18 ++++++++++++++++++ .../controller/NoteListingControllerTest.java | 6 ++++++ 5 files changed, 30 insertions(+) diff --git a/src/main/java/com/seanstarkey/notesvault/dto/CreateNoteRequest.java b/src/main/java/com/seanstarkey/notesvault/dto/CreateNoteRequest.java index 8a970a0..6c47384 100644 --- a/src/main/java/com/seanstarkey/notesvault/dto/CreateNoteRequest.java +++ b/src/main/java/com/seanstarkey/notesvault/dto/CreateNoteRequest.java @@ -9,6 +9,8 @@ import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.Size; /** + * Carries note content supplied by an authenticated owner. + * * @param title optional note title, limited to a concise display length * @param content required note body */ diff --git a/src/main/java/com/seanstarkey/notesvault/dto/NoteResponse.java b/src/main/java/com/seanstarkey/notesvault/dto/NoteResponse.java index 3eee608..7a29cca 100644 --- a/src/main/java/com/seanstarkey/notesvault/dto/NoteResponse.java +++ b/src/main/java/com/seanstarkey/notesvault/dto/NoteResponse.java @@ -9,6 +9,8 @@ import java.time.Instant; import java.util.UUID; /** + * Represents a note visible to the authenticated caller. + * * @param id stable note identifier * @param title note title * @param content note body diff --git a/src/main/java/com/seanstarkey/notesvault/dto/ShareNoteRequest.java b/src/main/java/com/seanstarkey/notesvault/dto/ShareNoteRequest.java index d051add..1a06747 100644 --- a/src/main/java/com/seanstarkey/notesvault/dto/ShareNoteRequest.java +++ b/src/main/java/com/seanstarkey/notesvault/dto/ShareNoteRequest.java @@ -9,6 +9,8 @@ import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.Size; /** + * Carries the target username for a note share operation. + * * @param username recipient username to grant read-only access */ public record ShareNoteRequest( diff --git a/src/main/java/com/seanstarkey/notesvault/repository/NoteShareRepository.java b/src/main/java/com/seanstarkey/notesvault/repository/NoteShareRepository.java index 2c518a0..12e15da 100644 --- a/src/main/java/com/seanstarkey/notesvault/repository/NoteShareRepository.java +++ b/src/main/java/com/seanstarkey/notesvault/repository/NoteShareRepository.java @@ -1,5 +1,9 @@ /** * NoteShareRepository.java + * + * Spring Data repository for note share grants. Provides lookup helpers for + * duplicate-share checks, read-access checks, and data-layer tests around cascade + * deletion behavior. */ package com.seanstarkey.notesvault.repository; @@ -12,9 +16,15 @@ import java.util.List; import java.util.Optional; import java.util.UUID; +/** + * Repository for NoteShare entities. Encapsulates queries around read-only share + * grants between notes and recipient users. + */ public interface NoteShareRepository extends JpaRepository { /** + * Finds an existing share grant for a note and recipient user. + * * @param note the shared note * @param sharedWith the user who may have read-only access * @return an Optional containing the share grant, or empty when no grant exists @@ -22,6 +32,8 @@ public interface NoteShareRepository extends JpaRepository { Optional findByNoteAndSharedWith(Note note, User sharedWith); /** + * Checks whether a note is already shared with a recipient. + * * @param note the note whose share grants should be searched * @param sharedWith the recipient user * @return true when a share grant exists; false otherwise @@ -29,18 +41,24 @@ public interface NoteShareRepository extends JpaRepository { boolean existsByNoteAndSharedWith(Note note, User sharedWith); /** + * Lists all share grants for a note. + * * @param note the note whose share grants should be returned * @return all share grants associated with the note */ List findAllByNote(Note note); /** + * Lists all share grants received by a user. + * * @param sharedWith the user whose received shares should be returned * @return all share grants where the supplied user is the recipient */ List findAllBySharedWith(User sharedWith); /** + * Deletes all share grants for a note. + * * @param note the note whose share grants should be removed */ void deleteAllByNote(Note note); diff --git a/src/test/java/com/seanstarkey/notesvault/controller/NoteListingControllerTest.java b/src/test/java/com/seanstarkey/notesvault/controller/NoteListingControllerTest.java index 791c4be..f709a6e 100644 --- a/src/test/java/com/seanstarkey/notesvault/controller/NoteListingControllerTest.java +++ b/src/test/java/com/seanstarkey/notesvault/controller/NoteListingControllerTest.java @@ -1,5 +1,7 @@ /** * NoteListingControllerTest.java + * + * API-level tests for authenticated note listing behavior. */ package com.seanstarkey.notesvault.controller; @@ -16,6 +18,10 @@ import static org.springframework.test.web.servlet.request.MockMvcRequestBuilder import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; +/** + * Verifies GET /notes through the real Spring MVC, Security, JPA, validation, + * and Flyway-backed H2 application stack. + */ @SpringBootTest @AutoConfigureMockMvc @Transactional