use of com.tngtech.archunit.lang.EvaluationResult in project ArchUnit by TNG.
the class ClassesShouldTest method notBeMemberClasses.
@Test
@UseDataProvider("notBeMemberClasses_rules")
public void notBeMemberClasses(ArchRule rule, Class<?> satisfied, Class<?> violated) {
EvaluationResult result = rule.evaluate(importClasses(satisfied, violated));
assertThat(singleLineFailureReportOf(result)).contains("classes should not be member classes").containsPattern(String.format("Class <%s> is 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 beClass.
@Test
@UseDataProvider("beClass_rules")
public void beClass(ArchRule rule, Class<?> satisfied, Class<?> violated) {
EvaluationResult result = rule.evaluate(importClasses(satisfied, violated));
assertThat(singleLineFailureReportOf(result)).contains("classes should be " + satisfied.getName()).containsPattern(String.format("Class <%s> is not %s in %s", quote(violated.getName()), quote(satisfied.getName()), locationPattern(violated))).doesNotMatch(String.format(".*<%s>.* is .*", quote(satisfied.getName())));
}
use of com.tngtech.archunit.lang.EvaluationResult in project ArchUnit by TNG.
the class ClassesShouldTest method notBeNestedClasses.
@Test
@UseDataProvider("notBeNestedClasses_rules")
public void notBeNestedClasses(ArchRule rule, Class<?> satisfied, Class<?> violated) {
EvaluationResult result = rule.evaluate(importClasses(satisfied, violated));
assertThat(singleLineFailureReportOf(result)).contains("classes should not be nested classes").containsPattern(String.format("Class <%s> is 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 metaAnnotatedWith.
@Test
@UseDataProvider("metaAnnotated_rules")
public void metaAnnotatedWith(ArchRule rule, Class<?> correctClass, Class<?> wrongClass) {
EvaluationResult result = rule.evaluate(importClasses(correctClass, wrongClass));
assertThat(singleLineFailureReportOf(result)).contains(String.format("classes should be meta-annotated with @%s", SomeMetaAnnotation.class.getSimpleName())).containsPattern(String.format("Class <%s> is not meta-annotated with @%s in %s", quote(wrongClass.getName()), SomeMetaAnnotation.class.getSimpleName(), locationPattern(String.class))).doesNotMatch(String.format(".*<%s>.*meta-annotated.*", quote(correctClass.getName())));
}
use of com.tngtech.archunit.lang.EvaluationResult in project ArchUnit by TNG.
the class ClassesShouldTest method annotatedWith.
@Test
@UseDataProvider("annotated_rules")
public void annotatedWith(ArchRule rule, Class<?> correctClass, Class<?> wrongClass) {
EvaluationResult result = rule.evaluate(importClasses(correctClass, wrongClass));
assertThat(singleLineFailureReportOf(result)).contains(String.format("classes should be annotated with @%s", RuntimeRetentionAnnotation.class.getSimpleName())).containsPattern(String.format("Class <%s> is not annotated with @%s in %s", quote(wrongClass.getName()), RuntimeRetentionAnnotation.class.getSimpleName(), locationPattern(String.class))).doesNotMatch(String.format(".*<%s>.*annotated.*", quote(correctClass.getName())));
}
Aggregations