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");
}
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()));
}
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");
}
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);
}
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");
}
Aggregations