package cn.yunzhixue.ability.center.architecture;

import com.tngtech.archunit.core.importer.ImportOption;
import com.tngtech.archunit.junit.AnalyzeClasses;
import com.tngtech.archunit.junit.ArchTest;
import com.tngtech.archunit.lang.ArchRule;

import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.noClasses;

@AnalyzeClasses(
        packages = "cn.yunzhixue.ability.center.examsprint",
        importOptions = ImportOption.DoNotIncludeTests.class)
class ExamSprintArchitectureTest {

    @ArchTest
    static final ArchRule contracts_should_not_depend_on_inner_layers = noClasses()
            .that().resideInAPackage("..contracts..")
            .should().dependOnClassesThat().resideInAnyPackage(
                    "..domain..",
                    "..application..",
                    "..infrastructure..",
                    "..adapter.."
            );

    @ArchTest
    static final ArchRule infrastructure_should_not_depend_on_runtime_adapters = noClasses()
            .that().resideInAPackage("..infrastructure..")
            .should().dependOnClassesThat().resideInAnyPackage(
                    "..adapter..",
                    "..configuration.."
            );

    @ArchTest
    static final ArchRule domain_should_not_depend_on_contracts = noClasses()
            .that().resideInAPackage("..domain..")
            .should().dependOnClassesThat().resideInAPackage("..contracts..");

    @ArchTest
    static final ArchRule domain_should_not_depend_on_jackson = noClasses()
            .that().resideInAPackage("..domain..")
            .should().dependOnClassesThat().resideInAnyPackage(
                    "com.fasterxml.jackson.."
            );
}
