98 lines
4.8 KiB
Java
98 lines
4.8 KiB
Java
package p.studio.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 = {"p.studio", "p.packer"}, importOptions = ImportOption.DoNotIncludeTests.class)
|
|
class StudioBoundaryArchTest {
|
|
@ArchTest
|
|
static final ArchRule automationTransportStaysInTheApp = noClasses()
|
|
.that().resideInAnyPackage("p.studio.api..", "p.studio.core..", "p.studio.ui..")
|
|
.should().dependOnClassesThat().resideInAnyPackage(
|
|
"p.studio.app.mcp..", "com.sun.net.httpserver..", "io.modelcontextprotocol..")
|
|
.because("DEC-0060 confines MCP and HTTP transport to application adapters");
|
|
|
|
@ArchTest
|
|
static final ArchRule staticContainerCannotReturn = noClasses()
|
|
.that().resideInAnyPackage("p.studio..")
|
|
.should().haveSimpleName("Container")
|
|
.because("DEC-0059 requires the static service locator to be physically absent");
|
|
|
|
@ArchTest
|
|
static final ArchRule appContainerCompatibilityBridgeCannotReturn = noClasses()
|
|
.that().resideInAnyPackage("p.studio..")
|
|
.should().haveSimpleName("AppContainer")
|
|
.because("DEC-0059 requires Spring composition without a legacy service bag");
|
|
|
|
@ArchTest
|
|
static final ArchRule studioApiIsFrameworkAndProviderNeutral = noClasses()
|
|
.that().resideInAPackage("p.studio.api..")
|
|
.should().dependOnClassesThat().resideInAnyPackage(
|
|
"javafx..",
|
|
"org.springframework..",
|
|
"org.springframework.modulith..",
|
|
"p.packer..",
|
|
"p.studio.compiler..",
|
|
"p.studio.lsp..",
|
|
"p.studio.utilities..",
|
|
"p.studio.core..",
|
|
"p.studio.ui..")
|
|
.because("DEC-0059 requires a toolkit and provider neutral public Studio API");
|
|
|
|
@ArchTest
|
|
static final ArchRule studioCoreDoesNotDependOnJavaFx = noClasses()
|
|
.that().resideInAPackage("p.studio.core..")
|
|
.should().dependOnClassesThat().resideInAPackage("javafx..")
|
|
.because("DEC-0059 requires the Studio Core to compile without JavaFX");
|
|
|
|
@ArchTest
|
|
static final ArchRule studioCoreDoesNotDependOnSpring = noClasses()
|
|
.that().resideInAPackage("p.studio.core..")
|
|
.should().dependOnClassesThat().resideInAPackage("org.springframework..")
|
|
.because("DEC-0059 confines Spring to application composition and keeps core as constructor-injected POJOs");
|
|
|
|
@ArchTest
|
|
static final ArchRule studioCoreDoesNotDependOnLegacySharedInfrastructure = noClasses()
|
|
.that().resideInAPackage("p.studio.core..")
|
|
.should().dependOnClassesThat().resideInAPackage("p.studio.utilities..")
|
|
.because("DEC-0059 requires the extracted core to own explicit contracts instead of inheriting the mixed Studio utility classpath");
|
|
|
|
@ArchTest
|
|
static final ArchRule javaFxAdapterDoesNotDependOnCoreOrProviderImplementations = noClasses()
|
|
.that().resideInAPackage("p.studio.ui.javafx..")
|
|
.should().dependOnClassesThat().resideInAnyPackage(
|
|
"p.studio.core..",
|
|
"p.packer..",
|
|
"p.studio.compiler..",
|
|
"p.studio.lsp..",
|
|
"p.studio.utilities..")
|
|
.because("DEC-0059 requires JavaFX to consume Studio API contracts only");
|
|
|
|
@ArchTest
|
|
static final ArchRule javaFxAdapterDoesNotOrchestrateTheFileSystem = noClasses()
|
|
.that().resideInAPackage("p.studio.ui.javafx..")
|
|
.should().dependOnClassesThat().haveFullyQualifiedName("java.nio.file.Files")
|
|
.because("DEC-0059 keeps filesystem orchestration behind neutral Studio services");
|
|
|
|
@ArchTest
|
|
static final ArchRule javaFxAdapterDoesNotOwnSerialization = noClasses()
|
|
.that().resideInAPackage("p.studio.ui.javafx..")
|
|
.should().dependOnClassesThat().resideInAPackage("com.fasterxml.jackson..")
|
|
.because("DEC-0059 keeps serialization in core or application adapters, not visual controls");
|
|
|
|
@ArchTest
|
|
static final ArchRule packerDoesNotDependOnStudio = noClasses()
|
|
.that().resideInAPackage("p.packer..")
|
|
.should().dependOnClassesThat().resideInAnyPackage(
|
|
"p.studio.api..",
|
|
"p.studio.core..",
|
|
"p.studio.ui..",
|
|
"p.studio.ui.javafx.window..",
|
|
"p.studio.ui.javafx.workspaces..")
|
|
.because("DEC-0059 keeps p.packer autonomous and dependency direction Studio to Packer");
|
|
}
|