test(architecture): apply the layer rules to repo packages

This commit is contained in:
lobo committed 2026-09-30 13:41:56 +02:00
1 parent afcfacb68b
commit b6be1879f0
2 files changed
+3 -3

No files matched your search

+1 -1
View File
@@ -129,7 +129,7 @@ layers:
|---|---|---|
| API | `api` | REST controllers, request/response records, `ApiMapper`. Calls services, never repositories. |
| Domain | `model`, `service`, `exception` | Plain Java models and business logic. Uses repositories, never API classes, entities or `EntityMapper`. |
| Persistence | `persistence` | JPA entities, Spring Data repositories, `EntityMapper`. Entities never reach the API layer. |
| Persistence | `persistence`, `repo` | JPA entities, Spring Data repositories, `EntityMapper`; `repo` holds `JdbcTemplate` queries. Entities never reach the API layer. |
`profile` and `stats` only read data. They have no entities and use `JdbcTemplate` queries in a `repo` package.
`version` has only an `api` package: `GET /api/version` answers the commit and build time of the running image.
@@ -73,12 +73,12 @@ class ArchitectureTest extends AbstractArchitectureTest {
@ArchTest
static final ArchRule apis_should_only_call_services = noClasses()
.that().resideInAPackage("..api..")
.should().dependOnClassesThat().resideInAPackage("..persistence..")
.should().dependOnClassesThat().resideInAnyPackage("..persistence..", "..repo..")
.because("APIs must delegate to Services and should not access Persistence directly.");
@ArchTest
static final ArchRule persistence_should_not_depend_on_apis = noClasses()
.that().resideInAPackage("..persistence..")
.that().resideInAnyPackage("..persistence..", "..repo..")
.should().dependOnClassesThat().resideInAPackage("..api..")
.because("Persistence layer must be independent of the API layer.");