use of com.tngtech.archunit.core.importer.testexamples.innerclassimport.ClassWithInnerClass in project ArchUnit by TNG.
the class ClassFileImporterTest method imports_enclosing_classes.
@Test
public void imports_enclosing_classes() {
JavaClasses classes = new ClassFileImporter().importUrl(getClass().getResource("testexamples/innerclassimport"));
JavaClass classWithInnerClass = classes.get(ClassWithInnerClass.class);
JavaClass innerClass = classes.get(ClassWithInnerClass.Inner.class);
JavaClass anonymousClass = classes.get(ClassWithInnerClass.class.getName() + "$1");
JavaClass localClass = classes.get(ClassWithInnerClass.class.getName() + "$1LocalCaller");
JavaMethod calledTarget = getOnlyElement(classes.get(CalledClass.class).getMethods());
assertThat(innerClass.getEnclosingClass()).contains(classWithInnerClass);
assertThat(anonymousClass.getEnclosingClass()).contains(classWithInnerClass);
assertThat(localClass.getEnclosingClass()).contains(classWithInnerClass);
JavaMethodCall call = getOnlyElement(innerClass.getCodeUnitWithParameterTypes("call").getMethodCallsFromSelf());
assertThatCall(call).isFrom("call").isTo(calledTarget).inLineNumber(31);
call = getOnlyElement(anonymousClass.getCodeUnitWithParameterTypes("call").getMethodCallsFromSelf());
assertThatCall(call).isFrom("call").isTo(calledTarget).inLineNumber(11);
call = getOnlyElement(localClass.getCodeUnitWithParameterTypes("call").getMethodCallsFromSelf());
assertThatCall(call).isFrom("call").isTo(calledTarget).inLineNumber(21);
}
Aggregations