JUnit 5 abstract test classes that enforce the architectural styles supported by the Nova Platform meta-framework. Built on top of ArchUnit, the library turns architectural drift into a failed CI run.
| Style | Abstract test class | Package layout |
|---|---|---|
| Layered | LayeredArchitectureTest |
controller.., service.., repository.., entity.., dto.. |
| Clean (phase 2) | CleanArchitectureTest |
domain.., application.., infrastructure.., api.. |
| Hexagonal (phase 2) | HexagonalArchitectureTest |
domain.., application.., adapters.. |
<dependency>
<groupId>pe.edu.nova.java.libs</groupId>
<artifactId>nova-architecture-rules</artifactId>
<version>1.0.0</version>
<scope>test</scope>
</dependency>Subclass the abstract test that matches your application's style and declare the base package to scan:
package com.acme.my;
import com.tngtech.archunit.core.importer.ImportOption;
import com.tngtech.archunit.junit.AnalyzeClasses;
import pe.edu.nova.java.archunit.LayeredArchitectureTest;
@AnalyzeClasses(
packages = "com.acme.my",
importOptions = ImportOption.DoNotIncludeTests.class)
class ArchitectureTest extends LayeredArchitectureTest {
@Override
protected String basePackage() {
return "com.acme.my";
}
}Run mvn test — ArchUnit reports every violation as a JUnit failure
with the exact offending class.
controller..depends onservice..,entity..,dto..,shared..— never onrepository...service..depends onrepository..,entity..,shared..— never oncontroller...repository..depends onentity..,shared..— never on anything above.entity..is a pure data layer — no imports from other layers.dto..never importsentity..(decoupling transport from persistence).- No service method declares
throws Exception. - No
@Autowiredfield injection on services.
Apache 2.0 — see LICENSE.
Run on each push to main (and every PR). The pipeline is reused from �hincho/nova-devops via reusable workflows.