use of com.tngtech.archunit.lang.ConditionEvents in project ArchUnit by TNG.
the class GivenCodeUnitsTest method types_match_for_methods.
@Test
public void types_match_for_methods() {
EvaluationResult result = methods().that(new DescribedPredicate<JavaMember>("are there") {
@Override
public boolean test(JavaMember input) {
return true;
}
}).and(new DescribedPredicate<JavaMethod>("are there") {
@Override
public boolean test(JavaMethod input) {
return true;
}
}).should(new ArchCondition<JavaMethod>("not exist") {
@Override
public void check(JavaMethod method, ConditionEvents events) {
events.add(SimpleConditionEvent.violated(method, "expected violation"));
}
}).evaluate(importClasses(ClassWithVariousMembers.class));
assertThat(Joiner.on(" ").join(result.getFailureReport().getDetails())).contains("expected violation");
}
use of com.tngtech.archunit.lang.ConditionEvents in project ArchUnit by TNG.
the class ArchConditionAssertion method checking.
public ConditionEventsAssertion checking(T item) {
ConditionEvents events = new ConditionEvents();
actual.check(item, events);
return assertThat(events);
}
use of com.tngtech.archunit.lang.ConditionEvents in project ArchUnit by TNG.
the class NeverCondition method finish.
@Override
public void finish(ConditionEvents events) {
ConditionEvents subEvents = new ConditionEvents();
condition.finish(subEvents);
for (ConditionEvent event : subEvents) {
event.addInvertedTo(events);
}
}
use of com.tngtech.archunit.lang.ConditionEvents in project ArchUnit by TNG.
the class ConditionEventsAssertion method newAbstractIterableAssert.
@Override
protected ConditionEventsAssertion newAbstractIterableAssert(Iterable<? extends ConditionEvent> iterable) {
ConditionEvents actual = new ConditionEvents();
iterable.forEach(actual::add);
return new ConditionEventsAssertion(actual);
}
use of com.tngtech.archunit.lang.ConditionEvents in project ArchUnit by TNG.
the class FieldAccessConditionTest method assertSatisfiedWithMessage.
private void assertSatisfiedWithMessage(FieldAccessCondition getFieldCondition, JavaFieldAccess access, String accessDescription) {
ConditionEvents events = checkCondition(getFieldCondition, access);
boolean satisfied = !events.containViolation();
assertThat(satisfied).as("Events are satisfied").isTrue();
assertThat(events.getViolating()).isEmpty();
assertDescription(access, accessDescription, messageOf(events.getAllowed()));
}
Aggregations