use of com.tngtech.archunit.lang.ArchRule in project ArchUnit by TNG.
the class ExtensionIntegrationTest method evaluation_results_are_dispatched_to_extensions.
@Test
void evaluation_results_are_dispatched_to_extensions() {
ArchConfiguration.get().configureExtension(ExampleExtension.UNIQUE_IDENTIFIER).setProperty("enabled", true);
ArchRule rule = noClasses().should().haveFullyQualifiedName(ClassViolatingCodingRules.class.getName());
checkRuleAndIgnoreFailure(classes, rule);
assertThat(ExampleExtension.getConfigurationEvents()).hasSize(1);
assertThat(ExampleExtension.getConfigurationEvents()).extracting("properties").are(containingEntry("example-prop", "exampleValue"));
EvaluatedRuleEvent event = getOnlyElement(ExampleExtension.getEvaluatedRuleEvents());
assertThat(event.contains(rule)).as("Rule was passed").isTrue();
assertThat(event.contains(classes)).as("Classes were passed").isTrue();
assertThat(event.hasViolationFor(ClassViolatingCodingRules.class)).as("Has violation for " + ClassViolatingCodingRules.class.getSimpleName()).isTrue();
}
use of com.tngtech.archunit.lang.ArchRule in project ArchUnit by TNG.
the class ExtensionIntegrationTest method evaluation_results_are_only_dispatched_to_enabled_extensions.
@Test
void evaluation_results_are_only_dispatched_to_enabled_extensions() {
ArchConfiguration.get().configureExtension(ExampleExtension.UNIQUE_IDENTIFIER).setProperty("enabled", false);
ArchRule rule = noClasses().should().haveFullyQualifiedName(ClassViolatingCodingRules.class.getName());
checkRuleAndIgnoreFailure(classes, rule);
assertThat(ExampleExtension.getConfigurationEvents()).isEmpty();
assertThat(ExampleExtension.getEvaluatedRuleEvents()).isEmpty();
}
use of com.tngtech.archunit.lang.ArchRule in project jhipster-lite by jhipster.
the class AnnotationArchTest method shouldHaveIntegrationTestAnnotation.
@Test
void shouldHaveIntegrationTestAnnotation() {
JavaClasses importedClasses = new ClassFileImporter().importPackages("tech.jhipster.lite");
ArchRule rule = classes().that().resideInAnyPackage("tech.jhipster.lite..").and().haveSimpleNameEndingWith("IT").should().beAnnotatedWith(IntegrationTest.class).orShould().beAnnotatedWith(Nested.class);
rule.check(importedClasses);
}
use of com.tngtech.archunit.lang.ArchRule in project zeebe by zeebe-io.
the class ImmutableProtocolTest method shouldAnnotateImmutableProtocol.
@ArchTest
void shouldAnnotateImmutableProtocol(final JavaClasses importedClasses) {
// given
final ArchRule rule = ArchRuleDefinition.classes().that().areInterfaces().and().resideInAnyPackage("io.camunda.zeebe.protocol.record.value..").or(Predicates.equivalentTo(Record.class)).and(DescribedPredicate.not(getExcludedClasses())).should().beAnnotatedWith(Value.Immutable.class).andShould().beAnnotatedWith(ImmutableProtocol.class).andShould(new BuilderCondition());
// then
rule.check(importedClasses);
}
use of com.tngtech.archunit.lang.ArchRule in project zeebe by zeebe-io.
the class ImmutableProtocolTest method shouldNotAnnotateExcludedClasses.
@ArchTest
void shouldNotAnnotateExcludedClasses(final JavaClasses importedClasses) {
// given
final ArchRule rule = ArchRuleDefinition.classes().that(getExcludedClasses()).should().notBeAnnotatedWith(ImmutableProtocol.class).orShould().notBeAnnotatedWith(Value.Immutable.class);
// then
rule.check(importedClasses);
}
Aggregations