Search in sources :

Example 6 with MethodDelegationBinder

use of net.bytebuddy.implementation.bind.MethodDelegationBinder in project byte-buddy by raphw.

the class TargetMethodAnnotationDrivenBinderTest method testTerminationBinderMismatch.

@Test
public void testTerminationBinderMismatch() throws Exception {
    when(targetMethod.isAccessibleTo(instrumentedType)).thenReturn(true);
    when(assignmentBinding.isValid()).thenReturn(false);
    when(methodInvocation.isValid()).thenReturn(true);
    when(termination.isValid()).thenReturn(false);
    when(targetMethod.getDeclaredAnnotations()).thenReturn(new AnnotationList.Empty());
    when(firstParameter.getDeclaredAnnotations()).thenReturn(new AnnotationList.Empty());
    when(secondParameter.getDeclaredAnnotations()).thenReturn(new AnnotationList.Empty());
    MethodDelegationBinder methodDelegationBinder = TargetMethodAnnotationDrivenBinder.of(Collections.<TargetMethodAnnotationDrivenBinder.ParameterBinder<?>>emptyList());
    assertThat(methodDelegationBinder.compile(targetMethod).bind(implementationTarget, sourceMethod, terminationHandler, methodInvoker, assigner).isValid(), is(false));
    verify(terminationHandler).resolve(assigner, typing, sourceMethod, targetMethod);
    verifyNoMoreInteractions(terminationHandler);
    verifyZeroInteractions(assigner);
    verifyZeroInteractions(methodInvoker);
}
Also used : MethodDelegationBinder(net.bytebuddy.implementation.bind.MethodDelegationBinder) AnnotationList(net.bytebuddy.description.annotation.AnnotationList) Test(org.junit.Test)

Aggregations

AnnotationList (net.bytebuddy.description.annotation.AnnotationList)6 MethodDelegationBinder (net.bytebuddy.implementation.bind.MethodDelegationBinder)6 Test (org.junit.Test)6 StackManipulation (net.bytebuddy.implementation.bytecode.StackManipulation)2 AnnotationDescription (net.bytebuddy.description.annotation.AnnotationDescription)1 ParameterList (net.bytebuddy.description.method.ParameterList)1 TypeDescription (net.bytebuddy.description.type.TypeDescription)1