use of net.bytebuddy.description.type.TypeDescription in project byte-buddy by raphw.
the class ClassLoadingStrategyDefaultTest method setUp.
@Before
public void setUp() throws Exception {
classLoader = new URLClassLoader(new URL[0], null);
binaryRepresentations = new LinkedHashMap<TypeDescription, byte[]>();
typeDescription = new TypeDescription.ForLoadedType(Foo.class);
binaryRepresentations.put(typeDescription, ClassFileExtraction.extract(Foo.class));
protectionDomain = getClass().getProtectionDomain();
when(packageDefinitionStrategy.define(any(ClassLoader.class), any(String.class), any(String.class))).thenReturn(PackageDefinitionStrategy.Definition.Undefined.INSTANCE);
}
use of net.bytebuddy.description.type.TypeDescription in project byte-buddy by raphw.
the class TransformerForFieldTest method testNoChangesUnlessSpecified.
@Test
public void testNoChangesUnlessSpecified() throws Exception {
TypeDescription typeDescription = new TypeDescription.ForLoadedType(Bar.class);
FieldDescription fieldDescription = typeDescription.getSuperClass().getDeclaredFields().filter(named(FOO)).getOnly();
FieldDescription transformed = Transformer.ForField.withModifiers().transform(typeDescription, fieldDescription);
assertThat(transformed, is(fieldDescription));
assertThat(transformed.getModifiers(), is(fieldDescription.getModifiers()));
}
use of net.bytebuddy.description.type.TypeDescription in project byte-buddy by raphw.
the class TransformerForFieldTest method testRetainsInstrumentedType.
@Test
public void testRetainsInstrumentedType() throws Exception {
TypeDescription typeDescription = new TypeDescription.ForLoadedType(Bar.class);
FieldDescription fieldDescription = typeDescription.getSuperClass().getDeclaredFields().filter(named(BAR)).getOnly();
FieldDescription transformed = Transformer.ForField.withModifiers().transform(typeDescription, fieldDescription);
assertThat(transformed, is(fieldDescription));
assertThat(transformed.getModifiers(), is(fieldDescription.getModifiers()));
assertThat(transformed.getType().asErasure(), is(typeDescription));
assertThat(transformed.getType().getSort(), is(TypeDefinition.Sort.PARAMETERIZED));
assertThat(transformed.getType().getTypeArguments().size(), is(1));
assertThat(transformed.getType().getTypeArguments().getOnly(), is(typeDescription.getSuperClass().getDeclaredFields().filter(named(FOO)).getOnly().getType()));
}
use of net.bytebuddy.description.type.TypeDescription in project byte-buddy by raphw.
the class TransformerForMethodTest method testNoChangesUnlessSpecified.
@Test
public void testNoChangesUnlessSpecified() throws Exception {
TypeDescription typeDescription = new TypeDescription.ForLoadedType(Bar.class);
MethodDescription methodDescription = typeDescription.getSuperClass().getDeclaredMethods().filter(named(FOO)).getOnly();
MethodDescription transformed = Transformer.ForMethod.withModifiers().transform(typeDescription, methodDescription);
assertThat(transformed, is(methodDescription));
assertThat(transformed.getModifiers(), is(methodDescription.getModifiers()));
}
use of net.bytebuddy.description.type.TypeDescription in project byte-buddy by raphw.
the class TransformerForMethodTest method testRetainsInstrumentedType.
@Test
public void testRetainsInstrumentedType() throws Exception {
TypeDescription typeDescription = new TypeDescription.ForLoadedType(Bar.class);
MethodDescription methodDescription = typeDescription.getSuperClass().getDeclaredMethods().filter(named(BAR)).getOnly();
MethodDescription transformed = Transformer.ForMethod.withModifiers().transform(typeDescription, methodDescription);
assertThat(transformed, is(methodDescription));
assertThat(transformed.getModifiers(), is(methodDescription.getModifiers()));
assertThat(transformed.getReturnType().asErasure(), is(typeDescription));
assertThat(transformed.getReturnType().getSort(), is(TypeDefinition.Sort.PARAMETERIZED));
assertThat(transformed.getReturnType().getTypeArguments().size(), is(1));
assertThat(transformed.getReturnType().getTypeArguments().getOnly(), is(typeDescription.getSuperClass().getDeclaredMethods().filter(named(FOO)).getOnly().getReturnType()));
}
Aggregations