use of com.tngtech.archunit.lang.EvaluationResult in project jmolecules-integrations by xmolecules.
the class JMoleculesOnionSimpleArchitectureRulesTest method ensureOnionSimple.
@ArchTest
void ensureOnionSimple(JavaClasses types) {
EvaluationResult result = JMoleculesArchitectureRules.ensureOnionSimple().evaluate(types);
//
assertThat(result.getFailureReport().getDetails()).satisfiesExactlyInAnyOrder(//
violation(AppType.class, InfraType.class), //
violation(AppType.class, InfraByAnnotation.class), //
violation(DomainType.class, AppType.class), //
violation(DomainType.class, AppByAnnotation.class), //
violation(DomainType.class, InfraType.class), //
violation(DomainType.class, InfraByAnnotation.class));
}
use of com.tngtech.archunit.lang.EvaluationResult in project ArchUnit by TNG.
the class GivenCodeUnitsTest method types_match_for_constructors.
@Test
public void types_match_for_constructors() {
EvaluationResult result = constructors().that(new DescribedPredicate<JavaMember>("are there") {
@Override
public boolean test(JavaMember input) {
return true;
}
}).and(new DescribedPredicate<JavaConstructor>("are there") {
@Override
public boolean test(JavaConstructor input) {
return true;
}
}).should(new ArchCondition<JavaConstructor>("not exist") {
@Override
public void check(JavaConstructor constructor, ConditionEvents events) {
events.add(SimpleConditionEvent.violated(constructor, "expected violation"));
}
}).evaluate(importClasses(ClassWithVariousMembers.class));
assertThat(Joiner.on(" ").join(result.getFailureReport().getDetails())).contains("expected violation");
}
use of com.tngtech.archunit.lang.EvaluationResult in project ArchUnit by TNG.
the class GivenCodeUnitsTest method parameter_types_predicates.
@Test
@UseDataProvider("restricted_parameter_types_rule_starts")
public void parameter_types_predicates(DescribedRuleStart ruleStart, Collection<String> expectedMembers) {
EvaluationResult result = ruleStart.should(everythingViolationPrintMemberName()).evaluate(importClasses(ClassWithVariousMembers.class));
assertThat(result.getFailureReport().getDetails()).containsOnlyElementsOf(expectedMembers);
}
use of com.tngtech.archunit.lang.EvaluationResult in project ArchUnit by TNG.
the class GivenCodeUnitsTest method complex_code_unit_syntax.
@Test
public void complex_code_unit_syntax() {
EvaluationResult result = codeUnits().that().areNotPackagePrivate().and().haveRawParameterTypes(lessThanTwo()).or(have(modifier(PUBLIC))).should(beAnnotatedWith(A.class)).evaluate(importClasses(ClassWithVariousMembers.class));
assertViolation(result);
assertThat(result.getFailureReport().getDetails()).containsOnly(String.format("Member '%s' is not annotated with @A", METHOD_ONE_ARG), String.format("Member '%s' is not annotated with @A", METHOD_THREE_ARGS), String.format("Member '%s' is not annotated with @A", CONSTRUCTOR_ONE_ARG), String.format("Member '%s' is not annotated with @A", CONSTRUCTOR_THREE_ARGS));
}
use of com.tngtech.archunit.lang.EvaluationResult in project ArchUnit by TNG.
the class GivenFieldsTest method property_predicates.
@Test
@UseDataProvider("restricted_property_rule_starts")
public void property_predicates(DescribedRuleStart ruleStart, Collection<String> expectedMembers) {
EvaluationResult result = ruleStart.should(everythingViolationPrintMemberName()).evaluate(importClasses(ClassWithVariousMembers.class));
assertThat(result.getFailureReport().getDetails()).containsOnlyElementsOf(expectedMembers);
}
Aggregations