use of com.tngtech.archunit.lang.EvaluationResult 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.lang.EvaluationResult in project ArchUnit by TNG.
the class ArchitecturesTest method layered_architecture_gathers_may_only_access_layers_violations.
@Test
@UseDataProvider("layeredArchitectureMayOnlyAccessLayersDefinitions")
public void layered_architecture_gathers_may_only_access_layers_violations(LayeredArchitecture architecture) {
JavaClasses classes = new ClassFileImporter().importPackages(absolute("mayonlyaccesslayers"));
EvaluationResult result = architecture.evaluate(classes);
assertPatternMatches(result.getFailureReport().getDetails(), ImmutableSet.of(expectedAccessViolationPattern(MayOnlyAccessLayersOriginClass.class, "call", MayOnlyAccessLayersForbiddenClass.class, "callMe"), expectedAccessViolationPattern(MayOnlyAccessLayersOriginClass.class, CONSTRUCTOR_NAME, Object.class, CONSTRUCTOR_NAME), expectedAccessViolationPattern(MayOnlyAccessLayersForbiddenClass.class, CONSTRUCTOR_NAME, Object.class, CONSTRUCTOR_NAME), expectedAccessViolationPattern(MayOnlyAccessLayersForbiddenClass.class, "callMe", MayOnlyAccessLayersOriginClass.class, CONSTRUCTOR_NAME), expectedInheritancePattern(MayOnlyAccessLayersOriginClass.class, Object.class), expectedInheritancePattern(MayOnlyAccessLayersForbiddenClass.class, Object.class), expectedFieldTypePattern(MayOnlyAccessLayersOriginClass.class, "illegalTarget", MayOnlyAccessLayersForbiddenClass.class)));
}
use of com.tngtech.archunit.lang.EvaluationResult 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.lang.EvaluationResult 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.lang.EvaluationResult in project ArchUnit by TNG.
the class ArchitecturesTest method onion_architecture_with_overwritten_description_retains_ignored_dependencies.
@Test
public void onion_architecture_with_overwritten_description_retains_ignored_dependencies() {
ArchRule onionIgnoringOriginApplicationLayerClass = getTestOnionArchitecture().ignoreDependency(equivalentTo(ApplicationLayerClass.class), DescribedPredicate.<JavaClass>alwaysTrue()).because("some reason causing description to be overwritten");
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