-
-
Save andres-sacco/4a163f1dde6e1fa966e51666ff1ff508 to your computer and use it in GitHub Desktop.
Annotations rules
This file contains 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 org.springframework.stereotype.Controller; | |
import org.springframework.web.bind.annotation.RestController; | |
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 static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.classes; | |
@AnalyzeClasses(packages = "com.example.archunit", importOptions = ImportOption.DoNotIncludeTests.class) | |
class AnnotationsRulesTest { | |
@ArchTest | |
static final ArchRule controller_should_be_annotated = classes() | |
.that().resideInAPackage("com.example.archunit.controller") | |
.should().beAnnotatedWith(RestController.class) | |
.andShould().notBeAnnotatedWith(Controller.class) | |
.because("Controllers should be annotated with @RestController, and not with @Controller") ; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment