name collision tests

This commit is contained in:
2026-06-07 10:33:19 +02:00
parent f780620cf9
commit 86fb4f260b
5 changed files with 124 additions and 48 deletions

View File

@@ -99,20 +99,34 @@ public class RegressionTest {
Main.exportAll(context, outputs, tempDir);
String baseName = scenario.baseName();
for (StateMachineExporter exporter : outputs) {
String fileName = baseName + exporter.getFileExtension();
Path actualFile = tempDir.resolve(baseName).resolve(fileName);
Path goldenFile = scenario.goldenPath().resolve(fileName);
assertThat(actualFile)
.as("File %s should exist in output", fileName)
.exists();
assertThat(actualFile)
.as("Content mismatch for %s", fileName)
.hasSameTextualContentAs(goldenFile);
// Find the generated directory (it might be named with FQN)
List<Path> generatedDirs;
try (var stream = Files.list(tempDir)) {
generatedDirs = stream.filter(Files::isDirectory).toList();
}
String targetBaseName = scenario.baseName();
Path actualDir = generatedDirs.stream()
.filter(d -> d.getFileName().toString().endsWith(targetBaseName))
.findFirst()
.orElseThrow(() -> new IllegalArgumentException("No output directory found for " + targetBaseName + " in " + generatedDirs));
String actualBaseName = actualDir.getFileName().toString();
for (StateMachineExporter exporter : outputs) {
String fileName = actualBaseName + exporter.getFileExtension();
String goldenFileName = targetBaseName + exporter.getFileExtension();
Path actualFile = actualDir.resolve(fileName);
Path goldenFile = scenario.goldenPath().resolve(goldenFileName);
assertThat(actualFile)
.as("File %s should exist in output", fileName)
.exists();
assertThat(actualFile)
.as("Content mismatch for %s", fileName)
.hasSameTextualContentAs(goldenFile);
}
}
}
}

View File

@@ -277,6 +277,7 @@ class AstFileFinderTest {
void shouldReturnTrue_whenFunctionReturnsTargetType() {
String source = """
public class Test {
@Bean
public StateMachine<S, E> build() { return null; }
}
""";
@@ -289,6 +290,7 @@ class AstFileFinderTest {
void shouldReturnFalse_whenNoFunctionReturnsTargetType() {
String source = """
public class Test {
@Bean
public void build() {}
}
""";
@@ -301,6 +303,7 @@ class AstFileFinderTest {
void shouldReturnTrue_whenFunctionReturnsQualifiedTargetType() {
String source = """
public class Test {
@Bean
public org.springframework.statemachine.StateMachine build() { return null; }
}
""";