-
-
Save andres-sacco/774bf7e86477484a7429607c2c87880b to your computer and use it in GitHub Desktop.
Service 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 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.fields; | |
@AnalyzeClasses(packages = "com.example.archunit", importOptions = ImportOption.DoNotIncludeTests.class) //1 | |
class ServiceRulesTest { | |
@ArchTest //2 | |
static final ArchRule fields_should_not_be_public = fields() | |
.that().areDeclaredInClassesThat() | |
.resideInAPackage("com.example.archunit.service") | |
.should().notBePublic() | |
.because("Public fields are not allowed in Service classes"); //3 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment