| | |
| | | import java.nio.file.Path; |
| | | import org.junit.jupiter.api.Test; |
| | | |
| | | /** 防止业务模块在骨架阶段意外引入具体设备实现。 */ |
| | | /** 防止业务实现重新依赖厂商、模拟器或传输基础设施。 */ |
| | | class ModuleDependencyContractTest |
| | | { |
| | | @Test |
| | |
| | | assertFalse(text.contains("battery-device-simulator")); |
| | | assertFalse(text.contains("spring-boot-starter-data-redis")); |
| | | } |
| | | |
| | | @Test void businessSourcesDependOnlyOnDeviceApi() throws Exception |
| | | { |
| | | Path sources = Path.of("src/main/java"); |
| | | try (var files = Files.walk(sources)) |
| | | { |
| | | for (Path file : files.filter(path -> path.toString().endsWith(".java")).toList()) |
| | | { |
| | | String source = Files.readString(file); |
| | | for (String forbidden : java.util.List.of("com.battery.device.bts", "com.battery.device.simulator", |
| | | "com.ruoyi.system", "org.springframework.web", "org.springframework.data.redis", "SseEmitter")) |
| | | assertFalse(source.contains(forbidden), file + " contains " + forbidden); |
| | | } |
| | | } |
| | | } |
| | | } |