use of com.tngtech.archunit.library.Architectures.OnionArchitecture in project ArchUnit by TNG.
the class ArchitecturesTest method onion_architecture_rejects_empty_layers_by_default.
@Test
public void onion_architecture_rejects_empty_layers_by_default() {
OnionArchitecture architecture = anOnionArchitectureWithEmptyLayers();
JavaClasses classes = new ClassFileImporter().importPackages(absolute("onionarchitecture"));
EvaluationResult result = architecture.evaluate(classes);
assertFailureOnionArchitectureWithEmptyLayers(result);
}
use of com.tngtech.archunit.library.Architectures.OnionArchitecture in project ArchUnit by TNG.
the class ArchitecturesTest method onion_architecture_gathers_all_violations.
@Test
public void onion_architecture_gathers_all_violations() {
OnionArchitecture architecture = getTestOnionArchitecture();
JavaClasses classes = new ClassFileImporter().importPackages(absolute("onionarchitecture"));
EvaluationResult result = architecture.evaluate(classes);
assertPatternMatches(result.getFailureReport().getDetails(), getExpectedOnionViolations().toPatterns());
}
use of com.tngtech.archunit.library.Architectures.OnionArchitecture in project ArchUnit by TNG.
the class ArchitecturesTest method onion_architecture_allows_empty_layers_if_all_layers_are_optional.
@Test
public void onion_architecture_allows_empty_layers_if_all_layers_are_optional() {
OnionArchitecture architecture = anOnionArchitectureWithEmptyLayers().withOptionalLayers(true);
assertThat(architecture.getDescription()).startsWith("Onion architecture consisting of (optional)");
JavaClasses classes = new ClassFileImporter().importPackages(absolute("onionarchitecture"));
EvaluationResult result = architecture.evaluate(classes);
assertThat(result.hasViolation()).as("result of evaluating empty layers has violation").isFalse();
assertThat(result.getFailureReport().isEmpty()).as("failure report").isTrue();
}
use of com.tngtech.archunit.library.Architectures.OnionArchitecture in project ArchUnit by TNG.
the class ArchitecturesTest method onion_architecture_overridden_description.
@Test
public void onion_architecture_overridden_description() {
OnionArchitecture 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");
assertThat(architecture.getDescription()).isEqualTo("overridden");
}
use of com.tngtech.archunit.library.Architectures.OnionArchitecture in project ArchUnit by TNG.
the class ArchitecturesTest method onion_architecture_is_not_violated_by_ignored_dependencies.
@Test
public void onion_architecture_is_not_violated_by_ignored_dependencies() {
OnionArchitecture onionIgnoringOriginApplicationLayerClass = getTestOnionArchitecture().ignoreDependency(ApplicationLayerClass.class, CliAdapterLayerClass.class).ignoreDependency(ApplicationLayerClass.class.getName(), PersistenceAdapterLayerClass.class.getName()).ignoreDependency(simpleNameStartingWith("ApplicationLayerCl"), simpleNameContaining("estAdapterLayerCl"));
JavaClasses classes = new ClassFileImporter().importPackages(absolute("onionarchitecture"));
EvaluationResult result = onionIgnoringOriginApplicationLayerClass.evaluate(classes);
ExpectedOnionViolations expectedViolations = getExpectedOnionViolations().withoutViolationsWithOrigin(ApplicationLayerClass.class);
assertPatternMatches(result.getFailureReport().getDetails(), expectedViolations.toPatterns());
}
Aggregations