92 lines
3.9 KiB
Java
92 lines
3.9 KiB
Java
package com.label.unit;
|
|
|
|
import org.junit.jupiter.api.DisplayName;
|
|
import org.junit.jupiter.api.Test;
|
|
|
|
import static org.assertj.core.api.Assertions.assertThatCode;
|
|
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
|
|
|
@DisplayName("标准目录扁平化迁移守卫测试")
|
|
class PackageStructureMigrationTest {
|
|
|
|
@Test
|
|
@DisplayName("基础设施类已迁移到目标目录")
|
|
void infrastructureTypesMoved() {
|
|
assertClassExists("com.label.annotation.OperationLog");
|
|
assertClassExists("com.label.aspect.AuditAspect");
|
|
assertClassExists("com.label.config.MybatisPlusConfig");
|
|
assertClassExists("com.label.config.OpenApiConfig");
|
|
assertClassExists("com.label.config.RedisConfig");
|
|
assertClassExists("com.label.event.ExtractionApprovedEvent");
|
|
assertClassExists("com.label.listener.ExtractionApprovedEventListener");
|
|
|
|
assertClassMissing("com.label.common.aop.OperationLog");
|
|
assertClassMissing("com.label.common.aop.AuditAspect");
|
|
assertClassMissing("com.label.common.config.MybatisPlusConfig");
|
|
assertClassMissing("com.label.common.config.OpenApiConfig");
|
|
assertClassMissing("com.label.common.config.RedisConfig");
|
|
assertClassMissing("com.label.module.annotation.event.ExtractionApprovedEvent");
|
|
assertClassMissing("com.label.module.annotation.service.ExtractionApprovedEventListener");
|
|
}
|
|
|
|
@Test
|
|
@DisplayName("DTO、实体、Mapper 已迁移到扁平数据层")
|
|
void dataTypesMoved() {
|
|
for (String fqcn : java.util.List.of(
|
|
"com.label.dto.LoginRequest",
|
|
"com.label.dto.LoginResponse",
|
|
"com.label.dto.UserInfoResponse",
|
|
"com.label.dto.TaskResponse",
|
|
"com.label.dto.SourceResponse",
|
|
"com.label.entity.AnnotationResult",
|
|
"com.label.entity.TrainingDataset",
|
|
"com.label.entity.SysConfig",
|
|
"com.label.entity.ExportBatch",
|
|
"com.label.entity.SourceData",
|
|
"com.label.entity.AnnotationTask",
|
|
"com.label.entity.AnnotationTaskHistory",
|
|
"com.label.entity.SysCompany",
|
|
"com.label.entity.SysUser",
|
|
"com.label.entity.VideoProcessJob",
|
|
"com.label.mapper.AnnotationResultMapper",
|
|
"com.label.mapper.TrainingDatasetMapper",
|
|
"com.label.mapper.SysConfigMapper",
|
|
"com.label.mapper.ExportBatchMapper",
|
|
"com.label.mapper.SourceDataMapper",
|
|
"com.label.mapper.AnnotationTaskMapper",
|
|
"com.label.mapper.TaskHistoryMapper",
|
|
"com.label.mapper.SysCompanyMapper",
|
|
"com.label.mapper.SysUserMapper",
|
|
"com.label.mapper.VideoProcessJobMapper")) {
|
|
assertClassExists(fqcn);
|
|
}
|
|
}
|
|
|
|
@Test
|
|
@DisplayName("服务类已迁移到扁平 service 目录")
|
|
void serviceTypesMoved() {
|
|
for (String fqcn : java.util.List.of(
|
|
"com.label.service.ExtractionService",
|
|
"com.label.service.QaService",
|
|
"com.label.service.SysConfigService",
|
|
"com.label.service.ExportService",
|
|
"com.label.service.FinetuneService",
|
|
"com.label.service.SourceService",
|
|
"com.label.service.TaskClaimService",
|
|
"com.label.service.TaskService",
|
|
"com.label.service.AuthService",
|
|
"com.label.service.UserService",
|
|
"com.label.service.VideoProcessService")) {
|
|
assertClassExists(fqcn);
|
|
}
|
|
}
|
|
|
|
private static void assertClassExists(String fqcn) {
|
|
assertThatCode(() -> Class.forName(fqcn)).doesNotThrowAnyException();
|
|
}
|
|
|
|
private static void assertClassMissing(String fqcn) {
|
|
assertThatThrownBy(() -> Class.forName(fqcn)).isInstanceOf(ClassNotFoundException.class);
|
|
}
|
|
}
|