use of com.tngtech.archunit.core.domain.JavaFieldAccess in project ArchUnit by TNG.
the class ClassFileImporterLambdaAccessesTest method imports_field_access_from_lambda_without_parameter.
@Test
public void imports_field_access_from_lambda_without_parameter() {
class Target {
}
@SuppressWarnings("unused")
class Caller {
Target target;
Consumer<Target> call() {
return (target) -> this.target = target;
}
}
JavaClasses classes = new ClassFileImporter().importClasses(Target.class, Caller.class);
JavaFieldAccess access = getOnlyElement(filterOriginByName(classes.get(Caller.class).getFieldAccessesFromSelf(), "call"));
assertThatAccess(access).isFrom("call").isTo(Caller.class, "target");
}
use of com.tngtech.archunit.core.domain.JavaFieldAccess in project ArchUnit by TNG.
the class FieldAccessConditionTest method FieldAccessCondition_satisfied_on_both_get_and_set_field.
@Test
public void FieldAccessCondition_satisfied_on_both_get_and_set_field() {
JavaFieldAccess setAccess = accessFromCallerToTargetWithType(SET);
FieldAccessCondition setFieldCondition = new FieldAccessCondition(target(name(setAccess.getTarget().getName())));
assertSatisfiedWithMessage(setFieldCondition, setAccess, "sets");
JavaFieldAccess getAccess = accessFromCallerToTargetWithType(GET);
setFieldCondition = new FieldAccessCondition(target(name(getAccess.getTarget().getName())));
assertSatisfiedWithMessage(setFieldCondition, getAccess, "gets");
}
Aggregations