use of com.tngtech.archunit.lang.EvaluationResult in project ArchUnit by TNG.
the class GivenSlicesTest method restricting_slices_that_should_not_depend_on_each_other.
@Test
public void restricting_slices_that_should_not_depend_on_each_other() {
archConfigurationRule.setFailOnEmptyShould(false);
GivenSlices givenSlices = slices().matching("..testclasses.(*)..");
JavaClasses classes = new ClassFileImporter().importPackages("com.tngtech.archunit.library.testclasses");
EvaluationResult result = givenSlices.that(DescribedPredicate.<Slice>alwaysFalse()).and(DescribedPredicate.<Slice>alwaysTrue()).should().notDependOnEachOther().evaluate(classes);
assertThat(result.hasViolation()).as("Result has violation").isFalse();
result = givenSlices.that(DescribedPredicate.<Slice>alwaysTrue()).or(DescribedPredicate.<Slice>alwaysFalse()).should().notDependOnEachOther().evaluate(classes);
assertThat(result.hasViolation()).as("Result has violation").isTrue();
}
use of com.tngtech.archunit.lang.EvaluationResult in project ArchUnit by TNG.
the class PlantUmlArchConditionTest method can_handle_all_possible_user_inputs_without_violations.
@Test
@UseDataProvider("possibleInputTypes")
public void can_handle_all_possible_user_inputs_without_violations(PlantUmlCreationTestCase testCase) {
File file = TestDiagram.in(temporaryFolder).component("SomeOrigin").withStereoTypes("..origin").component("SomeTarget").withStereoTypes("..target").dependencyFrom("[SomeOrigin]").to("[SomeTarget]").write();
PlantUmlArchCondition condition = testCase.createConditionFrom(file);
EvaluationResult result = createEvaluationResult(condition, "simpledependency");
assertNoViolation(result);
}
use of com.tngtech.archunit.lang.EvaluationResult in project ArchUnit by TNG.
the class PlantUmlArchConditionTest method assertConditionHasNumberOfFailures.
private void assertConditionHasNumberOfFailures(JavaClasses classes, PlantUmlArchCondition condition, int expectedNumberOfFailures) {
EvaluationResult result = classes().should(condition).evaluate(classes);
assertThat(result.getFailureReport().getDetails()).as("number of failures").hasSize(expectedNumberOfFailures);
}
use of com.tngtech.archunit.lang.EvaluationResult in project ArchUnit by TNG.
the class MethodsShouldTest method property_predicates.
@Test
@UseDataProvider("restricted_property_rule_ends")
public void property_predicates(ArchRule ruleStart, Collection<String> expectedMembers) {
EvaluationResult result = ruleStart.evaluate(importClasses(ClassWithVariousMembers.class));
Set<String> actualMethods = parseMembers(ClassWithVariousMembers.class, result.getFailureReport().getDetails());
assertThat(actualMethods).containsOnlyElementsOf(expectedMembers);
}
use of com.tngtech.archunit.lang.EvaluationResult in project ArchUnit by TNG.
the class ClassesShouldTest method haveSimpleNameEndingWith.
@Test
@UseDataProvider("haveSimpleNameEndingWith_rules")
public void haveSimpleNameEndingWith(ArchRule rule, String suffix) {
EvaluationResult result = rule.evaluate(importClasses(SomeClass.class, WrongNamedClass.class));
assertThat(singleLineFailureReportOf(result)).contains(String.format("classes should have simple name ending with '%s'", suffix)).containsPattern(String.format("simple name of %s does not end with '%s' in %s", quote(WrongNamedClass.class.getName()), quote(suffix), locationPattern(WrongNamedClass.class))).doesNotContain(SomeClass.class.getName());
}
Aggregations