chore: 테스트 변경
This commit is contained in:
@@ -21,7 +21,7 @@ class ArchitectureTest {
|
||||
new ClassFileImporter().importPath(Path.of("build/classes/java/main"));
|
||||
|
||||
@Test
|
||||
@DisplayName("등록 UseCase → execution scope와 decision context port로 흐름 분리")
|
||||
@DisplayName("등록 UseCase → execution scope와 decision snapshot port로 흐름 분리")
|
||||
void registrationMutationUsesBusinessNamedPorts() {
|
||||
classes()
|
||||
.that().haveSimpleName("RegisterCourseUseCase")
|
||||
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
package com.study.course_registration.architecture;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class LessonMasterWriteBoundaryTest {
|
||||
private static final Path MAIN_SOURCE = Path.of("src/main/java");
|
||||
private static final Path SEEDER = Path.of(
|
||||
"src/main/java/com/study/course_registration/seeder/DataSeeder.java");
|
||||
|
||||
@Test
|
||||
@DisplayName("Lesson master write → 현재는 Seeder만 직접 생성 허용")
|
||||
void lessonMasterCreationIsSeederOnly() throws IOException {
|
||||
List<String> violations = new ArrayList<>();
|
||||
|
||||
try (Stream<Path> files = Files.walk(MAIN_SOURCE)) {
|
||||
files.filter(path -> path.toString().endsWith(".java"))
|
||||
.filter(path -> !path.equals(SEEDER))
|
||||
.forEach(path -> inspectCreation(path, violations));
|
||||
}
|
||||
|
||||
assertThat(violations)
|
||||
.as("운영 Lesson master write path를 추가할 때는 domain policy를 통과하는 명시적 application boundary를 먼저 만드세요.")
|
||||
.isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Seeder schedule write → LessonSchedulePolicy 검증 후 persist")
|
||||
void seederValidatesScheduleBeforePersisting() throws IOException {
|
||||
String source = Files.readString(SEEDER);
|
||||
int validation = source.indexOf("schedulePolicy.validate(");
|
||||
int persistence = source.indexOf("schedules.forEach(entityManager::persist)");
|
||||
|
||||
assertThat(validation).isGreaterThanOrEqualTo(0);
|
||||
assertThat(persistence).isGreaterThan(validation);
|
||||
}
|
||||
|
||||
private static void inspectCreation(Path path, List<String> violations) {
|
||||
try {
|
||||
String source = Files.readString(path);
|
||||
if (source.contains("new Lesson(") || source.contains("new LessonSchedule(")) {
|
||||
violations.add(path.toString());
|
||||
}
|
||||
} catch (IOException exception) {
|
||||
throw new IllegalStateException("Lesson master write boundary 검사 실패: " + path, exception);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user