use of com.tngtech.archunit.lang.EvaluationResult in project ArchUnit by TNG.
the class ClassesShouldTest method assignableTo.
@Test
@UseDataProvider("assignableTo_rules")
public void assignableTo(ArchRule rule, Class<?> satisfied, Class<?> violated) {
EvaluationResult result = rule.evaluate(importClasses(satisfied, violated));
assertThat(singleLineFailureReportOf(result)).contains(String.format("classes should be assignable to %s", Collection.class.getName())).containsPattern(String.format("Class <%s> is not assignable to %s in %s", quote(violated.getName()), quote(Collection.class.getName()), locationPattern(violated))).doesNotMatch(String.format(".*%s.* assignable.*", quote(satisfied.getName())));
}
use of com.tngtech.archunit.lang.EvaluationResult in project ArchUnit by TNG.
the class ClassesShouldTest method notBeLocalClasses.
@Test
@UseDataProvider("notBeLocalClasses_rules")
public void notBeLocalClasses(ArchRule rule, Class<?> satisfied, Class<?> violated) {
EvaluationResult result = rule.evaluate(importClasses(satisfied, violated));
assertThat(singleLineFailureReportOf(result)).contains("classes should not be local classes").containsPattern(String.format("Class <%s> is a local class", quote(violated.getName()))).doesNotMatch(String.format(".*%s.* local class.*", quote(satisfied.getName())));
}
use of com.tngtech.archunit.lang.EvaluationResult in project ArchUnit by TNG.
the class ClassesShouldTest method beMemberClasses.
@Test
@UseDataProvider("beMemberClasses_rules")
public void beMemberClasses(ArchRule rule, Class<?> satisfied, Class<?> violated) {
EvaluationResult result = rule.evaluate(importClasses(satisfied, violated));
assertThat(singleLineFailureReportOf(result)).contains("classes should be member classes").containsPattern(String.format("Class <%s> is not a member class", quote(violated.getName()))).doesNotMatch(String.format(".*%s.* member class.*", quote(satisfied.getName())));
}
use of com.tngtech.archunit.lang.EvaluationResult in project ArchUnit by TNG.
the class ClassesShouldTest method callConstructor.
@Test
@UseDataProvider("callConstructor_rules")
public void callConstructor(ArchRule rule) {
EvaluationResult result = rule.evaluate(importClasses(ClassWithConstructor.class, ClassCallingConstructor.class, ClassCallingWrongConstructor.class));
assertThat(singleLineFailureReportOf(result)).contains(String.format("classes should call constructor %s.<init>(%s)", ClassWithConstructor.class.getSimpleName(), String.class.getSimpleName())).containsPattern(callConstructorRegex(ClassCallingWrongConstructor.class, ClassCallingConstructor.class, int.class, Date.class)).doesNotMatch(callConstructorRegex(ClassCallingConstructor.class, ClassWithConstructor.class, String.class));
}
use of com.tngtech.archunit.lang.EvaluationResult in project ArchUnit by TNG.
the class ClassesShouldTest method notAnnotatedWith.
@Test
@UseDataProvider("notAnnotated_rules")
public void notAnnotatedWith(ArchRule rule, Class<?> correctClass, Class<?> wrongClass) {
EvaluationResult result = rule.evaluate(importClasses(correctClass, wrongClass));
assertThat(singleLineFailureReportOf(result)).contains("classes should not be annotated with @" + RuntimeRetentionAnnotation.class.getSimpleName()).containsPattern(String.format("Class <%s> is annotated with @%s in %s", quote(wrongClass.getName()), RuntimeRetentionAnnotation.class.getSimpleName(), locationPattern(getClass()))).doesNotMatch(String.format(".*<%s>.*annotated.*", quote(correctClass.getName())));
}
Aggregations