use of net.bytebuddy.description.type.TypeDescription in project byte-buddy by raphw.
the class TypePoolDefaultLazyTypeContainmentTest method testDeclaredInMethodGetTypeIsNotNull.
@Test
public void testDeclaredInMethodGetTypeIsNotNull() throws Exception {
TypeDescription typeDescription = mock(TypeDescription.class);
TypePool typePool = mock(TypePool.class);
when(typePool.describe(FOO)).thenReturn(new TypePool.Resolution.Simple(typeDescription));
assertThat(new TypePool.Default.LazyTypeDescription.TypeContainment.WithinMethod(FOO_INTERNAL, BAR, QUX).getEnclosingType(typePool), is(typeDescription));
}
use of net.bytebuddy.description.type.TypeDescription in project byte-buddy by raphw.
the class TypePoolDefaultLazyTypeContainmentTest method testDeclaredInMethodGetMethodIsNull.
@Test
@SuppressWarnings("unchecked")
public void testDeclaredInMethodGetMethodIsNull() throws Exception {
MethodDescription methodDescription = mock(MethodDescription.class);
when(methodDescription.getActualName()).thenReturn(BAR);
when(methodDescription.getDescriptor()).thenReturn(QUX);
TypeDescription typeDescription = mock(TypeDescription.class);
TypePool typePool = mock(TypePool.class);
when(typePool.describe(FOO)).thenReturn(new TypePool.Resolution.Simple(typeDescription));
when(typeDescription.getDeclaredMethods()).thenReturn((MethodList) new MethodList.Explicit<MethodDescription>(methodDescription));
assertThat(new TypePool.Default.LazyTypeDescription.TypeContainment.WithinMethod(FOO_INTERNAL, BAR, QUX).getEnclosingMethod(typePool), is(methodDescription));
}
use of net.bytebuddy.description.type.TypeDescription in project byte-buddy by raphw.
the class TypePoolDefaultLazyTypeContainmentTest method testDeclaredInTypeGetTypeIsNotNull.
@Test
public void testDeclaredInTypeGetTypeIsNotNull() throws Exception {
TypePool typePool = mock(TypePool.class);
TypeDescription typeDescription = mock(TypeDescription.class);
when(typePool.describe(FOO)).thenReturn(new TypePool.Resolution.Simple(typeDescription));
assertThat(new TypePool.Default.LazyTypeDescription.TypeContainment.WithinType(FOO_INTERNAL, false).getEnclosingType(typePool), is(typeDescription));
assertThat(new TypePool.Default.LazyTypeDescription.TypeContainment.WithinType(FOO_INTERNAL, true).getEnclosingType(typePool), is(typeDescription));
}
use of net.bytebuddy.description.type.TypeDescription in project byte-buddy by raphw.
the class TypePoolDefaultWithLazyResolutionTypeDescriptionTest method testGenericSuperInterfaceHierarchyResolutionIsLazy.
@Test
public void testGenericSuperInterfaceHierarchyResolutionIsLazy() throws Exception {
ClassFileLocator classFileLocator = spy(ClassFileLocator.ForClassLoader.ofClassPath());
assertThat(describe(GenericType.class, classFileLocator, new TypePool.CacheProvider.Simple()).getInterfaces().getOnly().asErasure(), CoreMatchers.is((TypeDescription) new TypeDescription.ForLoadedType(SampleGenericInterface.class)));
verify(classFileLocator).locate(GenericType.class.getName());
verifyNoMoreInteractions(classFileLocator);
}
use of net.bytebuddy.description.type.TypeDescription in project byte-buddy by raphw.
the class RebaseDynamicTypeBuilderTest method testObjectProperties.
@Test
public void testObjectProperties() throws Exception {
ObjectPropertyAssertion.of(RebaseDynamicTypeBuilder.class).create(new ObjectPropertyAssertion.Creator<List<?>>() {
@Override
public List<?> create() {
TypeDescription typeDescription = mock(TypeDescription.class);
when(typeDescription.asErasure()).thenReturn(typeDescription);
return Collections.singletonList(typeDescription);
}
}).create(new ObjectPropertyAssertion.Creator<TypeDescription>() {
@Override
public TypeDescription create() {
TypeDescription rawTypeDescription = mock(TypeDescription.class);
when(rawTypeDescription.asErasure()).thenReturn(rawTypeDescription);
when(rawTypeDescription.getDeclaredAnnotations()).thenReturn(new AnnotationList.Empty());
when(rawTypeDescription.getTypeVariables()).thenReturn(new TypeList.Generic.Empty());
TypeDescription.Generic typeDescription = mock(TypeDescription.Generic.class);
when(typeDescription.asGenericType()).thenReturn(typeDescription);
when(typeDescription.asErasure()).thenReturn(rawTypeDescription);
when(rawTypeDescription.getInterfaces()).thenReturn(new TypeList.Generic.Explicit(typeDescription));
when(rawTypeDescription.getDeclaredFields()).thenReturn(new FieldList.Empty<FieldDescription.InDefinedShape>());
when(rawTypeDescription.getDeclaredMethods()).thenReturn(new MethodList.Empty<MethodDescription.InDefinedShape>());
return rawTypeDescription;
}
}).apply();
}
Aggregations