From 1db0f38f62e633e2a4d1a45567b726110a3aeacd Mon Sep 17 00:00:00 2001 From: Marcel Date: Tue, 28 Apr 2026 20:14:14 +0200 Subject: [PATCH] test(transcription): 400 + VALIDATION_ERROR when mention personId is null Regression guard for the @NotNull on PersonMention.personId paired with @Valid on the DTO field. The wiring was added in the previous commit; this test ensures dropping either annotation in the future causes a loud test failure rather than silently allowing payloads with no personId to reach the service layer (where the listener relies on the UUID being present). Refs #362 Co-Authored-By: Claude Opus 4.7 --- .../TranscriptionBlockControllerTest.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/backend/src/test/java/org/raddatz/familienarchiv/controller/TranscriptionBlockControllerTest.java b/backend/src/test/java/org/raddatz/familienarchiv/controller/TranscriptionBlockControllerTest.java index 8b75dae3..68ccacfb 100644 --- a/backend/src/test/java/org/raddatz/familienarchiv/controller/TranscriptionBlockControllerTest.java +++ b/backend/src/test/java/org/raddatz/familienarchiv/controller/TranscriptionBlockControllerTest.java @@ -199,6 +199,20 @@ class TranscriptionBlockControllerTest { .andExpect(jsonPath("$.code").value("VALIDATION_ERROR")); } + @Test + @WithMockUser(authorities = "WRITE_ALL") + void createBlock_returns400_whenMentionedPersonPersonIdIsNull() throws Exception { + when(userService.findByEmail(any())).thenReturn(mockUser()); + String body = "{\"pageNumber\":1,\"x\":0.1,\"y\":0.2,\"width\":0.3,\"height\":0.4,\"text\":\"x\"," + + "\"mentionedPersons\":[{\"personId\":null,\"displayName\":\"Auguste Raddatz\"}]}"; + + mockMvc.perform(post(URL_BASE) + .contentType(MediaType.APPLICATION_JSON) + .content(body)) + .andExpect(status().isBadRequest()) + .andExpect(jsonPath("$.code").value("VALIDATION_ERROR")); + } + // ─── PUT /api/documents/{id}/transcription-blocks/{blockId} ───────────── @Test