use of com.tngtech.archunit.lang.ArchRule in project MovieManager by Angular2Guy.
the class MyArchitectureTests method ruleGeneralCodingRules.
@Test
public void ruleGeneralCodingRules() {
ArchRule archRule = CompositeArchRule.of(GeneralCodingRules.NO_CLASSES_SHOULD_ACCESS_STANDARD_STREAMS).and(NO_CLASSES_SHOULD_USE_FIELD_INJECTION).because("Good practice");
JavaClasses classesToCheck = this.importedClasses.that(JavaClass.Predicates.resideOutsideOfPackages("..adapter.clients.test.."));
archRule.check(classesToCheck);
}
use of com.tngtech.archunit.lang.ArchRule in project MovieManager by Angular2Guy.
the class MyArchitectureTests method ruleCronJobMethodsAnnotations.
@Test
public void ruleCronJobMethodsAnnotations() {
ArchRule exceptionType = ArchRuleDefinition.methods().that().arePublic().and().areDeclaredInClassesThat().resideInAPackage("..adapter.cron..").should().beAnnotatedWith(PostConstruct.class).orShould().beAnnotatedWith(Scheduled.class).andShould().beAnnotatedWith(SchedulerLock.class).orShould().beAnnotatedWith(Order.class);
exceptionType.check(this.importedClasses);
}
use of com.tngtech.archunit.lang.ArchRule in project github-api by hub4j.
the class ArchTests method testRequireUseOfAssertThat.
@Test
public void testRequireUseOfAssertThat() {
final String reason = "This project uses `assertThat(...)` or `assertThrows(...)` instead of other `assert*()` methods.";
final DescribedPredicate<HasName> assertMethodOtherThanAssertThat = nameContaining("assert").and(DescribedPredicate.not(name("assertThat")).and(DescribedPredicate.not(name("assertThrows"))));
final ArchRule onlyAssertThatRule = classes().should(not(callMethodWhere(target(assertMethodOtherThanAssertThat)))).because(reason);
onlyAssertThatRule.check(testClassFiles);
}
use of com.tngtech.archunit.lang.ArchRule in project sirius-components by eclipse-sirius.
the class CodingRulesTests method classesImplementingInputShouldBeFinal.
@Test
public void classesImplementingInputShouldBeFinal() {
// @formatter:off
ArchRule rule = ArchRuleDefinition.classes().that().areAssignableTo(IInput.class).and().areNotInterfaces().should().haveModifier(JavaModifier.FINAL);
// @formatter:on
rule.check(this.getClasses());
}
use of com.tngtech.archunit.lang.ArchRule in project sirius-components by eclipse-sirius.
the class CodingRulesTests method classesImplentingPayloadShouldBeFinal.
@Test
public void classesImplentingPayloadShouldBeFinal() {
// @formatter:off
ArchRule rule = ArchRuleDefinition.classes().that().areAssignableTo(IPayload.class).and().areNotInterfaces().should().haveModifier(JavaModifier.FINAL).andShould().haveOnlyFinalFields();
// @formatter:on
rule.check(this.getClasses());
}
Aggregations