Search in sources :

Example 1 with EnumValue

use of spoon.test.reference.testclasses.EnumValue in project spoon by INRIA.

the class TypeReferenceTest method testRecursiveTypeReferenceInGenericType.

@Test
public void testRecursiveTypeReferenceInGenericType() throws Exception {
    final Launcher launcher = new Launcher();
    launcher.addInputResource("./src/test/java/spoon/test/reference/testclasses/EnumValue.java");
    launcher.setSourceOutputDirectory("./target/spoon-test");
    launcher.run();
    final CtClass<EnumValue> aClass = launcher.getFactory().Class().get(EnumValue.class);
    final CtMethod<?> asEnum = aClass.getMethodsByName("asEnum").get(0);
    // New type parameter declaration.
    final CtTypeParameter typeParameter = asEnum.getFormalCtTypeParameters().get(0);
    assertNotNull(typeParameter);
    assertNotNull(typeParameter.getSuperclass());
    final CtTypeReference<?> extendsGeneric = typeParameter.getSuperclass();
    assertNotNull(extendsGeneric);
    assertEquals(1, extendsGeneric.getActualTypeArguments().size());
    final CtTypeReference circularRef = extendsGeneric.getActualTypeArguments().get(0);
    assertNotNull(circularRef);
}
Also used : CtTypeParameter(spoon.reflect.declaration.CtTypeParameter) EnumValue(spoon.test.reference.testclasses.EnumValue) CtTypeReference(spoon.reflect.reference.CtTypeReference) Launcher(spoon.Launcher) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 Launcher (spoon.Launcher)1 CtTypeParameter (spoon.reflect.declaration.CtTypeParameter)1 CtTypeReference (spoon.reflect.reference.CtTypeReference)1 EnumValue (spoon.test.reference.testclasses.EnumValue)1