Search in sources :

Example 1 with EvaluatedRuleEvent

use of com.tngtech.archunit.exampletest.extension.EvaluatedRuleEvent 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();
}
Also used : EvaluatedRuleEvent(com.tngtech.archunit.exampletest.extension.EvaluatedRuleEvent) ArchRule(com.tngtech.archunit.lang.ArchRule) ClassViolatingCodingRules(com.tngtech.archunit.example.layers.ClassViolatingCodingRules) Test(org.junit.jupiter.api.Test)

Aggregations

ClassViolatingCodingRules (com.tngtech.archunit.example.layers.ClassViolatingCodingRules)1 EvaluatedRuleEvent (com.tngtech.archunit.exampletest.extension.EvaluatedRuleEvent)1 ArchRule (com.tngtech.archunit.lang.ArchRule)1 Test (org.junit.jupiter.api.Test)1