refactor: 테스트 GWT로 통일해서 사용할 수 있도록 구성 및 서브에이전트 파일 수정
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
package com.study.course_registration.architecture;
|
||||
|
||||
import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.classes;
|
||||
import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.noClasses;
|
||||
import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.noFields;
|
||||
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import com.tngtech.archunit.core.domain.JavaClasses;
|
||||
import com.tngtech.archunit.core.importer.ClassFileImporter;
|
||||
|
||||
import java.nio.file.Path;
|
||||
|
||||
import jakarta.persistence.ManyToMany;
|
||||
import jakarta.persistence.OneToMany;
|
||||
import jakarta.persistence.OneToOne;
|
||||
|
||||
class ArchitectureTest {
|
||||
@Test
|
||||
@DisplayName("수강신청 mutation → RegistrationLockManager 의존")
|
||||
void registrationMutationUsesLockBoundary() {
|
||||
JavaClasses classes = new ClassFileImporter().importPath(Path.of("build/classes/java/main"));
|
||||
|
||||
classes()
|
||||
.that().haveSimpleName("CourseRegistrationService")
|
||||
.should().dependOnClassesThat().haveSimpleName("RegistrationLockManager")
|
||||
.check(classes);
|
||||
|
||||
noClasses()
|
||||
.that().haveSimpleName("CourseRegistrationService")
|
||||
.should().dependOnClassesThat().haveSimpleName("LessonRepository")
|
||||
.check(classes);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("새 service → registration write repository 우회 금지")
|
||||
void registrationWriteRepositoriesStayInsideApprovedServices() {
|
||||
JavaClasses classes = new ClassFileImporter().importPath(Path.of("build/classes/java/main"));
|
||||
|
||||
noClasses()
|
||||
.that().resideInAPackage("..service..")
|
||||
.and().doNotHaveSimpleName("CourseRegistrationService")
|
||||
.and().doNotHaveSimpleName("LessonQueryService")
|
||||
.should().dependOnClassesThat().haveSimpleName("UserLessonRepository")
|
||||
.check(classes);
|
||||
|
||||
noClasses()
|
||||
.that().resideInAPackage("..service..")
|
||||
.and().doNotHaveSimpleName("CourseRegistrationService")
|
||||
.should().dependOnClassesThat().haveSimpleName("RegistrationIdempotencyRepository")
|
||||
.check(classes);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("엔티티 연관관계 → ManyToOne만 허용")
|
||||
void entityAssociationsUseManyToOneOnly() {
|
||||
JavaClasses classes = new ClassFileImporter().importPath(Path.of("build/classes/java/main"));
|
||||
|
||||
noFields()
|
||||
.that().areDeclaredInClassesThat().resideInAPackage("..entity..")
|
||||
.should().beAnnotatedWith(OneToOne.class)
|
||||
.check(classes);
|
||||
noFields()
|
||||
.that().areDeclaredInClassesThat().resideInAPackage("..entity..")
|
||||
.should().beAnnotatedWith(OneToMany.class)
|
||||
.check(classes);
|
||||
noFields()
|
||||
.that().areDeclaredInClassesThat().resideInAPackage("..entity..")
|
||||
.should().beAnnotatedWith(ManyToMany.class)
|
||||
.check(classes);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user