name collision tests
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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; }
|
||||
}
|
||||
""";
|
||||
|
||||
Reference in New Issue
Block a user