use of com.tngtech.archunit.lang.EvaluationResult in project ArchUnit by TNG.
the class ClassesShouldTest method notVisibility.
@Test
@UseDataProvider("not_visibility_rules")
public void notVisibility(ArchRule rule, JavaModifier modifier, Class<?> satisfied, Class<?> violated) {
EvaluationResult result = rule.evaluate(importClasses(satisfied, violated));
assertThat(singleLineFailureReportOf(result)).contains(String.format("classes should not be %s", modifier.name().toLowerCase())).containsPattern(String.format("Class <%s> .* modifier %s", quote(violated.getName()), modifier)).doesNotMatch(String.format(".*<%s>.* modifier %s.*", quote(satisfied.getName()), modifier));
}
use of com.tngtech.archunit.lang.EvaluationResult in project ArchUnit by TNG.
the class ClassesShouldTest method implement_satisfied.
@Test
@UseDataProvider("implement_satisfied_rules")
public void implement_satisfied(ArchRule rule, Class<?> satisfied) {
EvaluationResult result = rule.evaluate(importHierarchies(satisfied));
assertThat(singleLineFailureReportOf(result)).doesNotMatch(String.format(".*%s.* implement.*", quote(satisfied.getName())));
}
use of com.tngtech.archunit.lang.EvaluationResult in project ArchUnit by TNG.
the class ClassesShouldTest method resideInAPackage.
@Test
@UseDataProvider("resideInAPackage_rules")
public void resideInAPackage(ArchRule rule, String packageIdentifier) {
checkTestStillValid(packageIdentifier, ImmutableSet.of(ArchRule.class, ArchCondition.class), ImmutableSet.<Class<?>>of(ArchConfiguration.class), ImmutableSet.<Class<?>>of(GivenObjects.class));
EvaluationResult result = rule.evaluate(importClasses(ArchRule.class, ArchCondition.class, ArchConfiguration.class, GivenObjects.class));
assertThat(singleLineFailureReportOf(result)).contains(String.format("classes should reside in a package '%s'", packageIdentifier)).containsPattern(doesntResideInAPackagePatternFor(ArchConfiguration.class, packageIdentifier)).containsPattern(doesntResideInAPackagePatternFor(GivenObjects.class, packageIdentifier)).doesNotContain(String.format("%s", ArchRule.class.getSimpleName())).doesNotContain(String.format("%s", ArchCondition.class.getSimpleName()));
}
use of com.tngtech.archunit.lang.EvaluationResult in project ArchUnit by TNG.
the class ClassesShouldTest method haveFullyQualifiedName.
@Test
@UseDataProvider("haveFullyQualifiedName_rules")
public void haveFullyQualifiedName(ArchRule rule) {
EvaluationResult result = rule.evaluate(importClasses(SomeClass.class, WrongNamedClass.class));
assertThat(singleLineFailureReportOf(result)).contains(String.format("classes should have fully qualified name '%s'", SomeClass.class.getName())).containsPattern(String.format("Class <%s> does not have fully qualified name '%s' in %s", quote(WrongNamedClass.class.getName()), quote(SomeClass.class.getName()), locationPattern(WrongNamedClass.class))).doesNotMatch(String.format(".*<%s>.*name.*", quote(SomeClass.class.getName())));
}
use of com.tngtech.archunit.lang.EvaluationResult in project ArchUnit by TNG.
the class ClassesShouldTest method notHaveFullyQualifiedName.
@Test
@UseDataProvider("notHaveFullyQualifiedName_rules")
public void notHaveFullyQualifiedName(ArchRule rule) {
EvaluationResult result = rule.evaluate(importClasses(SomeClass.class, WrongNamedClass.class));
assertThat(singleLineFailureReportOf(result)).contains(String.format("classes should not have fully qualified name '%s'", WrongNamedClass.class.getName())).contains(String.format("Class <%s> has fully qualified name '%s'", WrongNamedClass.class.getName(), WrongNamedClass.class.getName())).doesNotContain(String.format("<%s>.*name", SomeClass.class.getName()));
}
Aggregations