mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-25 01:05:48 +00:00
Add ArchUnit
This commit is contained in:
parent
89e357eccc
commit
98136d141d
4 changed files with 44 additions and 0 deletions
8
pom.xml
8
pom.xml
|
@ -112,6 +112,14 @@
|
|||
<artifactId>jakarta.xml.bind-api</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.tngtech.archunit</groupId>
|
||||
<artifactId>archunit</artifactId>
|
||||
<version>1.0.1</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
package org.springframework.samples.petclinic.application;
|
||||
|
||||
public class UseCase {
|
||||
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
package org.springframework.samples.petclinic.domain;
|
||||
|
||||
public class MyDomain {
|
||||
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package org.springframework.samples.petclinic;
|
||||
|
||||
import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.noClasses;
|
||||
|
||||
import com.tngtech.archunit.core.domain.JavaClasses;
|
||||
import com.tngtech.archunit.core.importer.ClassFileImporter;
|
||||
import com.tngtech.archunit.lang.ArchRule;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class LayerDependencyRulesTest {
|
||||
|
||||
private final JavaClasses importedClasses = new ClassFileImporter()
|
||||
.importPackages("org.springframework.samples.petclinic");
|
||||
|
||||
@Test
|
||||
void applicationLayerShouldNotDependOnInfrastructureLayer() {
|
||||
ArchRule rule = noClasses().that()
|
||||
.resideInAPackage("..application..")
|
||||
.should()
|
||||
.dependOnClassesThat()
|
||||
.resideInAPackage("..infrastructure..");
|
||||
|
||||
rule.check(importedClasses);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue