Skip to content

Commit 305da7d

Browse files
authored
#18: Implement additional naming convention rules (#26)
1 parent 719d882 commit 305da7d

File tree

1 file changed

+33
-6
lines changed

1 file changed

+33
-6
lines changed

src/test/java/com/devonfw/sample/archunit/NamingConventionTest.java

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
package com.devonfw.sample.archunit;
22

3+
import com.devonfw.sample.archunit.general.common.AbstractCto;
34
import com.devonfw.sample.archunit.general.common.AbstractEto;
45
import com.devonfw.sample.archunit.general.dataaccess.ApplicationPersistenceEntity;
6+
import com.devonfw.sample.archunit.general.logic.AbstractUc;
57
import com.tngtech.archunit.core.importer.ImportOption;
68
import com.tngtech.archunit.junit.AnalyzeClasses;
79
import com.tngtech.archunit.junit.ArchTest;
@@ -16,26 +18,51 @@
1618
public class NamingConventionTest {
1719

1820
/**
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
2034
* naming convention by ending with 'Entity'.
2135
*/
2236
@ArchTest
23-
private static final ArchRule DevonNamingConventionEntityCheck =
37+
private static final ArchRule N3DevonNamingConventionEntityCheck =
2438
classes()
2539
.that().areAssignableTo(ApplicationPersistenceEntity.class)
2640
.should().haveSimpleNameEndingWith("Entity")
2741
.because("Classes extending ApplicationPersistenceEntity must follow the naming convention by" +
28-
"ending with 'Entity'.");
42+
" ending with 'Entity'.");
2943

3044
/**
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'.
3347
*/
3448
@ArchTest
35-
private static final ArchRule DevonNamingConventionEtoCheck =
49+
private static final ArchRule N4DevonNamingConventionEtoCheck =
3650
classes()
3751
.that().areAssignableTo(AbstractEto.class)
3852
.should().haveSimpleNameEndingWith("Eto")
3953
.because("Classes extending AbstractEto must follow the naming convention by ending with 'Eto'.");
4054

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+
4168
}

0 commit comments

Comments
 (0)