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.rules; | |
import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.classes; | |
import org.springframework.web.bind.annotation.RestController; | |
import com.tngtech.archunit.lang.ArchRule; | |
public class TeamArchRules { | |
/** Architecture Rule for REST controller conventions */ | |
public static ArchRule CONTROLLERS_SHOULD_BE_SUFFIXED_AND_LOCATED = |
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
import static com.tngtech.archunit.library.GeneralCodingRules.NO_CLASSES_SHOULD_THROW_GENERIC_EXCEPTIONS; | |
import static com.tngtech.archunit.library.GeneralCodingRules.NO_CLASSES_SHOULD_USE_JODATIME; | |
... | |
@ArchTest | |
static ArchRule no_generic_exceptions = NO_CLASSES_SHOULD_THROW_GENERIC_EXCEPTIONS; | |
@ArchTest | |
static ArchRule do_not_use_jodatime = NO_CLASSES_SHOULD_USE_JODATIME; |
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
@ArchTest | |
private static ArchRule controllers_should_be_suffixed = | |
classes() | |
.that().areAnnotatedWith(RestController.class) | |
.should().haveSimpleNameEndingWith("Controller") | |
.and().resideInAPackage("..controller..") | |
.because("Erkennbarkeit Controller Hauptklasse"); |
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
@ArchTest | |
private static ArchRule no_java_util_date = | |
noClasses() | |
.should().dependOnClassesThat() | |
.haveFullyQualifiedName(java.util.Date.class.getName()) | |
.because("LocalDate statt java.util.Date verwenden"); |
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.library.Architectures.onionArchitecture; | |
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; | |
@AnalyzeClasses( | |
packages = "de.viadee.architecture.archunit", |
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.library.Architectures.layeredArchitecture; | |
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; | |
@AnalyzeClasses( | |
packages = "de.viadee.architecture.archunit", |
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 com.tngtech.archunit.junit.AnalyzeClasses; | |
import com.tngtech.archunit.junit.ArchTest; | |
import com.tngtech.archunit.lang.ArchRule; | |
@AnalyzeClasses(packages = "de.viadee.architecture.archunit") | |
public class SimpleArchitectureCompactTest { | |
@ArchTest |
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
java.lang.AssertionError: Architecture Violation [Priority: MEDIUM] - Rule 'no classes that reside in a package '..controller..' should depend on classes that reside in a package '..persistence..', because controllers must use business services instead of the persistence layer' was violated (3 times): | |
Constructor <de.viadee.architecture.archunit.controller.HelloWorldController.<init>(de.viadee.architecture.archunit.service.HelloWorldService, de.viadee.architecture.archunit.persistence.PersistenceManager)> has parameter of type <de.viadee.architecture.archunit.persistence.PersistenceManager> in (HelloWorldController.java:0) | |
Field <de.viadee.architecture.archunit.controller.HelloWorldController.persistenceManager> has type <de.viadee.architecture.archunit.persistence.PersistenceManager> in (HelloWorldController.java:0) | |
Method <de.viadee.architecture.archunit.controller.HelloWorldController.save(java.lang.String)> calls method <de.viadee.architecture.archunit.persistence.PersistenceManager.save(java.lang.O |
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 |
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
dependencies { | |
testImplementation 'com.tngtech.archunit:archunit-junit5:0.23.1' | |
} |