@Test
public void extend_existing_method_fields_are_transformed() throws Exception
{
Logger logger = mockLogger();
TransformMethodSignature sig = new TransformMethodSignature(Modifier.PUBLIC, "int", "getTargetValue", null,
null);
Runnable runnable = mockRunnable();
runnable.run();
replay();
InternalClassTransformation ct = createClassTransformation(MethodPrefixTarget.class, logger);
String name = ct.addInjectedField(Runnable.class, "runnable", runnable);
// Transform the field.
TransformMethodSignature reader = new TransformMethodSignature(Modifier.PRIVATE, "int", "read_target_value",
null, null);
ct.addMethod(reader, "return 66;");
ct.replaceReadAccess("_targetField", "read_target_value");