Skip to content

Commit

Permalink
Fixed further tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
Rafael Winterhalter committed Dec 21, 2015
1 parent c0fe11a commit a0978aa
Show file tree
Hide file tree
Showing 20 changed files with 55 additions and 48 deletions.
Expand Up @@ -142,7 +142,7 @@ protected ByteCodeAppender.Size applySetter(MethodVisitor methodVisitor,
fieldDescription, fieldDescription,
methodDescription, methodDescription,
new StackManipulation.Compound( new StackManipulation.Compound(
MethodVariableAccess.forType(fieldDescription.getType().asErasure()) MethodVariableAccess.of(fieldDescription.getType().asErasure())
.loadOffset(methodDescription.getParameters().get(0).getOffset()), .loadOffset(methodDescription.getParameters().get(0).getOffset()),
stackManipulation, stackManipulation,
FieldAccess.forField(fieldDescription).putter() FieldAccess.forField(fieldDescription).putter()
Expand Down
Expand Up @@ -131,7 +131,7 @@ private List<StackManipulation> argumentValuesOf(MethodDescription instrumentedM
int currentIndex = 1; int currentIndex = 1;
for (TypeDescription parameterType : parameterTypes) { for (TypeDescription parameterType : parameterTypes) {
instruction.add(new StackManipulation.Compound( instruction.add(new StackManipulation.Compound(
MethodVariableAccess.forType(parameterType).loadOffset(currentIndex), MethodVariableAccess.of(parameterType).loadOffset(currentIndex),
assigner.assign(parameterType, TypeDescription.OBJECT, Assigner.Typing.STATIC))); assigner.assign(parameterType, TypeDescription.OBJECT, Assigner.Typing.STATIC)));
currentIndex += parameterType.getStackSize().getSize(); currentIndex += parameterType.getStackSize().getSize();
} }
Expand Down Expand Up @@ -418,7 +418,7 @@ public Size apply(MethodVisitor methodVisitor, Context implementationContext, Me
implementationContext, implementationContext,
instrumentedMethod, instrumentedMethod,
instrumentedType, instrumentedType,
MethodVariableAccess.forType(instrumentedType).loadOffset(0)); MethodVariableAccess.of(instrumentedType).loadOffset(0));
} }


@Override @Override
Expand Down
Expand Up @@ -1765,7 +1765,7 @@ public Resolved resolve(TypeDescription instrumentedType, MethodDescription inst
if (index >= parameters.size()) { if (index >= parameters.size()) {
throw new IllegalStateException("No parameter " + index + " for " + instrumentedMethod); throw new IllegalStateException("No parameter " + index + " for " + instrumentedMethod);
} }
return new Resolved.Simple(MethodVariableAccess.forType(parameters.get(index).getType().asErasure()) return new Resolved.Simple(MethodVariableAccess.of(parameters.get(index).getType().asErasure())
.loadOffset(instrumentedMethod.getParameters().get(index).getOffset()), parameters.get(index).getType().asErasure()); .loadOffset(instrumentedMethod.getParameters().get(index).getOffset()), parameters.get(index).getType().asErasure());
} }


Expand Down Expand Up @@ -1829,7 +1829,7 @@ public Resolved resolve(TypeDescription instrumentedType, MethodDescription inst
if (!stackManipulation.isValid()) { if (!stackManipulation.isValid()) {
throw new IllegalArgumentException("Cannot assign " + parameters.get(index) + " to " + typeDescription); throw new IllegalArgumentException("Cannot assign " + parameters.get(index) + " to " + typeDescription);
} }
return new Resolved.Simple(new StackManipulation.Compound(MethodVariableAccess.forType(parameters.get(index) return new Resolved.Simple(new StackManipulation.Compound(MethodVariableAccess.of(parameters.get(index)
.getType().asErasure()).loadOffset(parameters.get(index).getOffset()), stackManipulation), typeDescription); .getType().asErasure()).loadOffset(parameters.get(index).getOffset()), stackManipulation), typeDescription);
} }


Expand Down
Expand Up @@ -994,7 +994,7 @@ public StackManipulation resolve(TypeDescription instrumentedType,
} }
ParameterDescription parameterDescription = interceptedMethod.getParameters().get(index); ParameterDescription parameterDescription = interceptedMethod.getParameters().get(index);
StackManipulation stackManipulation = new StackManipulation.Compound( StackManipulation stackManipulation = new StackManipulation.Compound(
MethodVariableAccess.forType(parameterDescription.getType().asErasure()).loadOffset(parameterDescription.getOffset()), MethodVariableAccess.of(parameterDescription.getType().asErasure()).loadOffset(parameterDescription.getOffset()),
assigner.assign(parameterDescription.getType().asErasure(), targetType, typing)); assigner.assign(parameterDescription.getType().asErasure(), targetType, typing));
if (!stackManipulation.isValid()) { if (!stackManipulation.isValid()) {
throw new IllegalStateException("Cannot assign " + parameterDescription + " to " + targetType + " for " + interceptedMethod); throw new IllegalStateException("Cannot assign " + parameterDescription + " to " + targetType + " for " + interceptedMethod);
Expand Down
Expand Up @@ -300,7 +300,7 @@ public Size apply(MethodVisitor methodVisitor, Context implementationContext, Me
for (FieldDescription fieldDescription : fieldList) { for (FieldDescription fieldDescription : fieldList) {
fieldLoading[index] = new StackManipulation.Compound( fieldLoading[index] = new StackManipulation.Compound(
thisReference, thisReference,
MethodVariableAccess.forType(fieldDescription.getType().asErasure()) MethodVariableAccess.of(fieldDescription.getType().asErasure())
.loadOffset(instrumentedMethod.getParameters().get(index).getOffset()), .loadOffset(instrumentedMethod.getParameters().get(index).getOffset()),
FieldAccess.forField(fieldDescription).putter() FieldAccess.forField(fieldDescription).putter()
); );
Expand Down Expand Up @@ -412,7 +412,7 @@ private Appender(TypeDescription instrumentedType) {
public Size apply(MethodVisitor methodVisitor, public Size apply(MethodVisitor methodVisitor,
Context implementationContext, Context implementationContext,
MethodDescription instrumentedMethod) { MethodDescription instrumentedMethod) {
StackManipulation thisReference = MethodVariableAccess.forType(instrumentedType).loadOffset(0); StackManipulation thisReference = MethodVariableAccess.of(instrumentedType).loadOffset(0);
FieldList<?> fieldList = instrumentedType.getDeclaredFields(); FieldList<?> fieldList = instrumentedType.getDeclaredFields();
StackManipulation[] fieldLoading = new StackManipulation[fieldList.size()]; StackManipulation[] fieldLoading = new StackManipulation[fieldList.size()];
int index = 0; int index = 0;
Expand Down
Expand Up @@ -486,7 +486,7 @@ public Size apply(MethodVisitor methodVisitor, Implementation.Context implementa
MethodInvocation.invoke(proxyType.getDeclaredMethods() MethodInvocation.invoke(proxyType.getDeclaredMethods()
.filter(isConstructor().and(takesArguments(constructorParameters))).getOnly()), .filter(isConstructor().and(takesArguments(constructorParameters))).getOnly()),
Duplication.SINGLE, Duplication.SINGLE,
MethodVariableAccess.forType(implementationTarget.getInstrumentedType()).loadOffset(0), MethodVariableAccess.of(implementationTarget.getInstrumentedType()).loadOffset(0),
FieldAccess.forField(proxyType.getDeclaredFields() FieldAccess.forField(proxyType.getDeclaredFields()
.filter((ElementMatchers.named(INSTANCE_FIELD))).getOnly()).putter() .filter((ElementMatchers.named(INSTANCE_FIELD))).getOnly()).putter()
).apply(methodVisitor, implementationContext); ).apply(methodVisitor, implementationContext);
Expand Down Expand Up @@ -589,7 +589,7 @@ public Size apply(MethodVisitor methodVisitor, Implementation.Context implementa
MethodInvocation.invoke(proxyType.getDeclaredMethods() MethodInvocation.invoke(proxyType.getDeclaredMethods()
.filter(named(REFLECTION_METHOD).and(takesArguments(0))).getOnly()), .filter(named(REFLECTION_METHOD).and(takesArguments(0))).getOnly()),
Duplication.SINGLE, Duplication.SINGLE,
MethodVariableAccess.forType(implementationTarget.getInstrumentedType()).loadOffset(0), MethodVariableAccess.of(implementationTarget.getInstrumentedType()).loadOffset(0),
FieldAccess.forField(proxyType.getDeclaredFields() FieldAccess.forField(proxyType.getDeclaredFields()
.filter((named(INSTANCE_FIELD))).getOnly()).putter() .filter((named(INSTANCE_FIELD))).getOnly()).putter()
).apply(methodVisitor, implementationContext); ).apply(methodVisitor, implementationContext);
Expand Down Expand Up @@ -680,7 +680,7 @@ public Size apply(MethodVisitor methodVisitor, Implementation.Context implementa
Duplication.SINGLE, Duplication.SINGLE,
MethodInvocation.invoke(proxyType.getDeclaredMethods().filter(isConstructor()).getOnly()), MethodInvocation.invoke(proxyType.getDeclaredMethods().filter(isConstructor()).getOnly()),
Duplication.SINGLE, Duplication.SINGLE,
MethodVariableAccess.forType(implementationTarget.getInstrumentedType()).loadOffset(0), MethodVariableAccess.of(implementationTarget.getInstrumentedType()).loadOffset(0),
FieldAccess.forField(proxyType.getDeclaredFields() FieldAccess.forField(proxyType.getDeclaredFields()
.filter((named(INSTANCE_FIELD))).getOnly()).putter() .filter((named(INSTANCE_FIELD))).getOnly()).putter()
).apply(methodVisitor, implementationContext); ).apply(methodVisitor, implementationContext);
Expand Down
Expand Up @@ -143,7 +143,7 @@ public MethodDelegationBinder.ParameterBinding<?> bind(AnnotationDescription.Loa
? join(implementationTarget.getInstrumentedType(), source.getParameters().asTypeList().asErasures()) ? join(implementationTarget.getInstrumentedType(), source.getParameters().asTypeList().asErasures())
: source.getParameters().asTypeList().asErasures()) { : source.getParameters().asTypeList().asErasures()) {
StackManipulation stackManipulation = new StackManipulation.Compound( StackManipulation stackManipulation = new StackManipulation.Compound(
MethodVariableAccess.forType(sourceParameter).loadOffset(offset), MethodVariableAccess.of(sourceParameter).loadOffset(offset),
assigner.assign(sourceParameter, arrayFactory.getComponentType(), RuntimeType.Verifier.check(target))); assigner.assign(sourceParameter, arrayFactory.getComponentType(), RuntimeType.Verifier.check(target)));
if (stackManipulation.isValid()) { if (stackManipulation.isValid()) {
stackManipulations.add(stackManipulation); stackManipulations.add(stackManipulation);
Expand Down
Expand Up @@ -80,7 +80,7 @@ protected MethodDelegationBinder.ParameterBinding<?> makeBinding(TypeDescription
int parameterOffset) { int parameterOffset) {
return MethodDelegationBinder.ParameterBinding.Unique.of( return MethodDelegationBinder.ParameterBinding.Unique.of(
new StackManipulation.Compound( new StackManipulation.Compound(
MethodVariableAccess.forType(sourceType).loadOffset(parameterOffset), MethodVariableAccess.of(sourceType).loadOffset(parameterOffset),
assigner.assign(sourceType, targetType, typing)), assigner.assign(sourceType, targetType, typing)),
new ArgumentTypeResolver.ParameterIndexToken(sourceParameterIndex) new ArgumentTypeResolver.ParameterIndexToken(sourceParameterIndex)
); );
Expand All @@ -100,7 +100,7 @@ protected MethodDelegationBinder.ParameterBinding<?> makeBinding(TypeDescription
int parameterOffset) { int parameterOffset) {
return new MethodDelegationBinder.ParameterBinding.Anonymous( return new MethodDelegationBinder.ParameterBinding.Anonymous(
new StackManipulation.Compound( new StackManipulation.Compound(
MethodVariableAccess.forType(sourceType).loadOffset(parameterOffset), MethodVariableAccess.of(sourceType).loadOffset(parameterOffset),
assigner.assign(sourceType, targetType, typing)) assigner.assign(sourceType, targetType, typing))
); );
} }
Expand Down
Expand Up @@ -617,7 +617,7 @@ public Size apply(MethodVisitor methodVisitor,
MethodVariableAccess.REFERENCE.loadOffset(0), MethodVariableAccess.REFERENCE.loadOffset(0),
FieldAccess.forField(typeDescription.getDeclaredFields() FieldAccess.forField(typeDescription.getDeclaredFields()
.filter((named(AccessorProxy.FIELD_NAME))).getOnly()).getter()), .filter((named(AccessorProxy.FIELD_NAME))).getOnly()).getter()),
MethodVariableAccess.forType(parameterType).loadOffset(1), MethodVariableAccess.of(parameterType).loadOffset(1),
assigner.assign(parameterType, setterMethod.getParameters().get(0).getType().asErasure(), Assigner.Typing.DYNAMIC), assigner.assign(parameterType, setterMethod.getParameters().get(0).getType().asErasure(), Assigner.Typing.DYNAMIC),
MethodInvocation.invoke(setterMethod), MethodInvocation.invoke(setterMethod),
MethodReturn.VOID MethodReturn.VOID
Expand Down
Expand Up @@ -424,7 +424,7 @@ public Size apply(MethodVisitor methodVisitor, Context implementationContext, Me
for (FieldDescription fieldDescription : fieldList) { for (FieldDescription fieldDescription : fieldList) {
fieldLoading[index] = new StackManipulation.Compound( fieldLoading[index] = new StackManipulation.Compound(
thisReference, thisReference,
MethodVariableAccess.forType(fieldDescription.getType().asErasure()) MethodVariableAccess.of(fieldDescription.getType().asErasure())
.loadOffset(instrumentedMethod.getParameters().get(index).getOffset()), .loadOffset(instrumentedMethod.getParameters().get(index).getOffset()),
FieldAccess.forField(fieldDescription).putter() FieldAccess.forField(fieldDescription).putter()
); );
Expand Down Expand Up @@ -539,7 +539,7 @@ private Appender(TypeDescription instrumentedType) {
public Size apply(MethodVisitor methodVisitor, public Size apply(MethodVisitor methodVisitor,
Context implementationContext, Context implementationContext,
MethodDescription instrumentedMethod) { MethodDescription instrumentedMethod) {
StackManipulation thisReference = MethodVariableAccess.forType(instrumentedType).loadOffset(0); StackManipulation thisReference = MethodVariableAccess.of(instrumentedType).loadOffset(0);
FieldList<?> fieldList = instrumentedType.getDeclaredFields(); FieldList<?> fieldList = instrumentedType.getDeclaredFields();
StackManipulation[] fieldLoading = new StackManipulation[fieldList.size()]; StackManipulation[] fieldLoading = new StackManipulation[fieldList.size()];
int index = 0; int index = 0;
Expand Down
Expand Up @@ -70,7 +70,7 @@ public enum MethodVariableAccess {
* @param typeDescription The type of the variable to be loaded. * @param typeDescription The type of the variable to be loaded.
* @return An accessor for the given type. * @return An accessor for the given type.
*/ */
public static MethodVariableAccess forType(TypeDescription typeDescription) { public static MethodVariableAccess of(TypeDescription typeDescription) {
if (typeDescription.isPrimitive()) { if (typeDescription.isPrimitive()) {
if (typeDescription.represents(long.class)) { if (typeDescription.represents(long.class)) {
return LONG; return LONG;
Expand Down Expand Up @@ -149,10 +149,10 @@ public boolean isValid() {


@Override @Override
public Size apply(MethodVisitor methodVisitor, Implementation.Context implementationContext) { public Size apply(MethodVisitor methodVisitor, Implementation.Context implementationContext) {
List<StackManipulation> stackManipulations = new ArrayList<StackManipulation>(methodDescription.getParameters().size() * 2); List<StackManipulation> stackManipulations = new ArrayList<StackManipulation>();
for (ParameterDescription parameterDescription : methodDescription.getParameters()) { for (ParameterDescription parameterDescription : methodDescription.getParameters()) {
TypeDescription parameterType = parameterDescription.getType().asErasure(); TypeDescription parameterType = parameterDescription.getType().asErasure();
stackManipulations.add(forType(parameterType).loadOffset(parameterDescription.getOffset())); stackManipulations.add(of(parameterType).loadOffset(parameterDescription.getOffset()));
stackManipulations.add(typeCastingHandler.ofIndex(parameterType, parameterDescription.getIndex())); stackManipulations.add(typeCastingHandler.ofIndex(parameterType, parameterDescription.getIndex()));
} }
return new Compound(stackManipulations).apply(methodVisitor, implementationContext); return new Compound(stackManipulations).apply(methodVisitor, implementationContext);
Expand Down
Expand Up @@ -28,6 +28,9 @@ public class FieldValueBinderTest extends AbstractAnnotationBinderTest<FieldValu
@Mock @Mock
private GenericTypeDescription fieldType, targetType; private GenericTypeDescription fieldType, targetType;


@Mock
private TypeDescription rawFieldType;

public FieldValueBinderTest() { public FieldValueBinderTest() {
super(FieldValue.class); super(FieldValue.class);
} }
Expand All @@ -39,6 +42,7 @@ public void setUp() throws Exception {
when(fieldDescription.asDefined()).thenReturn(fieldDescription); when(fieldDescription.asDefined()).thenReturn(fieldDescription);
when(fieldDescription.getType()).thenReturn(fieldType); when(fieldDescription.getType()).thenReturn(fieldType);
when(target.getType()).thenReturn(targetType); when(target.getType()).thenReturn(targetType);
when(fieldType.asErasure()).thenReturn(rawFieldType);
} }


@Override @Override
Expand All @@ -65,12 +69,11 @@ public void testFieldOfInterfaceThrowsException() throws Exception {
} }


@Test @Test
@SuppressWarnings("unchecked")
public void testLegalAssignment() throws Exception { public void testLegalAssignment() throws Exception {
doReturn(void.class).when(annotation).definingType(); doReturn(void.class).when(annotation).definingType();
when(annotation.value()).thenReturn(FOO); when(annotation.value()).thenReturn(FOO);
when(instrumentedType.getDeclaredFields()) when(instrumentedType.getDeclaredFields())
.thenReturn((FieldList) new FieldList.Explicit<FieldDescription>(Collections.singletonList(fieldDescription))); .thenReturn(new FieldList.Explicit<FieldDescription.InDefinedShape>(Collections.singletonList(fieldDescription)));
when(fieldDescription.getSourceCodeName()).thenReturn(FOO); when(fieldDescription.getSourceCodeName()).thenReturn(FOO);
when(fieldDescription.isVisibleTo(instrumentedType)).thenReturn(true); when(fieldDescription.isVisibleTo(instrumentedType)).thenReturn(true);
when(target.getDeclaredAnnotations()).thenReturn(new AnnotationList.Empty()); when(target.getDeclaredAnnotations()).thenReturn(new AnnotationList.Empty());
Expand All @@ -84,12 +87,11 @@ public void testLegalAssignment() throws Exception {
} }


@Test @Test
@SuppressWarnings("unchecked")
public void testIllegalAssignmentNonAssignable() throws Exception { public void testIllegalAssignmentNonAssignable() throws Exception {
doReturn(void.class).when(annotation).definingType(); doReturn(void.class).when(annotation).definingType();
when(annotation.value()).thenReturn(FOO); when(annotation.value()).thenReturn(FOO);
when(instrumentedType.getDeclaredFields()) when(instrumentedType.getDeclaredFields())
.thenReturn((FieldList) new FieldList.Explicit<FieldDescription>(Collections.singletonList(fieldDescription))); .thenReturn(new FieldList.Explicit<FieldDescription.InDefinedShape>(Collections.singletonList(fieldDescription)));
when(fieldDescription.getSourceCodeName()).thenReturn(FOO); when(fieldDescription.getSourceCodeName()).thenReturn(FOO);
when(fieldDescription.isVisibleTo(instrumentedType)).thenReturn(true); when(fieldDescription.isVisibleTo(instrumentedType)).thenReturn(true);
when(target.getDeclaredAnnotations()).thenReturn(new AnnotationList.Empty()); when(target.getDeclaredAnnotations()).thenReturn(new AnnotationList.Empty());
Expand All @@ -103,12 +105,11 @@ public void testIllegalAssignmentNonAssignable() throws Exception {
} }


@Test @Test
@SuppressWarnings("unchecked")
public void testIllegalAssignmentStaticMethod() throws Exception { public void testIllegalAssignmentStaticMethod() throws Exception {
doReturn(void.class).when(annotation).definingType(); doReturn(void.class).when(annotation).definingType();
when(annotation.value()).thenReturn(FOO); when(annotation.value()).thenReturn(FOO);
when(instrumentedType.getDeclaredFields()) when(instrumentedType.getDeclaredFields())
.thenReturn((FieldList) new FieldList.Explicit<FieldDescription>(Collections.singletonList(fieldDescription))); .thenReturn(new FieldList.Explicit<FieldDescription.InDefinedShape>(Collections.singletonList(fieldDescription)));
when(fieldDescription.getSourceCodeName()).thenReturn(FOO); when(fieldDescription.getSourceCodeName()).thenReturn(FOO);
when(fieldDescription.isVisibleTo(instrumentedType)).thenReturn(true); when(fieldDescription.isVisibleTo(instrumentedType)).thenReturn(true);
when(target.getDeclaredAnnotations()).thenReturn(new AnnotationList.Empty()); when(target.getDeclaredAnnotations()).thenReturn(new AnnotationList.Empty());
Expand All @@ -123,12 +124,11 @@ public void testIllegalAssignmentStaticMethod() throws Exception {
} }


@Test @Test
@SuppressWarnings("unchecked")
public void testLegalAssignmentStaticMethodStaticField() throws Exception { public void testLegalAssignmentStaticMethodStaticField() throws Exception {
doReturn(void.class).when(annotation).definingType(); doReturn(void.class).when(annotation).definingType();
when(annotation.value()).thenReturn(FOO); when(annotation.value()).thenReturn(FOO);
when(instrumentedType.getDeclaredFields()) when(instrumentedType.getDeclaredFields())
.thenReturn((FieldList) new FieldList.Explicit<FieldDescription>(Collections.singletonList(fieldDescription))); .thenReturn(new FieldList.Explicit<FieldDescription.InDefinedShape>(Collections.singletonList(fieldDescription)));
when(fieldDescription.getSourceCodeName()).thenReturn(FOO); when(fieldDescription.getSourceCodeName()).thenReturn(FOO);
when(fieldDescription.isVisibleTo(instrumentedType)).thenReturn(true); when(fieldDescription.isVisibleTo(instrumentedType)).thenReturn(true);
when(target.getDeclaredAnnotations()).thenReturn(new AnnotationList.Empty()); when(target.getDeclaredAnnotations()).thenReturn(new AnnotationList.Empty());
Expand Down
Expand Up @@ -46,7 +46,8 @@ public OriginBinderTest() {
public void setUp() throws Exception { public void setUp() throws Exception {
super.setUp(); super.setUp();
when(target.getType()).thenReturn(genericTargetType); when(target.getType()).thenReturn(genericTargetType);
when(genericTargetType.asErasure()).thenReturn(targetType); // TODO when(targetType.asErasure()).thenReturn(targetType);
when(genericTargetType.asErasure()).thenReturn(targetType);
when(source.asDefined()).thenReturn(methodDescription); when(source.asDefined()).thenReturn(methodDescription);
} }


Expand Down Expand Up @@ -126,8 +127,7 @@ public void testModifierBinding() throws Exception {
@Test @Test
@JavaVersionRule.Enforce(7) @JavaVersionRule.Enforce(7)
public void testMethodHandleBinding() throws Exception { public void testMethodHandleBinding() throws Exception {
targetType = new TypeDescription.ForLoadedType(JavaType.METHOD_HANDLE.load()); when(genericTargetType.asErasure()).thenReturn(new TypeDescription.ForLoadedType(JavaType.METHOD_HANDLE.load()));
when(target.getType()).thenReturn(genericTargetType);
TypeDescription typeDescription = mock(TypeDescription.class); TypeDescription typeDescription = mock(TypeDescription.class);
when(typeDescription.asErasure()).thenReturn(typeDescription); when(typeDescription.asErasure()).thenReturn(typeDescription);
when(methodDescription.getDeclaringType()).thenReturn(typeDescription); when(methodDescription.getDeclaringType()).thenReturn(typeDescription);
Expand All @@ -139,8 +139,7 @@ public void testMethodHandleBinding() throws Exception {
@Test @Test
@JavaVersionRule.Enforce(7) @JavaVersionRule.Enforce(7)
public void testMethodTypeBinding() throws Exception { public void testMethodTypeBinding() throws Exception {
targetType = new TypeDescription.ForLoadedType(JavaType.METHOD_TYPE.load()); when(genericTargetType.asErasure()).thenReturn(new TypeDescription.ForLoadedType(JavaType.METHOD_TYPE.load()));
when(target.getType()).thenReturn(genericTargetType);
when(methodDescription.getDescriptor()).thenReturn(FOO); when(methodDescription.getDescriptor()).thenReturn(FOO);
MethodDelegationBinder.ParameterBinding<?> parameterBinding = Origin.Binder.INSTANCE MethodDelegationBinder.ParameterBinding<?> parameterBinding = Origin.Binder.INSTANCE
.bind(annotationDescription, source, target, implementationTarget, assigner); .bind(annotationDescription, source, target, implementationTarget, assigner);
Expand All @@ -149,7 +148,7 @@ public void testMethodTypeBinding() throws Exception {


@Test(expected = IllegalStateException.class) @Test(expected = IllegalStateException.class)
public void testIllegalBinding() throws Exception { public void testIllegalBinding() throws Exception {
when(targetType.getName()).thenReturn(FOO); when(targetType.getInternalName()).thenReturn(FOO);
when(targetType.getSort()).thenReturn(TypeDefinition.Sort.NON_GENERIC); when(targetType.getSort()).thenReturn(TypeDefinition.Sort.NON_GENERIC);
Origin.Binder.INSTANCE.bind(annotationDescription, source, target, implementationTarget, assigner); Origin.Binder.INSTANCE.bind(annotationDescription, source, target, implementationTarget, assigner);
} }
Expand Down

0 comments on commit a0978aa

Please sign in to comment.