use of com.tngtech.archunit.lang.ConditionEvents in project ArchUnit by TNG.
the class JavaAccessConditionTest method assertThatOnlyAccessToSomeClassFor.
private ConditionEventsAssertion assertThatOnlyAccessToSomeClassFor(JavaClass clazz, JavaAccessCondition<JavaAccess<?>> condition) {
Set<JavaAccess<?>> accesses = filterByTarget(clazz.getAccessesFromSelf(), SomeClass.class);
ConditionEvents events = new ConditionEvents();
for (JavaAccess<?> access : accesses) {
condition.check(access, events);
}
return assertThat(events);
}
use of com.tngtech.archunit.lang.ConditionEvents in project ArchUnit by TNG.
the class ClassAccessesFieldConditionTest method condition_works.
@Theory
public void condition_works(PositiveTestCase testCase) {
ConditionEvents events = new ConditionEvents();
testCase.condition.check(CALLER_CLASS, events);
assertThat(events).containNoViolation();
}
use of com.tngtech.archunit.lang.ConditionEvents in project ArchUnit by TNG.
the class ClassCallsCodeUnitConditionTest method call_with_wrong_method_name_doesnt_match.
@Test
public void call_with_wrong_method_name_doesnt_match() {
ConditionEvents events = checkCondition(callMethodWhere(target(name("wrong")).and(target(rawParameterTypes(TargetClass.appendStringParams))).and(target(owner(type(TargetClass.class))))));
assertThat(events).haveOneViolationMessageContaining(VIOLATION_MESSAGE_PARTS);
}
use of com.tngtech.archunit.lang.ConditionEvents in project ArchUnit by TNG.
the class ClassCallsCodeUnitConditionTest method call_without_argument_doesnt_match.
@Test
public void call_without_argument_doesnt_match() {
ConditionEvents events = checkCondition(callMethodWhere(target(rawParameterTypes(new Class[0])).and(target(name(TargetClass.appendStringMethod)).and(target(owner(type(TargetClass.class)))))));
assertThat(events).haveOneViolationMessageContaining(VIOLATION_MESSAGE_PARTS);
}
use of com.tngtech.archunit.lang.ConditionEvents in project ArchUnit by TNG.
the class ContainsOnlyConditionTest method inverting_works.
@Test
public void inverting_works() throws Exception {
ConditionEvents events = new ConditionEvents();
containOnlyElementsThat(IS_SERIALIZABLE).check(TWO_SERIALIZABLE_OBJECTS, events);
assertThat(events).containNoViolation();
assertThat(events.getAllowed()).as("Exactly one allowed event occurred").hasSize(1);
assertThat(getInverted(events)).containViolations(messageForTwoTimes(isSerializableMessageFor(SerializableObject.class)));
}
Aggregations