fix(ocr): persist scriptType override via DocumentService transaction

OcrService.startOcr() was setting scriptType on a detached entity,
silently losing the mutation. Added DocumentService.updateScriptType()
with @Transactional to persist the change properly.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Marcel
2026-04-13 12:26:37 +02:00
parent 2d43f09172
commit 6a0fd25662
3 changed files with 11 additions and 3 deletions

View File

@@ -146,7 +146,7 @@ class OcrServiceTest {
}
@Test
void startOcr_setsScriptTypeOnDocument_whenProvided() {
void startOcr_updatesScriptType_whenProvided() {
UUID docId = UUID.randomUUID();
Document doc = Document.builder().id(docId).status(DocumentStatus.UPLOADED)
.filePath("test.pdf").scriptType(ScriptType.UNKNOWN).build();
@@ -160,6 +160,6 @@ class OcrServiceTest {
ocrService.startOcr(docId, ScriptType.HANDWRITING_LATIN, UUID.randomUUID());
assertThat(doc.getScriptType()).isEqualTo(ScriptType.HANDWRITING_LATIN);
verify(documentService).updateScriptType(docId, ScriptType.HANDWRITING_LATIN);
}
}