|
| 1 | +package com.devonfw.sample.archunit; |
| 2 | + |
| 3 | +import com.devonfw.sample.archunit.general.common.AbstractEto; |
| 4 | +import com.devonfw.sample.archunit.general.dataaccess.ApplicationPersistenceEntity; |
| 5 | +import com.tngtech.archunit.core.importer.ImportOption; |
| 6 | +import com.tngtech.archunit.junit.AnalyzeClasses; |
| 7 | +import com.tngtech.archunit.junit.ArchTest; |
| 8 | +import com.tngtech.archunit.lang.ArchRule; |
| 9 | + |
| 10 | +import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.classes; |
| 11 | + |
| 12 | +/** |
| 13 | + * JUnit test that validates the naming convention rules of this application. |
| 14 | + */ |
| 15 | +@AnalyzeClasses(packages = "com.devonfw.sample.archunit", importOptions = ImportOption.DoNotIncludeTests.class) |
| 16 | +public class NamingConventionTest { |
| 17 | + |
| 18 | + /** |
| 19 | + * DevonNamingConventionCheck verifying that classes extending ApplicationPersistenceEntity are following the |
| 20 | + * naming convention by ending with 'Entity'. |
| 21 | + */ |
| 22 | + @ArchTest |
| 23 | + private static final ArchRule DevonNamingConventionEntityCheck = |
| 24 | + classes() |
| 25 | + .that().areAssignableTo(ApplicationPersistenceEntity.class) |
| 26 | + .should().haveSimpleNameEndingWith("Entity") |
| 27 | + .because("Classes extending ApplicationPersistenceEntity must follow the naming convention by" + |
| 28 | + "ending with 'Entity'."); |
| 29 | + |
| 30 | + /** |
| 31 | + * DevonNamingConventionCheck verifying that classes extending AbstractEto are following the naming convention by |
| 32 | + * ending with Eto. |
| 33 | + */ |
| 34 | + @ArchTest |
| 35 | + private static final ArchRule DevonNamingConventionEtoCheck = |
| 36 | + classes() |
| 37 | + .that().areAssignableTo(AbstractEto.class) |
| 38 | + .should().haveSimpleNameEndingWith("Eto") |
| 39 | + .because("Classes extending AbstractEto must follow the naming convention by ending with 'Eto'."); |
| 40 | + |
| 41 | +} |
0 commit comments