test(geschichte): GeschichteControllerTest — list_passesStatusDraftFilterToService #809

Open
opened 2026-06-12 07:37:27 +02:00 by marcel · 0 comments
Owner

Context

Identified during review of #794 (annotate GET /api/geschichten OpenAPI params). The three parameter-routing tests added in #794 cover documentId, limit, and PUBLISHED status, but the DRAFT routing path at the controller layer has no pin.

What needs to be done

Add a @WebMvcTest test to GeschichteControllerTest mirroring the pattern of list_passesStatusFilterToService added in #794, using DRAFT instead of PUBLISHED:

@Test
@WithMockUser(authorities = "READ_ALL")
void list_passesStatusDraftFilterToService() throws Exception {
    when(geschichteService.list(eq(GeschichteStatus.DRAFT), any(), any(), anyInt()))
            .thenReturn(List.of());

    mockMvc.perform(get("/api/geschichten").param("status", "DRAFT"))
            .andExpect(status().isOk());

    verify(geschichteService).list(eq(GeschichteStatus.DRAFT), any(), any(), anyInt());
}

Note: the controller is neutral — it passes whatever status the caller sends straight through to the service. The access-control override lives in the service layer (covered by #795). This test pins only the controller routing behaviour.

Acceptance Criteria

  • GeschichteControllerTest contains list_passesStatusDraftFilterToService
  • Test uses @WithMockUser(authorities = "READ_ALL") (no BLOG_WRITE needed for the list endpoint)
  • Test uses eq(GeschichteStatus.DRAFT) to pin the DRAFT path, any() / anyInt() for the rest

Why this matters

Pins the DRAFT routing path at the controller layer. Without this, the DRAFT branch of the status parameter has no controller-level coverage — any accidental param rename or mapping change would go undetected.

## Context Identified during review of #794 (annotate GET /api/geschichten OpenAPI params). The three parameter-routing tests added in #794 cover `documentId`, `limit`, and `PUBLISHED` status, but the DRAFT routing path at the controller layer has no pin. ## What needs to be done Add a `@WebMvcTest` test to `GeschichteControllerTest` mirroring the pattern of `list_passesStatusFilterToService` added in #794, using `DRAFT` instead of `PUBLISHED`: ```java @Test @WithMockUser(authorities = "READ_ALL") void list_passesStatusDraftFilterToService() throws Exception { when(geschichteService.list(eq(GeschichteStatus.DRAFT), any(), any(), anyInt())) .thenReturn(List.of()); mockMvc.perform(get("/api/geschichten").param("status", "DRAFT")) .andExpect(status().isOk()); verify(geschichteService).list(eq(GeschichteStatus.DRAFT), any(), any(), anyInt()); } ``` Note: the controller is neutral — it passes whatever `status` the caller sends straight through to the service. The access-control override lives in the service layer (covered by #795). This test pins only the controller routing behaviour. ## Acceptance Criteria - [ ] `GeschichteControllerTest` contains `list_passesStatusDraftFilterToService` - [ ] Test uses `@WithMockUser(authorities = "READ_ALL")` (no `BLOG_WRITE` needed for the list endpoint) - [ ] Test uses `eq(GeschichteStatus.DRAFT)` to pin the DRAFT path, `any()` / `anyInt()` for the rest ## Why this matters Pins the DRAFT routing path at the controller layer. Without this, the DRAFT branch of the `status` parameter has no controller-level coverage — any accidental param rename or mapping change would go undetected.
marcel added the P3-latertest labels 2026-06-12 07:37:34 +02:00
Sign in to join this conversation.
No Label P3-later test
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: marcel/familienarchiv#809