use of net.bytebuddy.description.method.ParameterDescription in project byte-buddy by raphw.
the class MethodAttributeAppenderForInstrumentedMethodTest method testMethodParameterAnnotationRuntimeRetention.
@Test
@SuppressWarnings("unchecked")
public void testMethodParameterAnnotationRuntimeRetention() throws Exception {
when(annotationValueFilter.isRelevant(any(AnnotationDescription.class), any(MethodDescription.InDefinedShape.class))).thenReturn(true);
when(methodDescription.getDeclaredAnnotations()).thenReturn(new AnnotationList.Empty());
ParameterDescription parameterDescription = mock(ParameterDescription.class);
when(parameterDescription.getType()).thenReturn(TypeDescription.Generic.OBJECT);
when(parameterDescription.getDeclaredAnnotations()).thenReturn(new AnnotationList.ForLoadedAnnotations(new Baz.Instance()));
when(methodDescription.getParameters()).thenReturn((ParameterList) new ParameterList.Explicit<ParameterDescription>(parameterDescription));
when(methodDescription.getReturnType()).thenReturn(TypeDescription.Generic.VOID);
when(methodDescription.getTypeVariables()).thenReturn(new TypeList.Generic.Empty());
when(methodDescription.getExceptionTypes()).thenReturn(new TypeList.Generic.Empty());
methodAttributeAppender.apply(methodVisitor, methodDescription, annotationValueFilter);
verify(methodVisitor).visitParameterAnnotation(0, Type.getDescriptor(Baz.class), true);
verifyNoMoreInteractions(methodVisitor);
}
use of net.bytebuddy.description.method.ParameterDescription in project byte-buddy by raphw.
the class MethodAttributeAppenderForInstrumentedMethodTest method testMethodParameterTypeTypeAnnotationRuntimeRetention.
@Test
@SuppressWarnings("unchecked")
public void testMethodParameterTypeTypeAnnotationRuntimeRetention() throws Exception {
when(annotationValueFilter.isRelevant(any(AnnotationDescription.class), any(MethodDescription.InDefinedShape.class))).thenReturn(true);
when(methodDescription.getDeclaredAnnotations()).thenReturn(new AnnotationList.Empty());
ParameterDescription parameterDescription = mock(ParameterDescription.class);
when(parameterDescription.getDeclaredAnnotations()).thenReturn(new AnnotationList.Empty());
when(parameterDescription.getType()).thenReturn(simpleAnnotatedType);
when(methodDescription.getParameters()).thenReturn((ParameterList) new ParameterList.Explicit<ParameterDescription>(parameterDescription));
when(methodDescription.getReturnType()).thenReturn(TypeDescription.Generic.VOID);
when(methodDescription.getTypeVariables()).thenReturn(new TypeList.Generic.Empty());
when(methodDescription.getExceptionTypes()).thenReturn(new TypeList.Generic.Empty());
when(simpleAnnotatedType.getDeclaredAnnotations()).thenReturn(new AnnotationList.ForLoadedAnnotations(new Baz.Instance()));
methodAttributeAppender.apply(methodVisitor, methodDescription, annotationValueFilter);
verify(methodVisitor).visitTypeAnnotation(TypeReference.newFormalParameterReference(0).getValue(), null, Type.getDescriptor(Baz.class), true);
verifyNoMoreInteractions(methodVisitor);
}
use of net.bytebuddy.description.method.ParameterDescription in project byte-buddy by raphw.
the class MethodVariableAccessOtherTest method testStoreParameter.
@Test
public void testStoreParameter() throws Exception {
ParameterDescription parameterDescription = mock(ParameterDescription.class);
when(parameterDescription.getType()).thenReturn(new TypeDescription.Generic.OfNonGenericType.ForLoadedType(int.class));
when(parameterDescription.getOffset()).thenReturn(4);
assertThat(MethodVariableAccess.store(parameterDescription), is(MethodVariableAccess.INTEGER.storeAt(4)));
}
use of net.bytebuddy.description.method.ParameterDescription in project byte-buddy by raphw.
the class MethodVariableAccessOtherTest method testLoadParameter.
@Test
public void testLoadParameter() throws Exception {
ParameterDescription parameterDescription = mock(ParameterDescription.class);
when(parameterDescription.getType()).thenReturn(new TypeDescription.Generic.OfNonGenericType.ForLoadedType(int.class));
when(parameterDescription.getOffset()).thenReturn(4);
assertThat(MethodVariableAccess.load(parameterDescription), is(MethodVariableAccess.INTEGER.loadFrom(4)));
}
Aggregations