use of com.tngtech.archunit.lang.ArchRule in project AngularAndSpringWithMaps by Angular2Guy.
the class MyArchitectureTests method createNoFieldInjectionRule.
private static ArchRule createNoFieldInjectionRule() {
ArchCondition<JavaField> annotatedWithSpringAutowired = beAnnotatedWith("org.springframework.beans.factory.annotation.Autowired");
ArchCondition<JavaField> annotatedWithGuiceInject = beAnnotatedWith("com.google.inject.Inject");
ArchCondition<JavaField> annotatedWithJakartaInject = beAnnotatedWith("javax.inject.Inject");
ArchRule beAnnotatedWithAnInjectionAnnotation = ArchRuleDefinition.noFields().should(annotatedWithSpringAutowired.or(annotatedWithGuiceInject).or(annotatedWithJakartaInject).as("be annotated with an injection annotation"));
return beAnnotatedWithAnInjectionAnnotation;
}
use of com.tngtech.archunit.lang.ArchRule in project arch-unit-build-plugin-core by societe-generale.
the class NoPublicFieldRuleTest method execute.
@Override
public void execute(String packagePath, ScopePathProvider scopePathProvider, Collection<String> excludedPaths) {
ArchRule rulePublic = fields().that().areNotStatic().or().areNotFinal().should().notBePublic().allowEmptyShould(true).because(NO_PUBLIC_FIELD_VIOLATION_MESSAGE);
rulePublic.check(ArchUtils.importAllClassesInPackage(scopePathProvider.getMainClassesPath(), packagePath, excludedPaths));
}
use of com.tngtech.archunit.lang.ArchRule in project arch-unit-build-plugin-core by societe-generale.
the class DontReturnNullCollectionTest method execute.
@Override
public void execute(String packagePath, ScopePathProvider scopePathProvider, Collection<String> excludedPaths) {
ArchRule rule = methods().that().haveRawReturnType(List.class).or().haveRawReturnType(Set.class).should().beAnnotatedWith(Nonnull.class).because(NO_NULL_COLLECTION_MESSAGE);
rule.check(ArchUtils.importAllClassesInPackage(scopePathProvider.getMainClassesPath(), packagePath, excludedPaths));
}
use of com.tngtech.archunit.lang.ArchRule in project MovieManager by Angular2Guy.
the class MyArchitectureTests method ruleControllerAnnotations.
@Test
public void ruleControllerAnnotations() {
ArchRule beAnnotatedWith = ArchRuleDefinition.classes().that().resideInAPackage("..adapter.controller..").should().beAnnotatedWith(RestController.class).orShould().beAnnotatedWith(Configuration.class);
beAnnotatedWith.check(this.importedClasses);
}
use of com.tngtech.archunit.lang.ArchRule in project MovieManager by Angular2Guy.
the class MyArchitectureTests method createNoFieldInjectionRule.
private static ArchRule createNoFieldInjectionRule() {
ArchCondition<JavaField> annotatedWithSpringAutowired = beAnnotatedWith("org.springframework.beans.factory.annotation.Autowired");
ArchCondition<JavaField> annotatedWithGuiceInject = beAnnotatedWith("com.google.inject.Inject");
ArchCondition<JavaField> annotatedWithJakartaInject = beAnnotatedWith("javax.inject.Inject");
ArchRule beAnnotatedWithAnInjectionAnnotation = ArchRuleDefinition.noFields().should(annotatedWithSpringAutowired.or(annotatedWithGuiceInject).or(annotatedWithJakartaInject).as("be annotated with an injection annotation"));
return beAnnotatedWithAnInjectionAnnotation;
}
Aggregations