fix(ocr): log debug instead of silently swallowing person name resolution errors
Replaces catch(Exception ignored){} with log.debug() in getTrainingInfo().
Adds controller test documenting the graceful degradation behavior
(response stays 200 when personService.getById() throws).
Fixes reviewer concerns from @felixbrandt and @nullx.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -229,6 +229,23 @@ class OcrControllerTest {
|
||||
.andExpect(jsonPath("$.ocrServiceAvailable").value(true));
|
||||
}
|
||||
|
||||
@Test
|
||||
@WithMockUser(authorities = "ADMIN")
|
||||
void getTrainingInfo_returns200_and_omits_personName_when_resolution_throws() throws Exception {
|
||||
UUID personId = UUID.randomUUID();
|
||||
OcrTrainingRun runWithPerson = OcrTrainingRun.builder()
|
||||
.id(UUID.randomUUID()).status(TrainingStatus.DONE)
|
||||
.personId(personId).blockCount(5).documentCount(1).modelName("sender_x").build();
|
||||
OcrTrainingService.TrainingInfoResponse info =
|
||||
new OcrTrainingService.TrainingInfoResponse(5, 20, 2, 3, true, null, List.of(runWithPerson));
|
||||
when(ocrTrainingService.getTrainingInfo()).thenReturn(info);
|
||||
when(personService.getById(personId)).thenThrow(new RuntimeException("DB error"));
|
||||
|
||||
mockMvc.perform(get("/api/ocr/training-info"))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.personNames").isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
@WithMockUser(authorities = "READ_ALL")
|
||||
void getDocumentOcrStatus_returnsNone_whenNoOcrJobExists() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user