From c524fb08e1088b264eb2afc8158daaa7160474be Mon Sep 17 00:00:00 2001 From: wh Date: Tue, 14 Apr 2026 13:50:51 +0800 Subject: [PATCH] refactor: complete backend directory flattening --- .../unit/PackageStructureMigrationTest.java | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/test/java/com/label/unit/PackageStructureMigrationTest.java b/src/test/java/com/label/unit/PackageStructureMigrationTest.java index 627ca7e..19eb651 100644 --- a/src/test/java/com/label/unit/PackageStructureMigrationTest.java +++ b/src/test/java/com/label/unit/PackageStructureMigrationTest.java @@ -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 paths = java.nio.file.Files.walk(java.nio.file.Path.of("src"))) { + java.util.List 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) { assertThatCode(() -> Class.forName(fqcn)).doesNotThrowAnyException(); }