refactor: complete backend directory flattening

This commit is contained in:
wh
2026-04-14 13:50:51 +08:00
parent ba42b6f50e
commit c524fb08e1

View File

@@ -98,6 +98,33 @@ class PackageStructureMigrationTest {
} }
} }
@Test
@DisplayName("源码中不再引用 legacy module 与 common 目录包名")
void sourceTreeHasNoLegacyPackageReferences() throws Exception {
java.nio.file.Path self = java.nio.file.Path.of(
"src", "test", "java", "com", "label", "unit", "PackageStructureMigrationTest.java");
try (java.util.stream.Stream<java.nio.file.Path> paths = java.nio.file.Files.walk(java.nio.file.Path.of("src"))) {
java.util.List<String> violations = paths
.filter(path -> path.toString().endsWith(".java"))
.filter(path -> !path.normalize().endsWith(self))
.map(path -> {
try {
String text = java.nio.file.Files.readString(path);
boolean legacy = text.contains("com.label.module.")
|| text.contains("com.label.common.aop")
|| text.contains("com.label.common.config");
return legacy ? path.toString() : null;
} catch (Exception e) {
throw new RuntimeException(e);
}
})
.filter(java.util.Objects::nonNull)
.toList();
org.assertj.core.api.Assertions.assertThat(violations).isEmpty();
}
}
private static void assertClassExists(String fqcn) { private static void assertClassExists(String fqcn) {
assertThatCode(() -> Class.forName(fqcn)).doesNotThrowAnyException(); assertThatCode(() -> Class.forName(fqcn)).doesNotThrowAnyException();
} }