use of com.tngtech.archunit.lang.EvaluationResult in project ArchUnit by TNG.
the class ClassesShouldTest method notBeEnums.
@Test
@UseDataProvider("notBeEnums_rules")
public void notBeEnums(ArchRule rule, Class<?> satisfied, Class<?> violated) {
EvaluationResult result = rule.evaluate(importClasses(satisfied, violated));
assertThat(singleLineFailureReportOf(result)).contains("classes should not be enums").containsPattern(String.format("Class <%s> is an enum in %s", quote(violated.getName()), locationPattern(violated))).doesNotMatch(String.format(".*%s.* enum.*", quote(satisfied.getName())));
}
use of com.tngtech.archunit.lang.EvaluationResult in project ArchUnit by TNG.
the class ClassesShouldTest method notAssignableFrom.
@Test
@UseDataProvider("notAssignableFrom_rules")
public void notAssignableFrom(ArchRule rule, Class<?> satisfied, Class<?> violated) {
EvaluationResult result = rule.evaluate(importClasses(satisfied, violated));
assertThat(singleLineFailureReportOf(result)).contains(String.format("classes should not be assignable from %s", List.class.getName())).containsPattern(String.format("Class <%s> is assignable from %s in %s", quote(violated.getName()), quote(List.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 haveSimpleNameNotContaining.
@Test
@UseDataProvider("haveSimpleNameNotContaining_rules")
public void haveSimpleNameNotContaining(ArchRule rule, String infix) {
EvaluationResult result = rule.evaluate(importClasses(SomeClass.class, WrongNamedClass.class));
assertThat(singleLineFailureReportOf(result)).contains(String.format("classes should have simple name not containing '%s'", infix)).containsPattern(String.format("simple name of %s contains '%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 modifiers.
@Test
@UseDataProvider("modifiers_rules")
public void modifiers(ArchRule rule, String havePrefix, JavaModifier modifier, Class<?> satisfied, Class<?> violated) {
EvaluationResult result = rule.evaluate(importClasses(satisfied, violated));
assertThat(singleLineFailureReportOf(result)).contains(String.format("classes should %shave modifier %s", havePrefix, modifier.name())).containsPattern(String.format("Class <%s> .* modifier %s in %s", quote(violated.getName()), modifier, // -> location == enclosingClass()
locationPattern(getClass()))).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 haveNameMatching.
@Test
@UseDataProvider("haveNameMatching_rules")
public void haveNameMatching(ArchRule rule, String regex) {
EvaluationResult result = rule.evaluate(importClasses(SomeClass.class, WrongNamedClass.class));
assertThat(singleLineFailureReportOf(result)).contains(String.format("classes should have name matching '%s'", regex)).containsPattern(String.format("Class <%s> does not match '%s' in %s", quote(WrongNamedClass.class.getName()), quote(regex), locationPattern(WrongNamedClass.class))).doesNotContain(String.format("%s", SomeClass.class.getSimpleName()));
}
Aggregations