-
-
Save andres-sacco/247bd1cb744324e6f18889d9313bb78a to your computer and use it in GitHub Desktop.
Name conventions
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 com.tngtech.archunit.junit.AnalyzeClasses; | |
import com.tngtech.archunit.junit.ArchTest; | |
import com.tngtech.archunit.lang.ArchRule; | |
import com.tngtech.archunit.core.importer.ImportOption; | |
import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.classes; | |
@AnalyzeClasses(packages = "com.example.archunit", importOptions = ImportOption.DoNotIncludeTests.class) | |
class NameConventionRulesTest { | |
private static final String CONTROLLER_SUFFIX = "Controller"; | |
private static final String CONTROLLER_PACKAGE = "com.example.archunit.controller"; | |
@ArchTest | |
static final ArchRule classes_in_controller_should_be_named_properly = classes() | |
.that().resideInAPackage(CONTROLLER_PACKAGE) | |
.should().haveSimpleNameEndingWith(CONTROLLER_SUFFIX) | |
.because(String.format("Classes in %s package should be named with %s suffix", CONTROLLER_PACKAGE, CONTROLLER_SUFFIX)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment