1
0

Meilenstein-Präfixe aus Klassennamen entfernt

This commit is contained in:
2026-04-02 09:11:52 +02:00
parent c0cdd0ed6e
commit 7d5c21f14c
21 changed files with 501 additions and 455 deletions

View File

@@ -0,0 +1,111 @@
package de.gecheckt.pdf.umbenenner.domain.model;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
import java.nio.file.Files;
import java.nio.file.Path;
import static org.junit.jupiter.api.Assertions.*;
/**
* Tests for document processing outcome types.
* <p>
* Verifies that all outcome types are properly created and validated.
*/
class DocumentProcessingOutcomeTest {
@TempDir
Path tempDir;
private SourceDocumentCandidate candidate;
@BeforeEach
void setUp() throws Exception {
Path pdfFile = tempDir.resolve("doc.pdf");
Files.createFile(pdfFile);
SourceDocumentLocator locator = new SourceDocumentLocator(pdfFile.toString());
candidate = new SourceDocumentCandidate("doc.pdf", 1024L, locator);
}
@Test
void testTechnicalDocumentError_ValidConstruction() {
// Act
var error = new TechnicalDocumentError(candidate, "I/O error", null);
// Assert
assertEquals(candidate, error.candidate());
assertEquals("I/O error", error.errorMessage());
assertNull(error.cause());
}
@Test
void testTechnicalDocumentError_WithCause() {
// Arrange
var cause = new RuntimeException("File not found");
// Act
var error = new TechnicalDocumentError(candidate, "I/O error", cause);
// Assert
assertEquals(cause, error.cause());
}
@Test
void testTechnicalDocumentError_WithNullCandidate_ThrowsException() {
assertThrows(NullPointerException.class,
() -> new TechnicalDocumentError(null, "Error", null));
}
@Test
void testTechnicalDocumentError_WithNullErrorMessage_ThrowsException() {
assertThrows(NullPointerException.class,
() -> new TechnicalDocumentError(candidate, null, null));
}
@Test
void testTechnicalDocumentError_WithEmptyErrorMessage_ThrowsException() {
assertThrows(IllegalArgumentException.class,
() -> new TechnicalDocumentError(candidate, "", null));
}
@Test
void testTechnicalDocumentError_IsDocumentProcessingOutcome() {
// Verify type relationship
var error = new TechnicalDocumentError(candidate, "Error", null);
assertInstanceOf(DocumentProcessingOutcome.class, error);
}
@Test
void testPreCheckPassed_IsDocumentProcessingOutcome() {
// Verify type relationship
var extraction = new PdfExtractionSuccess("text", new PdfPageCount(1));
var passed = new PreCheckPassed(candidate, extraction);
assertInstanceOf(DocumentProcessingOutcome.class, passed);
}
@Test
void testPreCheckFailed_IsDocumentProcessingOutcome() {
// Verify type relationship
var failed = new PreCheckFailed(candidate, "Test failure reason");
assertInstanceOf(DocumentProcessingOutcome.class, failed);
}
@Test
void testAllOutcomesAreExhaustive() {
// This test verifies that the outcome types are the only implementations
var extraction = new PdfExtractionSuccess("text", new PdfPageCount(1));
DocumentProcessingOutcome[] outcomes = {
new PreCheckPassed(candidate, extraction),
new PreCheckFailed(candidate, "Deterministic content failure"),
new TechnicalDocumentError(candidate, "Technical extraction error", null)
};
for (DocumentProcessingOutcome outcome : outcomes) {
assertInstanceOf(DocumentProcessingOutcome.class, outcome);
}
}
}

View File

@@ -1,113 +0,0 @@
package de.gecheckt.pdf.umbenenner.domain.model;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
import java.nio.file.Files;
import java.nio.file.Path;
import static org.junit.jupiter.api.Assertions.*;
/**
* Tests for M3 document processing outcome types.
* <p>
* Verifies that all four outcome types are properly created and validated.
*/
class M3DocumentProcessingOutcomeTest {
@TempDir
Path tempDir;
private SourceDocumentCandidate candidate;
@BeforeEach
void setUp() throws Exception {
Path pdfFile = tempDir.resolve("doc.pdf");
Files.createFile(pdfFile);
SourceDocumentLocator locator = new SourceDocumentLocator(pdfFile.toString());
candidate = new SourceDocumentCandidate("doc.pdf", 1024L, locator);
}
@Test
void testM3TechnicalDocumentError_ValidConstruction() {
// Act
var error = new M3TechnicalDocumentError(candidate, "I/O error", null);
// Assert
assertEquals(candidate, error.candidate());
assertEquals("I/O error", error.errorMessage());
assertNull(error.cause());
}
@Test
void testM3TechnicalDocumentError_WithCause() {
// Arrange
var cause = new RuntimeException("File not found");
// Act
var error = new M3TechnicalDocumentError(candidate, "I/O error", cause);
// Assert
assertEquals(cause, error.cause());
}
@Test
void testM3TechnicalDocumentError_WithNullCandidate_ThrowsException() {
assertThrows(NullPointerException.class,
() -> new M3TechnicalDocumentError(null, "Error", null));
}
@Test
void testM3TechnicalDocumentError_WithNullErrorMessage_ThrowsException() {
assertThrows(NullPointerException.class,
() -> new M3TechnicalDocumentError(candidate, null, null));
}
@Test
void testM3TechnicalDocumentError_WithEmptyErrorMessage_ThrowsException() {
assertThrows(IllegalArgumentException.class,
() -> new M3TechnicalDocumentError(candidate, "", null));
}
@Test
void testM3TechnicalDocumentError_IsM3DocumentProcessingOutcome() {
// Verify type relationship
var error = new M3TechnicalDocumentError(candidate, "Error", null);
assertInstanceOf(M3DocumentProcessingOutcome.class, error);
}
@Test
void testM3PreCheckPassed_IsM3DocumentProcessingOutcome() {
// Verify type relationship
var extraction = new PdfExtractionSuccess("text", new PdfPageCount(1));
var passed = new M3PreCheckPassed(candidate, extraction);
assertInstanceOf(M3DocumentProcessingOutcome.class, passed);
}
@Test
void testM3PreCheckFailed_IsM3DocumentProcessingOutcome() {
// Verify type relationship
var failed = new M3PreCheckFailed(candidate, "Test failure reason");
assertInstanceOf(M3DocumentProcessingOutcome.class, failed);
}
@Test
void testAllThreeOutcomesAreExhaustive() {
// This test verifies that the three outcome types are the only implementations
// M3 has exactly three outcome types: passed, failed (deterministic), and technical error
var extraction = new PdfExtractionSuccess("text", new PdfPageCount(1));
M3DocumentProcessingOutcome[] outcomes = {
new M3PreCheckPassed(candidate, extraction),
new M3PreCheckFailed(candidate, "Deterministic content failure"),
new M3TechnicalDocumentError(candidate, "Technical extraction error", null)
};
for (M3DocumentProcessingOutcome outcome : outcomes) {
assertInstanceOf(M3DocumentProcessingOutcome.class, outcome);
}
}
}