11package com .netflix .nebula .test .archrules ;
22
33import com .netflix .nebula .archrules .core .ArchRulesService ;
4+ import com .tngtech .archunit .core .domain .JavaClass ;
45import com .tngtech .archunit .lang .ArchRule ;
56import com .tngtech .archunit .lang .Priority ;
67import com .tngtech .archunit .lang .syntax .ArchRuleDefinition ;
1314import static com .netflix .nebula .archrules .common .CanBeAnnotated .Predicates .deprecatedForRemoval ;
1415import static com .tngtech .archunit .core .domain .JavaAccess .Predicates .target ;
1516import static com .tngtech .archunit .core .domain .JavaAccess .Predicates .targetOwner ;
16- import static com .tngtech .archunit .core .domain .JavaClass .Predicates .resideInAPackage ;
17- import static com .tngtech .archunit .core .domain .JavaClass .Predicates .resideOutsideOfPackages ;
17+ import static com .tngtech .archunit .core .domain .JavaClass .Predicates .*;
1818import static com .tngtech .archunit .lang .conditions .ArchPredicates .are ;
1919import static com .tngtech .archunit .lang .conditions .ArchPredicates .is ;
2020
@@ -38,11 +38,26 @@ public class NebulaTestArchRules implements ArchRulesService {
3838 .allowEmptyShould (true )
3939 .because ("deprecated for removal APIs will be removed in the next major version of nebula-test" );
4040
41+ static final ArchRule SPOCK = ArchRuleDefinition .priority (Priority .MEDIUM )
42+ .noClasses ().that (resideOutsideOfPackages ("nebula.test.." ))
43+ .should ()
44+ .beAssignableTo ("nebula.test.IntegrationBase" )
45+ .orShould ().dependOnClassesThat (assignableTo ("nebula.test.IntegrationBase" ))
46+ .orShould ().beAssignableTo ("nebula.test.IntegrationTestKitBase" )
47+ .orShould ().dependOnClassesThat (assignableTo ("nebula.test.IntegrationTestKitBase" ))
48+ .orShould ().beAssignableTo ("nebula.test.IntegrationTestKitSpec" )
49+ .orShould ().dependOnClassesThat (assignableTo ("nebula.test.IntegrationTestKitSpec" ))
50+ .orShould ().beAssignableTo ("nebula.test.AbstractIntegrationTestKitBase" )
51+ .orShould ().dependOnClassesThat (assignableTo ("nebula.test.AbstractIntegrationTestKitBase" ))
52+ .allowEmptyShould (true )
53+ .because ("spock base classes will eventually be deprecated in favor of TestKit DSL" );
54+
4155 @ Override
4256 public Map <String , ArchRule > getRules () {
4357 Map <String , ArchRule > rules = new HashMap <>();
4458 rules .put ("noDeprecatedNebulaTest" , DEPRECATED );
4559 rules .put ("noDeprecatedForRemovalNebulaTest" , DEPRECATED_FOR_REMOVAL );
60+ rules .put ("don't use spock base classes" , SPOCK );
4661 return rules ;
4762 }
4863}
0 commit comments