use of com.tngtech.archunit.core.domain.TestUtils.AccessesSimulator in project ArchUnit by TNG.
the class ArchConditionsTest method never_call_method_where_target_owner_is_assignable_to.
@Test
public void never_call_method_where_target_owner_is_assignable_to() {
JavaClass callingClass = importClassWithContext(CallingClass.class);
AccessesSimulator simulateCall = simulateCall();
JavaClass someClass = importClassWithContext(SomeClass.class);
JavaMethod doNotCallMe = someClass.getMethod("doNotCallMe");
JavaMethodCall callTodoNotCallMe = simulateCall.from(callingClass.getMethod("call"), 0).to(doNotCallMe);
ArchCondition<JavaClass> condition = never(callMethodWhere(target(name("doNotCallMe")).and(target(owner(assignableTo(SomeSuperclass.class))))));
assertThat(condition).checking(callingClass).containViolations(callTodoNotCallMe.getDescription());
condition = never(callMethodWhere(target(name("doNotCallMe")).and(target(owner(type(SomeSuperclass.class))))));
assertThat(condition).checking(callingClass).containNoViolation();
}
Aggregations