Skip to content

Commit

Permalink
refactor architecture test to detect dependency rule
Browse files Browse the repository at this point in the history
  • Loading branch information
WeRockStar committed Mar 21, 2024
1 parent d154696 commit cb2fb51
Showing 1 changed file with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import com.tngtech.archunit.lang.ArchRule;
import org.springframework.stereotype.Repository;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RestController;

@AnalyzeClasses(
packages = "com.kampus.kbazaar",
Expand All @@ -20,11 +19,10 @@ public class DependencyRuleTest {
static final ArchRule service_should_access_by_controller =
classes()
.that()
.haveSimpleNameEndingWith("Service")
.areAnnotatedWith(Service.class)
.should()
.onlyBeAccessed()
.byClassesThat()
.haveSimpleNameEndingWith("Controller")
.dependOnClassesThat()
.areAnnotatedWith(Repository.class)
.allowEmptyShould(true);

@ArchTest
Expand Down

0 comments on commit cb2fb51

Please sign in to comment.