Search in sources :

Example 96 with ArchRule

use of com.tngtech.archunit.lang.ArchRule in project ArchUnit by TNG.

the class FreezingArchRuleTest method only_reports_relevant_lines_of_multi_line_events.

@Test
public void only_reports_relevant_lines_of_multi_line_events() {
    TestViolationStore violationStore = new TestViolationStore();
    createFrozen(violationStore, rule("some description").withViolations(new ViolatedEvent("first violation1", "second violation1"), new ViolatedEvent("first violation2", "second violation2")).create());
    ArchRule anotherViolation = rule("some description").withViolations(new ViolatedEvent("first violation1", "second violation1", "third violation1"), new ViolatedEvent("first violation2", "second violation2")).create();
    ArchRule frozenWithNewViolation = freeze(anotherViolation).persistIn(violationStore);
    assertThatRule(frozenWithNewViolation).checking(importClasses(getClass())).hasOnlyViolations("third violation1");
}
Also used : ArchRule(com.tngtech.archunit.lang.ArchRule) Test(org.junit.Test)

Example 97 with ArchRule

use of com.tngtech.archunit.lang.ArchRule in project ArchUnit by TNG.

the class FreezingArchRuleTest method toString_shows_original_rule_and_FreezingArchRule.

@Test
public void toString_shows_original_rule_and_FreezingArchRule() {
    ArchRule rule = rule("some description").withoutViolations().create();
    ArchRule frozen = freeze(rule);
    assertThat(frozen.toString()).isEqualTo(String.format("%s{%s}", FreezingArchRule.class.getSimpleName(), rule.toString()));
}
Also used : ArchRule(com.tngtech.archunit.lang.ArchRule) Test(org.junit.Test)

Example 98 with ArchRule

use of com.tngtech.archunit.lang.ArchRule in project ArchUnit by TNG.

the class TextFileBasedViolationStoreTest method stores_violations_of_multiple_rules.

@Test
public void stores_violations_of_multiple_rules() {
    ArchRule firstRule = rule("first rule");
    store.save(firstRule, ImmutableList.of("first violation1", "first violation2"));
    ArchRule secondRule = rule("second rule");
    store.save(secondRule, ImmutableList.of("second violation1", "second violation2"));
    ArchRule thirdRule = rule("third rule");
    store.save(thirdRule, ImmutableList.of("third violation1", "third violation2"));
    assertThat(store.getViolations(firstRule)).containsOnly("first violation1", "first violation2");
    assertThat(store.getViolations(secondRule)).containsOnly("second violation1", "second violation2");
    assertThat(store.getViolations(thirdRule)).containsOnly("third violation1", "third violation2");
}
Also used : ArchRule(com.tngtech.archunit.lang.ArchRule) Test(org.junit.Test)

Example 99 with ArchRule

use of com.tngtech.archunit.lang.ArchRule in project ArchUnit by TNG.

the class TextFileBasedViolationStoreTest method throws_an_exception_if_violations_of_unstored_rule_are_requested.

@Test
public void throws_an_exception_if_violations_of_unstored_rule_are_requested() {
    ArchRule rule = defaultRule();
    thrown.expect(IllegalArgumentException.class);
    thrown.expectMessage("No rule stored with description '" + rule.getDescription() + "'");
    store.getViolations(rule);
}
Also used : ArchRule(com.tngtech.archunit.lang.ArchRule) Test(org.junit.Test)

Example 100 with ArchRule

use of com.tngtech.archunit.lang.ArchRule in project ArchUnit by TNG.

the class ArchitecturesTest method onion_architecture_because_clause.

@Test
public void onion_architecture_because_clause() {
    ArchRule architecture = onionArchitecture().domainModels("onionarchitecture.domain.model..").domainServices("onionarchitecture.domain.service..").applicationServices("onionarchitecture.application..").adapter("cli", "onionarchitecture.adapter.cli..").adapter("persistence", "onionarchitecture.adapter.persistence..").adapter("rest", "onionarchitecture.adapter.rest.command..", "onionarchitecture.adapter.rest.query..").as("overridden").because("some reason");
    assertThat(architecture.getDescription()).isEqualTo("overridden, because some reason");
}
Also used : ArchRule(com.tngtech.archunit.lang.ArchRule) Test(org.junit.Test)

Aggregations

ArchRule (com.tngtech.archunit.lang.ArchRule)141 Test (org.junit.jupiter.api.Test)90 Test (org.junit.Test)37 ArchTest (com.tngtech.archunit.junit.ArchTest)19 CompositeArchRule (com.tngtech.archunit.lang.CompositeArchRule)19 JavaClasses (com.tngtech.archunit.core.domain.JavaClasses)18 UseDataProvider (com.tngtech.java.junit.dataprovider.UseDataProvider)13 ClassFileImporter (com.tngtech.archunit.core.importer.ClassFileImporter)12 DynamicTest (org.junit.jupiter.api.DynamicTest)12 TaskanaIntegrationTest (testapi.TaskanaIntegrationTest)12 EvaluationResult (com.tngtech.archunit.lang.EvaluationResult)6 JavaClass (com.tngtech.archunit.core.domain.JavaClass)5 Immutable (org.eclipse.sirius.components.annotations.Immutable)5 ArchConfiguration (com.tngtech.archunit.ArchConfiguration)4 JavaField (com.tngtech.archunit.core.domain.JavaField)4 CanBeAnnotatedTest (com.tngtech.archunit.core.domain.properties.CanBeAnnotatedTest)4 ArchCondition (com.tngtech.archunit.lang.ArchCondition)3 ClassViolatingCodingRules (com.tngtech.archunit.example.layers.ClassViolatingCodingRules)2 ImmutableProtocol (io.camunda.zeebe.protocol.record.ImmutableProtocol)2 Record (io.camunda.zeebe.protocol.record.Record)2