test(transcription): 400 + VALIDATION_ERROR when mention displayName exceeds 200 chars
Wires @Valid on the @RequestBody parameter of TranscriptionBlockController's createBlock and updateBlock methods so JSR-303 actually fires for incoming DTOs. With @Valid on the field-level mentionedPersons in the DTO (added in the previous commit), Jakarta validation now recurses into each PersonMention element and rejects displayName values past the @Size(max=200) ceiling. The test posts a 201-char displayName and asserts the global handler maps the resulting MethodArgumentNotValidException to 400 + code:VALIDATION_ERROR. Refs #362 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -183,6 +183,22 @@ class TranscriptionBlockControllerTest {
|
||||
.andExpect(status().isUnauthorized());
|
||||
}
|
||||
|
||||
@Test
|
||||
@WithMockUser(authorities = "WRITE_ALL")
|
||||
void createBlock_returns400_whenMentionedPersonDisplayNameExceeds200Chars() throws Exception {
|
||||
when(userService.findByEmail(any())).thenReturn(mockUser());
|
||||
String longName = "A".repeat(201);
|
||||
String body = "{\"pageNumber\":1,\"x\":0.1,\"y\":0.2,\"width\":0.3,\"height\":0.4,\"text\":\"x\","
|
||||
+ "\"mentionedPersons\":[{\"personId\":\"" + UUID.randomUUID()
|
||||
+ "\",\"displayName\":\"" + longName + "\"}]}";
|
||||
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user