Skip to content

Instantly share code, notes, and snippets.

@andres-sacco
Last active January 15, 2021 23:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andres-sacco/247bd1cb744324e6f18889d9313bb78a to your computer and use it in GitHub Desktop.
Save andres-sacco/247bd1cb744324e6f18889d9313bb78a to your computer and use it in GitHub Desktop.
Name conventions
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