use of com.tngtech.archunit.lang.EvaluationResult in project ArchUnit by TNG.
the class ClassesShouldTest method beNestedClasses.
@Test
@UseDataProvider("beNestedClasses_rules")
public void beNestedClasses(ArchRule rule, Class<?> satisfied, Class<?> violated) {
EvaluationResult result = rule.evaluate(importClasses(satisfied, violated));
assertThat(singleLineFailureReportOf(result)).contains("classes should be nested classes").containsPattern(String.format("Class <%s> is not a nested class", quote(violated.getName()))).doesNotMatch(String.format(".*%s.* nested class.*", quote(satisfied.getName())));
}
use of com.tngtech.archunit.lang.EvaluationResult in project ArchUnit by TNG.
the class ClassesShouldTest method notBeInterfaces.
@Test
@UseDataProvider("notBeInterfaces_rules")
public void notBeInterfaces(ArchRule rule, Class<?> satisfied, Class<?> violated) {
EvaluationResult result = rule.evaluate(importClasses(satisfied, violated));
assertThat(singleLineFailureReportOf(result)).contains("classes should not be interfaces").containsPattern(String.format("Class <%s> is an interface in %s", quote(violated.getName()), locationPattern(violated))).doesNotMatch(String.format(".*%s.* interface.*", quote(satisfied.getName())));
}
use of com.tngtech.archunit.lang.EvaluationResult in project ArchUnit by TNG.
the class ClassesShouldTest method haveSimpleNameContaining.
@Test
@UseDataProvider("haveSimpleNameContaining_rules")
public void haveSimpleNameContaining(ArchRule rule, String infix) {
EvaluationResult result = rule.evaluate(importClasses(SomeClass.class, WrongNamedClass.class));
assertThat(singleLineFailureReportOf(result)).contains(String.format("classes should have simple name containing '%s'", infix)).containsPattern(String.format("simple name of %s does not contain '%s' in %s", quote(WrongNamedClass.class.getName()), quote(infix), locationPattern(WrongNamedClass.class))).doesNotContain(SomeClass.class.getName());
}
use of com.tngtech.archunit.lang.EvaluationResult in project ArchUnit by TNG.
the class ClassesShouldTest method onlyCallMethodsThat.
@Test
@UseDataProvider("onlyCallMethodsThat_rules")
public void onlyCallMethodsThat(ArchRule rule) {
EvaluationResult result = rule.evaluate(importClasses(ClassWithMethod.class, ClassCallingMethod.class, ClassCallingWrongMethod.class));
assertThat(singleLineFailureReportOf(result)).contains(String.format("classes should only call methods that are declared in %s", ClassWithMethod.class.getName())).containsPattern(callMethodRegex(ClassCallingWrongMethod.class, ClassCallingMethod.class, "call")).doesNotMatch(accessesFieldRegex(ClassAccessingWrongFieldMethodAndConstructor.class, "sets", ClassAccessingFieldMethodAndConstructor.class, "wrongField")).doesNotMatch(callMethodRegex(ClassCallingMethod.class, ClassWithMethod.class, "method", String.class));
}
use of com.tngtech.archunit.lang.EvaluationResult in project ArchUnit by TNG.
the class ClassesShouldTest method beInterfaces.
@Test
@UseDataProvider("beInterfaces_rules")
public void beInterfaces(ArchRule rule, Class<?> satisfied, Class<?> violated) {
EvaluationResult result = rule.evaluate(importClasses(satisfied, violated));
assertThat(singleLineFailureReportOf(result)).contains("classes should be interfaces").containsPattern(String.format("Class <%s> is not an interface in %s", quote(violated.getName()), locationPattern(violated))).doesNotMatch(String.format(".*%s.* interface.*", quote(satisfied.getName())));
}
Aggregations