use of com.tngtech.archunit.library.Architectures.LayeredArchitecture in project ArchUnit by TNG.
the class ArchitecturesTest method layered_architecture_allows_individual_empty_optionalLayer.
@Test
public void layered_architecture_allows_individual_empty_optionalLayer() {
LayeredArchitecture architecture = layeredArchitecture().optionalLayer("can be absent").definedBy(absolute("should.not.be.found.."));
JavaClasses classes = new ClassFileImporter().importPackages(absolute(""));
EvaluationResult result = architecture.evaluate(classes);
assertThat(result.hasViolation()).as("result of evaluating empty optionalLayer has violation").isFalse();
assertThat(result.getFailureReport().isEmpty()).as("failure report").isTrue();
}
use of com.tngtech.archunit.library.Architectures.LayeredArchitecture in project ArchUnit by TNG.
the class ArchitecturesTest method layered_architecture_allows_empty_layers_if_all_layers_are_optional.
@Test
public void layered_architecture_allows_empty_layers_if_all_layers_are_optional() {
LayeredArchitecture architecture = aLayeredArchitectureWithEmptyLayers().withOptionalLayers(true);
assertThat(architecture.getDescription()).startsWith("Layered architecture consisting of (optional)");
JavaClasses classes = new ClassFileImporter().importPackages(absolute(""));
assertThatRule(architecture).checking(classes).hasNoViolation();
}
use of com.tngtech.archunit.library.Architectures.LayeredArchitecture in project ArchUnit by TNG.
the class ArchitecturesTest method layered_architecture_combines_multiple_ignores.
@Test
public void layered_architecture_combines_multiple_ignores() {
JavaClasses classes = new ClassFileImporter().importClasses(FirstAnyPkgClass.class, SomePkgSubclass.class, SecondThreeAnyClass.class, SomePkgClass.class);
LayeredArchitecture layeredArchitecture = layeredArchitecture().layer("One").definedBy(absolute("some.pkg..")).whereLayer("One").mayNotBeAccessedByAnyLayer().ignoreDependency(FirstAnyPkgClass.class, SomePkgSubclass.class);
assertThat(layeredArchitecture.evaluate(classes).hasViolation()).as("result has violation").isTrue();
layeredArchitecture = layeredArchitecture.ignoreDependency(SecondThreeAnyClass.class, SomePkgClass.class);
assertThat(layeredArchitecture.evaluate(classes).hasViolation()).as("result has violation").isFalse();
}
use of com.tngtech.archunit.library.Architectures.LayeredArchitecture in project ArchUnit by TNG.
the class ArchitecturesTest method layered_architecture_overridden_description.
@Test
public void layered_architecture_overridden_description() {
LayeredArchitecture architecture = layeredArchitecture().layer("One").definedBy("some.pkg..").whereLayer("One").mayNotBeAccessedByAnyLayer().as("overridden");
assertThat(architecture.getDescription()).isEqualTo("overridden");
}
use of com.tngtech.archunit.library.Architectures.LayeredArchitecture in project ArchUnit by TNG.
the class ArchitecturesTest method layered_architecture_rejects_empty_layers_by_default.
@Test
public void layered_architecture_rejects_empty_layers_by_default() {
LayeredArchitecture architecture = aLayeredArchitectureWithEmptyLayers();
JavaClasses classes = new ClassFileImporter().importPackages(absolute(""));
EvaluationResult result = architecture.evaluate(classes);
assertFailureLayeredArchitectureWithEmptyLayers(result);
}
Aggregations