fix(ocr): replace IllegalStateException with DomainException in triggerSenderTraining
Some checks failed
CI / Unit & Component Tests (push) Failing after 2m33s
CI / OCR Service Tests (push) Successful in 36s
CI / Backend Unit Tests (push) Failing after 2m46s
CI / Unit & Component Tests (pull_request) Failing after 2m37s
CI / OCR Service Tests (pull_request) Successful in 36s
CI / Backend Unit Tests (pull_request) Failing after 2m50s
Some checks failed
CI / Unit & Component Tests (push) Failing after 2m33s
CI / OCR Service Tests (push) Successful in 36s
CI / Backend Unit Tests (push) Failing after 2m46s
CI / Unit & Component Tests (pull_request) Failing after 2m37s
CI / OCR Service Tests (pull_request) Successful in 36s
CI / Backend Unit Tests (pull_request) Failing after 2m50s
Consistent with triggerManualSenderTraining — both defensive paths now use DomainException.internal(OCR_TRAINING_CONFLICT) when the expected RUNNING row is not found after creation. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -154,7 +154,8 @@ public class SenderModelService {
|
|||||||
|
|
||||||
OcrTrainingRun run = Objects.requireNonNull(txTemplate.execute(status ->
|
OcrTrainingRun run = Objects.requireNonNull(txTemplate.execute(status ->
|
||||||
trainingRunRepository.findFirstByPersonIdAndStatus(personId, TrainingStatus.RUNNING)
|
trainingRunRepository.findFirstByPersonIdAndStatus(personId, TrainingStatus.RUNNING)
|
||||||
.orElseThrow(() -> new IllegalStateException(
|
.orElseThrow(() -> DomainException.internal(
|
||||||
|
ErrorCode.OCR_TRAINING_CONFLICT,
|
||||||
"Expected RUNNING row for person " + personId + " but none found"))));
|
"Expected RUNNING row for person " + personId + " but none found"))));
|
||||||
|
|
||||||
String runId = run.getId().toString();
|
String runId = run.getId().toString();
|
||||||
|
|||||||
@@ -297,6 +297,16 @@ class SenderModelServiceTest {
|
|||||||
verify(senderModelRepository, never()).save(any());
|
verify(senderModelRepository, never()).save(any());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void triggerSenderTraining_throwsDomainException_whenRunningRowMissingAfterDispatch() {
|
||||||
|
when(trainingRunRepository.findFirstByPersonIdAndStatus(personId, TrainingStatus.RUNNING))
|
||||||
|
.thenReturn(Optional.empty());
|
||||||
|
|
||||||
|
org.assertj.core.api.Assertions.assertThatThrownBy(
|
||||||
|
() -> service.triggerSenderTraining(personId, 0))
|
||||||
|
.isInstanceOf(DomainException.class);
|
||||||
|
}
|
||||||
|
|
||||||
// ─── triggerSenderTraining — queue promotion ──────────────────────────────
|
// ─── triggerSenderTraining — queue promotion ──────────────────────────────
|
||||||
|
|
||||||
// ─── triggerManualSenderTraining ──────────────────────────────────────────
|
// ─── triggerManualSenderTraining ──────────────────────────────────────────
|
||||||
|
|||||||
Reference in New Issue
Block a user