use of org.apache.beam.vendor.bytebuddy.v1_11_0.net.bytebuddy.description.type.TypeDescription in project byte-buddy by raphw.
the class MethodGraphCompilerDefaultTest method testInterfaceExtension.
@Test
public void testInterfaceExtension() throws Exception {
TypeDescription typeDescription = new TypeDescription.ForLoadedType(InterfaceBase.InnerInterface.class);
MethodGraph.Linked methodGraph = MethodGraph.Compiler.Default.forJavaHierarchy().compile(typeDescription);
assertThat(methodGraph.listNodes().size(), is(1));
MethodDescription method = typeDescription.getInterfaces().getOnly().getDeclaredMethods().getOnly();
MethodGraph.Node node = methodGraph.locate(method.asSignatureToken());
assertThat(node.getSort(), is(MethodGraph.Node.Sort.RESOLVED));
assertThat(node.getMethodTypes().size(), is(1));
assertThat(node.getMethodTypes().contains(method.asTypeToken()), is(true));
assertThat(node.getRepresentative(), is(method));
assertThat(node.getVisibility(), is(method.getVisibility()));
assertThat(methodGraph.listNodes().contains(node), is(true));
}
use of org.apache.beam.vendor.bytebuddy.v1_11_0.net.bytebuddy.description.type.TypeDescription in project byte-buddy by raphw.
the class MethodGraphCompilerDefaultTest method testGenericWithReturnTypeInterfaceMultipleEvolution.
@Test
public void testGenericWithReturnTypeInterfaceMultipleEvolution() throws Exception {
TypeDescription typeDescription = new TypeDescription.ForLoadedType(GenericWithReturnTypeInterfaceBase.Intermediate.Inner.class);
MethodGraph.Linked methodGraph = MethodGraph.Compiler.Default.forJavaHierarchy().compile(typeDescription);
assertThat(methodGraph.listNodes().size(), is(1));
MethodDescription.SignatureToken token = typeDescription.getDeclaredMethods().filter(ElementMatchers.not(isBridge())).getOnly().asSignatureToken();
MethodGraph.Node node = methodGraph.locate(token);
MethodDescription.SignatureToken firstBridgeToken = typeDescription.getInterfaces().getOnly().getDeclaredMethods().filter(ElementMatchers.not(isBridge())).getOnly().asDefined().asSignatureToken();
MethodDescription.SignatureToken secondBridgeToken = typeDescription.getInterfaces().getOnly().getInterfaces().getOnly().getDeclaredMethods().getOnly().asDefined().asSignatureToken();
assertThat(node, is(methodGraph.locate(firstBridgeToken)));
assertThat(node, is(methodGraph.locate(secondBridgeToken)));
assertThat(node.getSort(), is(MethodGraph.Node.Sort.RESOLVED));
assertThat(node.getMethodTypes().size(), is(3));
assertThat(node.getMethodTypes().contains(token.asTypeToken()), is(true));
assertThat(node.getMethodTypes().contains(firstBridgeToken.asTypeToken()), is(true));
assertThat(node.getMethodTypes().contains(secondBridgeToken.asTypeToken()), is(true));
assertThat(node.getVisibility(), is(Visibility.PUBLIC));
}
use of org.apache.beam.vendor.bytebuddy.v1_11_0.net.bytebuddy.description.type.TypeDescription in project byte-buddy by raphw.
the class MethodGraphCompilerDefaultTest method testGenericNonOverriddenClassExtension.
@Test
public void testGenericNonOverriddenClassExtension() throws Exception {
TypeDescription typeDescription = new TypeDescription.ForLoadedType(GenericNonOverriddenClassBase.Inner.class);
MethodGraph.Linked methodGraph = MethodGraph.Compiler.Default.forJavaHierarchy().compile(typeDescription);
assertThat(methodGraph.listNodes().size(), is(TypeDescription.OBJECT.getDeclaredMethods().filter(isVirtual()).size() + 1));
MethodDescription methodDescription = typeDescription.getSuperClass().getDeclaredMethods().filter(isMethod()).getOnly();
MethodGraph.Node node = methodGraph.locate(methodDescription.asSignatureToken());
assertThat(node.getSort(), is(MethodGraph.Node.Sort.RESOLVED));
assertThat(node.getRepresentative(), is(methodDescription));
assertThat(node.getMethodTypes().size(), is(2));
assertThat(node.getMethodTypes().contains(methodDescription.asTypeToken()), is(true));
assertThat(node.getMethodTypes().contains(methodDescription.asDefined().asTypeToken()), is(true));
assertThat(node, is(methodGraph.getSuperClassGraph().locate(methodDescription.asSignatureToken())));
assertThat(node.getVisibility(), is(Visibility.PUBLIC));
}
use of org.apache.beam.vendor.bytebuddy.v1_11_0.net.bytebuddy.description.type.TypeDescription in project byte-buddy by raphw.
the class MethodGraphCompilerDefaultTest method testGenericInterfaceMultipleEvolution.
@Test
public void testGenericInterfaceMultipleEvolution() throws Exception {
TypeDescription typeDescription = new TypeDescription.ForLoadedType(GenericInterfaceBase.Intermediate.Inner.class);
MethodGraph.Linked methodGraph = MethodGraph.Compiler.Default.forJavaHierarchy().compile(typeDescription);
assertThat(methodGraph.listNodes().size(), is(1));
MethodDescription.SignatureToken token = typeDescription.getDeclaredMethods().filter(ElementMatchers.not(isBridge())).getOnly().asSignatureToken();
MethodGraph.Node node = methodGraph.locate(token);
MethodDescription.SignatureToken firstBridgeToken = typeDescription.getInterfaces().getOnly().getDeclaredMethods().filter(ElementMatchers.not(isBridge())).getOnly().asDefined().asSignatureToken();
MethodDescription.SignatureToken secondBridgeToken = typeDescription.getInterfaces().getOnly().getInterfaces().getOnly().getDeclaredMethods().getOnly().asDefined().asSignatureToken();
assertThat(node, is(methodGraph.locate(firstBridgeToken)));
assertThat(node, is(methodGraph.locate(secondBridgeToken)));
assertThat(node.getSort(), is(MethodGraph.Node.Sort.RESOLVED));
assertThat(node.getMethodTypes().size(), is(3));
assertThat(node.getMethodTypes().contains(token.asTypeToken()), is(true));
assertThat(node.getMethodTypes().contains(firstBridgeToken.asTypeToken()), is(true));
assertThat(node.getMethodTypes().contains(secondBridgeToken.asTypeToken()), is(true));
assertThat(node.getVisibility(), is(Visibility.PUBLIC));
}
use of org.apache.beam.vendor.bytebuddy.v1_11_0.net.bytebuddy.description.type.TypeDescription in project byte-buddy by raphw.
the class MethodGraphCompilerDefaultTest method testDuplicateNameInterfaceImplementation.
@Test
public void testDuplicateNameInterfaceImplementation() throws Exception {
TypeDescription typeDescription = new TypeDescription.ForLoadedType(DuplicateNameInterface.InnerClass.class);
MethodGraph.Linked methodGraph = MethodGraph.Compiler.Default.forJavaHierarchy().compile(typeDescription);
assertThat(methodGraph.listNodes().size(), is(TypeDescription.OBJECT.getDeclaredMethods().filter(isVirtual()).size() + 3));
MethodDescription objectMethod = typeDescription.getInterfaces().getOnly().getDeclaredMethods().filter(takesArguments(Object.class)).getOnly();
MethodGraph.Node objectNode = methodGraph.locate(objectMethod.asSignatureToken());
assertThat(objectNode.getSort(), is(MethodGraph.Node.Sort.RESOLVED));
assertThat(objectNode.getRepresentative(), is(objectMethod));
assertThat(objectNode.getMethodTypes().size(), is(1));
assertThat(objectNode.getMethodTypes().contains(objectMethod.asTypeToken()), is(true));
assertThat(objectMethod.getVisibility(), is(objectMethod.getVisibility()));
MethodDescription integerMethod = typeDescription.getInterfaces().getOnly().getDeclaredMethods().filter(takesArguments(Integer.class)).getOnly();
MethodGraph.Node integerNode = methodGraph.locate(integerMethod.asSignatureToken());
assertThat(integerNode.getSort(), is(MethodGraph.Node.Sort.RESOLVED));
assertThat(integerNode.getRepresentative(), is(integerMethod));
assertThat(integerNode.getMethodTypes().size(), is(1));
assertThat(integerNode.getMethodTypes().contains(integerMethod.asTypeToken()), is(true));
assertThat(integerNode.getVisibility(), is(integerMethod.getVisibility()));
MethodDescription voidMethod = typeDescription.getDeclaredMethods().filter(takesArguments(Void.class)).getOnly();
MethodGraph.Node voidNode = methodGraph.locate(voidMethod.asSignatureToken());
assertThat(voidNode.getSort(), is(MethodGraph.Node.Sort.RESOLVED));
assertThat(voidNode.getRepresentative(), is(voidMethod));
assertThat(voidNode.getMethodTypes().size(), is(1));
assertThat(voidNode.getMethodTypes().contains(voidMethod.asTypeToken()), is(true));
assertThat(voidNode.getVisibility(), is(voidMethod.getVisibility()));
}
Aggregations