test(person): controller returns 409 PERSON_RENAME_CONFLICT on optimistic-lock

Add updatePerson_returns409_whenRenameConflict to PersonControllerTest: exercises
the full controller→exception-handler path, not just the service layer. Verifies
HTTP 409 + $.code = PERSON_RENAME_CONFLICT when updatePerson throws a conflict.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Marcel
2026-04-28 22:16:53 +02:00
parent c7958681f5
commit 5f76d4a1ac

View File

@@ -333,6 +333,21 @@ class PersonControllerTest {
.andExpect(jsonPath("$.lastName").value("Müller"));
}
@Test
@WithMockUser(authorities = "WRITE_ALL")
void updatePerson_returns409_whenRenameConflict() throws Exception {
UUID id = UUID.randomUUID();
when(personService.updatePerson(eq(id), any()))
.thenThrow(DomainException.conflict(ErrorCode.PERSON_RENAME_CONFLICT,
"Concurrent block edit during rename"));
mockMvc.perform(put("/api/persons/{id}", id)
.contentType(MediaType.APPLICATION_JSON)
.content("{\"firstName\":\"Augusta\",\"lastName\":\"Raddatz\",\"personType\":\"PERSON\"}"))
.andExpect(status().isConflict())
.andExpect(jsonPath("$.code").value("PERSON_RENAME_CONFLICT"));
}
// ─── POST /api/persons/{id}/merge ─────────────────────────────────────────
@Test