PreCheckFailed auf strukturierten Fehlergrund umgestellt
This commit is contained in:
@@ -3,6 +3,7 @@ package de.gecheckt.pdf.umbenenner.application.service;
|
||||
import de.gecheckt.pdf.umbenenner.application.config.StartConfiguration;
|
||||
import de.gecheckt.pdf.umbenenner.domain.model.DocumentProcessingOutcome;
|
||||
import de.gecheckt.pdf.umbenenner.domain.model.PreCheckFailed;
|
||||
import de.gecheckt.pdf.umbenenner.domain.model.PreCheckFailureReason;
|
||||
import de.gecheckt.pdf.umbenenner.domain.model.TechnicalDocumentError;
|
||||
import de.gecheckt.pdf.umbenenner.domain.model.PdfExtractionContentError;
|
||||
import de.gecheckt.pdf.umbenenner.domain.model.PdfExtractionResult;
|
||||
@@ -67,7 +68,7 @@ public class DocumentProcessingService {
|
||||
|
||||
case PdfExtractionContentError contentError ->
|
||||
// PDF content not extractable: classify as pre-check failed (deterministic content error)
|
||||
new PreCheckFailed(candidate, "PDF content not extractable: " + contentError.reason());
|
||||
new PreCheckFailed(candidate, PreCheckFailureReason.CONTENT_NOT_EXTRACTABLE);
|
||||
|
||||
case PdfExtractionTechnicalError technicalError ->
|
||||
// Technical failure during extraction: potentially retryable
|
||||
|
||||
@@ -61,7 +61,7 @@ public class PreCheckEvaluator {
|
||||
if (!hasUsableText(extraction.extractedText())) {
|
||||
return new PreCheckFailed(
|
||||
candidate,
|
||||
PreCheckFailureReason.NO_USABLE_TEXT.getDescription()
|
||||
PreCheckFailureReason.NO_USABLE_TEXT
|
||||
);
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ public class PreCheckEvaluator {
|
||||
if (extraction.pageCount().exceedsLimit(configuration.maxPages())) {
|
||||
return new PreCheckFailed(
|
||||
candidate,
|
||||
PreCheckFailureReason.PAGE_LIMIT_EXCEEDED.getDescription()
|
||||
PreCheckFailureReason.PAGE_LIMIT_EXCEEDED
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@ import de.gecheckt.pdf.umbenenner.application.port.out.SourceDocumentAccessExcep
|
||||
import de.gecheckt.pdf.umbenenner.application.port.out.SourceDocumentCandidatesPort;
|
||||
import de.gecheckt.pdf.umbenenner.application.service.DocumentProcessingService;
|
||||
import de.gecheckt.pdf.umbenenner.domain.model.BatchRunContext;
|
||||
import de.gecheckt.pdf.umbenenner.domain.model.DocumentProcessingOutcome;
|
||||
import de.gecheckt.pdf.umbenenner.domain.model.PreCheckFailed;
|
||||
import de.gecheckt.pdf.umbenenner.domain.model.PreCheckPassed;
|
||||
import de.gecheckt.pdf.umbenenner.domain.model.TechnicalDocumentError;
|
||||
@@ -187,7 +186,7 @@ public class DefaultBatchRunProcessingUseCase implements BatchRunProcessingUseCa
|
||||
candidate.uniqueIdentifier());
|
||||
case PreCheckFailed failed ->
|
||||
LOG.info("Pre-checks FAILED for '{}': {} (Deterministic content error – may retry in later run).",
|
||||
candidate.uniqueIdentifier(), failed.failureReason());
|
||||
candidate.uniqueIdentifier(), failed.failureReasonDescription());
|
||||
case TechnicalDocumentError technicalError ->
|
||||
LOG.warn("Processing FAILED for '{}': {} (Technical error – may retry in later run).",
|
||||
candidate.uniqueIdentifier(), technicalError.errorMessage());
|
||||
|
||||
@@ -3,6 +3,7 @@ package de.gecheckt.pdf.umbenenner.application.service;
|
||||
import de.gecheckt.pdf.umbenenner.application.config.StartConfiguration;
|
||||
import de.gecheckt.pdf.umbenenner.domain.model.DocumentProcessingOutcome;
|
||||
import de.gecheckt.pdf.umbenenner.domain.model.PreCheckFailed;
|
||||
import de.gecheckt.pdf.umbenenner.domain.model.PreCheckFailureReason;
|
||||
import de.gecheckt.pdf.umbenenner.domain.model.PreCheckPassed;
|
||||
import de.gecheckt.pdf.umbenenner.domain.model.TechnicalDocumentError;
|
||||
import de.gecheckt.pdf.umbenenner.domain.model.PdfExtractionContentError;
|
||||
@@ -98,7 +99,7 @@ class DocumentProcessingServiceTest {
|
||||
assertInstanceOf(PreCheckFailed.class, outcome);
|
||||
PreCheckFailed failed = (PreCheckFailed) outcome;
|
||||
assertEquals(candidate, failed.candidate());
|
||||
assertTrue(failed.failureReason().toLowerCase().contains("usable"));
|
||||
assertEquals(PreCheckFailureReason.NO_USABLE_TEXT, failed.failureReason());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -114,7 +115,7 @@ class DocumentProcessingServiceTest {
|
||||
assertInstanceOf(PreCheckFailed.class, outcome);
|
||||
PreCheckFailed failed = (PreCheckFailed) outcome;
|
||||
assertEquals(candidate, failed.candidate());
|
||||
assertTrue(failed.failureReason().toLowerCase().contains("page"));
|
||||
assertEquals(PreCheckFailureReason.PAGE_LIMIT_EXCEEDED, failed.failureReason());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -130,7 +131,7 @@ class DocumentProcessingServiceTest {
|
||||
assertInstanceOf(PreCheckFailed.class, outcome);
|
||||
PreCheckFailed result = (PreCheckFailed) outcome;
|
||||
assertEquals(candidate, result.candidate());
|
||||
assertTrue(result.failureReason().contains("PDF is corrupted"));
|
||||
assertEquals(PreCheckFailureReason.CONTENT_NOT_EXTRACTABLE, result.failureReason());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -53,7 +53,7 @@ class PreCheckEvaluatorTest {
|
||||
|
||||
assertTrue(result instanceof PreCheckFailed, "Should fail with empty text");
|
||||
PreCheckFailed failed = (PreCheckFailed) result;
|
||||
assertEquals(PreCheckFailureReason.NO_USABLE_TEXT.getDescription(), failed.failureReason());
|
||||
assertEquals(PreCheckFailureReason.NO_USABLE_TEXT, failed.failureReason());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -66,7 +66,7 @@ class PreCheckEvaluatorTest {
|
||||
|
||||
assertTrue(result instanceof PreCheckFailed, "Should fail with whitespace-only text");
|
||||
PreCheckFailed failed = (PreCheckFailed) result;
|
||||
assertEquals(PreCheckFailureReason.NO_USABLE_TEXT.getDescription(), failed.failureReason());
|
||||
assertEquals(PreCheckFailureReason.NO_USABLE_TEXT, failed.failureReason());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -79,7 +79,7 @@ class PreCheckEvaluatorTest {
|
||||
|
||||
assertTrue(result instanceof PreCheckFailed, "Should fail with special characters only");
|
||||
PreCheckFailed failed = (PreCheckFailed) result;
|
||||
assertEquals(PreCheckFailureReason.NO_USABLE_TEXT.getDescription(), failed.failureReason());
|
||||
assertEquals(PreCheckFailureReason.NO_USABLE_TEXT, failed.failureReason());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -147,7 +147,7 @@ class PreCheckEvaluatorTest {
|
||||
|
||||
assertTrue(result instanceof PreCheckFailed, "Should fail when page count exceeds limit");
|
||||
PreCheckFailed failed = (PreCheckFailed) result;
|
||||
assertEquals(PreCheckFailureReason.PAGE_LIMIT_EXCEEDED.getDescription(), failed.failureReason());
|
||||
assertEquals(PreCheckFailureReason.PAGE_LIMIT_EXCEEDED, failed.failureReason());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -160,7 +160,7 @@ class PreCheckEvaluatorTest {
|
||||
|
||||
assertTrue(result instanceof PreCheckFailed, "Should fail with page limit exceeded even if text is good");
|
||||
PreCheckFailed failed = (PreCheckFailed) result;
|
||||
assertEquals(PreCheckFailureReason.PAGE_LIMIT_EXCEEDED.getDescription(), failed.failureReason());
|
||||
assertEquals(PreCheckFailureReason.PAGE_LIMIT_EXCEEDED, failed.failureReason());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -177,7 +177,6 @@ class PreCheckEvaluatorTest {
|
||||
// The specific order of checks doesn't matter; just verify one reason is returned
|
||||
PreCheckFailed failed = (PreCheckFailed) result;
|
||||
assertNotNull(failed.failureReason());
|
||||
assertFalse(failed.failureReason().isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user