use of com.tngtech.archunit.core.domain.JavaConstructor.CONSTRUCTOR_NAME in project ArchUnit by TNG.
the class ClassFileImporterLambdaAccessesTest method imports_complex_combination_of_lambda_accesses_to_nested_class.
@Test
public void imports_complex_combination_of_lambda_accesses_to_nested_class() {
@SuppressWarnings("unused")
class Caller {
private Target target;
void call() {
Supplier<Supplier<Supplier<Target>>> quiteNestedConstructorCallSupplier = () -> () -> Target::new;
Function<String, Supplier<Supplier<Supplier<Target>>>> quiteNestedMethodCallSupplier = s -> () -> () -> () -> target.inner.method(s);
Supplier<Supplier<Supplier<String>>> quiteNestedFieldSupplier = () -> () -> () -> target.inner.field;
}
class Target {
final Inner inner = new Inner();
class Inner {
String field;
Target method(String s) {
return Target.this;
}
}
}
}
JavaClasses classes = new ClassFileImporter().importClasses(Caller.class, Caller.Target.class);
Set<JavaAccess<?>> accesses = classes.get(Caller.class).getAccessesFromSelf();
assertThatAccesses(accesses).contain(access().fromOrigin(Caller.class, "call").toTarget(Caller.Target.class, CONSTRUCTOR_NAME)).contain(access().fromOrigin(Caller.class, "call").toTarget(Caller.Target.Inner.class, "method")).contain(access().fromOrigin(Caller.class, "call").toTarget(Caller.Target.Inner.class, "field"));
}
Aggregations