Created
October 12, 2020 15:39
-
-
Save BenjaminKlatt/9c485a54b006545cb1fdd30400838dd7 to your computer and use it in GitHub Desktop.
ArchUnit Basis Test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package de.viadee.architecture.archunit.architecture; | |
import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.noClasses; | |
import org.junit.jupiter.api.Test; | |
import com.tngtech.archunit.core.domain.JavaClasses; | |
import com.tngtech.archunit.core.importer.ClassFileImporter; | |
import com.tngtech.archunit.lang.ArchRule; | |
public class SimpleArchitectureTest { | |
@Test | |
public void controllers_should_not_access_persistence() { | |
JavaClasses importedClasses = | |
new ClassFileImporter().importPackages("de.viadee.architecture.archunit"); | |
ArchRule rule = noClasses().that().resideInAPackage("..controller..").should() | |
.dependOnClassesThat().resideInAPackage("..persistence..") | |
.because("controllers must use business services instead of the persistence layer"); | |
rule.check(importedClasses); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment