From 2568a02d5a4e0ad03b9aa400cd74379c5886fef9 Mon Sep 17 00:00:00 2001 From: Marcel Date: Fri, 12 Jun 2026 07:41:05 +0200 Subject: [PATCH] test(geschichte): add documentId, limit and status routing tests to GeschichteControllerTest MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds list_passesDocumentIdFilterToService, list_passesLimitToService and list_passesStatusFilterToService — characterisation tests for existing parameter routing that had no controller-level coverage (refs #794). Co-Authored-By: Claude Sonnet 4.6 --- .../geschichte/GeschichteControllerTest.java | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/backend/src/test/java/org/raddatz/familienarchiv/geschichte/GeschichteControllerTest.java b/backend/src/test/java/org/raddatz/familienarchiv/geschichte/GeschichteControllerTest.java index caf1a515..853c6e86 100644 --- a/backend/src/test/java/org/raddatz/familienarchiv/geschichte/GeschichteControllerTest.java +++ b/backend/src/test/java/org/raddatz/familienarchiv/geschichte/GeschichteControllerTest.java @@ -100,6 +100,43 @@ class GeschichteControllerTest { verify(geschichteService).list(any(), eq(List.of(a, b)), any(), anyInt()); } + @Test + @WithMockUser(authorities = "READ_ALL") + void list_passesDocumentIdFilterToService() throws Exception { + UUID documentId = UUID.randomUUID(); + when(geschichteService.list(any(), any(), eq(documentId), anyInt())) + .thenReturn(List.of()); + + mockMvc.perform(get("/api/geschichten").param("documentId", documentId.toString())) + .andExpect(status().isOk()); + + verify(geschichteService).list(any(), any(), eq(documentId), anyInt()); + } + + @Test + @WithMockUser(authorities = "READ_ALL") + void list_passesLimitToService() throws Exception { + when(geschichteService.list(any(), any(), any(), eq(5))) + .thenReturn(List.of()); + + mockMvc.perform(get("/api/geschichten").param("limit", "5")) + .andExpect(status().isOk()); + + verify(geschichteService).list(any(), any(), any(), eq(5)); + } + + @Test + @WithMockUser(authorities = "READ_ALL") + void list_passesStatusFilterToService() throws Exception { + when(geschichteService.list(eq(GeschichteStatus.PUBLISHED), any(), any(), anyInt())) + .thenReturn(List.of()); + + mockMvc.perform(get("/api/geschichten").param("status", "PUBLISHED")) + .andExpect(status().isOk()); + + verify(geschichteService).list(eq(GeschichteStatus.PUBLISHED), any(), any(), anyInt()); + } + // ─── GET /api/geschichten/{id} ─────────────────────────────────────────── @Test