|
1 | 1 | package com.devonfw.sample.archunit; |
2 | 2 |
|
| 3 | +import com.devonfw.sample.archunit.general.common.AbstractCto; |
3 | 4 | import com.devonfw.sample.archunit.general.common.AbstractEto; |
4 | 5 | import com.devonfw.sample.archunit.general.dataaccess.ApplicationPersistenceEntity; |
| 6 | +import com.devonfw.sample.archunit.general.logic.AbstractUc; |
5 | 7 | import com.tngtech.archunit.core.importer.ImportOption; |
6 | 8 | import com.tngtech.archunit.junit.AnalyzeClasses; |
7 | 9 | import com.tngtech.archunit.junit.ArchTest; |
|
16 | 18 | public class NamingConventionTest { |
17 | 19 |
|
18 | 20 | /** |
19 | | - * DevonNamingConventionCheck verifying that classes extending ApplicationPersistenceEntity are following the |
| 21 | + * DevonNamingConventionCheck N1 verifying that classes extending AbstractCto are following the |
| 22 | + * naming convention by ending with 'Cto'. |
| 23 | + */ |
| 24 | + @ArchTest |
| 25 | + private static final ArchRule N1DevonNamingConventionCtoCheck = |
| 26 | + classes() |
| 27 | + .that().areAssignableTo(AbstractCto.class) |
| 28 | + .should().haveSimpleNameEndingWith("Cto") |
| 29 | + .because("Classes extending AbstractCto must follow the naming convention by" + |
| 30 | + " ending with 'Cto'."); |
| 31 | + |
| 32 | + /** |
| 33 | + * DevonNamingConventionCheck N3 verifying that classes extending ApplicationPersistenceEntity are following the |
20 | 34 | * naming convention by ending with 'Entity'. |
21 | 35 | */ |
22 | 36 | @ArchTest |
23 | | - private static final ArchRule DevonNamingConventionEntityCheck = |
| 37 | + private static final ArchRule N3DevonNamingConventionEntityCheck = |
24 | 38 | classes() |
25 | 39 | .that().areAssignableTo(ApplicationPersistenceEntity.class) |
26 | 40 | .should().haveSimpleNameEndingWith("Entity") |
27 | 41 | .because("Classes extending ApplicationPersistenceEntity must follow the naming convention by" + |
28 | | - "ending with 'Entity'."); |
| 42 | + " ending with 'Entity'."); |
29 | 43 |
|
30 | 44 | /** |
31 | | - * DevonNamingConventionCheck verifying that classes extending AbstractEto are following the naming convention by |
32 | | - * ending with Eto. |
| 45 | + * DevonNamingConventionCheck N4 verifying that classes extending AbstractEto are following the naming convention by |
| 46 | + * ending with 'Eto'. |
33 | 47 | */ |
34 | 48 | @ArchTest |
35 | | - private static final ArchRule DevonNamingConventionEtoCheck = |
| 49 | + private static final ArchRule N4DevonNamingConventionEtoCheck = |
36 | 50 | classes() |
37 | 51 | .that().areAssignableTo(AbstractEto.class) |
38 | 52 | .should().haveSimpleNameEndingWith("Eto") |
39 | 53 | .because("Classes extending AbstractEto must follow the naming convention by ending with 'Eto'."); |
40 | 54 |
|
| 55 | + /** |
| 56 | + * DevonNamingConventionCheck N5 verifying that non-abstract classes inherited from AbstractUc are following the |
| 57 | + * devonfw naming convention by beginning with 'Uc' and ending with 'Impl'. They must also implement an interface |
| 58 | + * with the same name except for the suffix 'Impl'. |
| 59 | + */ |
| 60 | + @ArchTest |
| 61 | + private static final ArchRule N5DevonNamingConventionUcCheck = |
| 62 | + classes() |
| 63 | + .that().areAssignableTo(AbstractUc.class) |
| 64 | + .and().doNotHaveSimpleName("AbstractUc") |
| 65 | + .should().haveSimpleNameStartingWith("Uc") |
| 66 | + .because("Classes extending AbstractUc must follow the naming convention by starting with 'Uc'."); |
| 67 | + |
41 | 68 | } |
0 commit comments