1
0

M7 Bootstrap, Startvalidierung und Exit-Code-Verhalten finalisiert

This commit is contained in:
2026-04-08 12:37:29 +02:00
parent e91cfb9ec2
commit 8d915e7ded
3 changed files with 102 additions and 65 deletions

View File

@@ -245,6 +245,77 @@ class BootstrapRunnerTest {
assertNotNull(runner, "Default constructor should create a valid BootstrapRunner");
}
/**
* Verifies that max.retries.transient = 0 is rejected as invalid startup configuration
* through the full bootstrap path using the real validator. The value 0 is explicitly
* prohibited; only integers >= 1 are valid. Invalid startup configuration must prevent
* the batch from starting and must produce exit code 1.
*/
@Test
void run_returnsOneWhenMaxRetriesTransientIsZeroViaRealValidator() throws Exception {
Path sourceDir = Files.createDirectories(tempDir.resolve("source-mrt"));
Path targetDir = Files.createDirectories(tempDir.resolve("target-mrt"));
Path dbFile = Files.createFile(tempDir.resolve("db-mrt.sqlite"));
Path promptFile = Files.createFile(tempDir.resolve("prompt-mrt.txt"));
StartConfiguration configWithZeroRetries = new StartConfiguration(
sourceDir,
targetDir,
dbFile,
java.net.URI.create("https://api.example.com"),
"gpt-4",
30,
0, // max.retries.transient = 0 is invalid (must be >= 1)
100,
50000,
promptFile,
tempDir.resolve("lock-mrt.lock"),
null,
"INFO",
"test-key",
false
);
BootstrapRunner runner = new BootstrapRunner(
() -> () -> configWithZeroRetries, // ConfigurationPortFactory → ConfigurationPort → StartConfiguration
lockFile -> new MockRunLockPort(),
StartConfigurationValidator::new, // use the real validator
jdbcUrl -> new MockSchemaInitializationPort(),
(config, lock) -> new MockRunBatchProcessingUseCase(true),
SchedulerBatchCommand::new
);
assertEquals(1, runner.run(),
"max.retries.transient = 0 must be rejected as invalid startup configuration "
+ "and must produce exit code 1");
}
/**
* Verifies that an invalid boolean property value for logging configuration
* (such as a non-boolean log.ai.sensitive value) causes a ConfigurationLoadingException
* during the loading phase, which must propagate to exit code 1.
* This ensures that malformed boolean configuration values prevent the batch from starting.
*/
@Test
void run_returnsOneWhenConfigurationLoadingFailsDueToInvalidBooleanProperty() {
BootstrapRunner runner = new BootstrapRunner(
() -> {
throw new de.gecheckt.pdf.umbenenner.adapter.out.configuration.ConfigurationLoadingException(
"Invalid value for log.ai.sensitive: 'maybe'. "
+ "Must be either 'true' or 'false' (case-insensitive).");
},
lockFile -> new MockRunLockPort(),
StartConfigurationValidator::new,
jdbcUrl -> new MockSchemaInitializationPort(),
(config, lock) -> new MockRunBatchProcessingUseCase(true),
SchedulerBatchCommand::new
);
assertEquals(1, runner.run(),
"Invalid boolean property value for logging configuration must produce exit code 1 "
+ "via ConfigurationLoadingException");
}
/**
* Hard startup failure test — schema initialization failure must be treated as
* a startup error and result in exit code 1. This verifies that