From b5cccd109c9e3422a9a17c899e1036d963a99e06 Mon Sep 17 00:00:00 2001 From: Ismail Ismailov Date: Thu, 27 Apr 2023 13:58:35 +0200 Subject: [PATCH] Add ArchUnit tests for domain layer --- .../petclinic/LayerDependencyRulesTest.java | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/test/java/org/springframework/samples/petclinic/LayerDependencyRulesTest.java b/src/test/java/org/springframework/samples/petclinic/LayerDependencyRulesTest.java index 4ea8bb15c..b6c6393e9 100644 --- a/src/test/java/org/springframework/samples/petclinic/LayerDependencyRulesTest.java +++ b/src/test/java/org/springframework/samples/petclinic/LayerDependencyRulesTest.java @@ -23,4 +23,26 @@ class LayerDependencyRulesTest { rule.check(importedClasses); } + @Test + void domainLayerShouldNotDependOnApplicationLayer() { + ArchRule rule = noClasses().that() + .resideInAPackage("..domain..") + .should() + .dependOnClassesThat() + .resideInAPackage("..application.."); + + rule.check(importedClasses); + } + + @Test + void domainLayerShouldNotDependOnInfrastructureLayer() { + ArchRule rule = noClasses().that() + .resideInAPackage("..domain..") + .should() + .dependOnClassesThat() + .resideInAPackage("..infrastructure.."); + + rule.check(importedClasses); + } + }