1
Files
lecture-professional-softwa…/src/test/java/mops/gruppen2/architecture/LayeredArchitectureTest.java
Christoph e9bab1bf3f Intellij Code Cleaunp
Co-authored-by: Christoph <tobi@urpost.de>
2020-03-18 23:25:54 +01:00

41 lines
1.7 KiB
Java

package mops.gruppen2.architecture;
import com.tngtech.archunit.core.importer.ImportOption;
import com.tngtech.archunit.junit.AnalyzeClasses;
import com.tngtech.archunit.junit.ArchTest;
import com.tngtech.archunit.lang.ArchRule;
import com.tngtech.archunit.library.Architectures;
@AnalyzeClasses(packages = "mops.gruppen2", importOptions = ImportOption.DoNotIncludeTests.class)
public class LayeredArchitectureTest {
private static final Architectures.LayeredArchitecture layeredArchitecture = Architectures
.layeredArchitecture()
.layer("Domain").definedBy("..domain..")
.layer("Service").definedBy("..service")
.layer("Controller").definedBy("..controller..")
.layer("Repository").definedBy("..repository..")
.layer("Config").definedBy("..config..");
@ArchTest
public static final ArchRule domainLayerShouldOnlyBeAccessedByServiceAndControllerLayer = layeredArchitecture
.whereLayer("Domain")
.mayOnlyBeAccessedByLayers("Service", "Controller", "Config");
@ArchTest
public static final ArchRule serviceLayerShouldOnlyBeAccessedByControllerLayer = layeredArchitecture
.whereLayer("Service")
.mayOnlyBeAccessedByLayers("Controller", "Config");
@ArchTest
public static final ArchRule repositoryLayerShouldOnlyBeAccessedByServiceLayer = layeredArchitecture
.whereLayer("Repository")
.mayOnlyBeAccessedByLayers("Service");
@ArchTest
public static final ArchRule controllerLayerShouldNotBeAccessedByAnyLayer = layeredArchitecture
.whereLayer("Controller")
.mayNotBeAccessedByAnyLayer();
}