Search in sources :

Example 1 with ExecutableRefTestSource

use of spoon.test.executable.testclasses.ExecutableRefTestSource in project spoon by INRIA.

the class ExecutableRefTest method getInvocationFromMethod.

private CtAbstractInvocation<?> getInvocationFromMethod(String methodName) throws Exception {
    Factory factory = build(ExecutableRefTestSource.class, MyIntf.class);
    CtClass<ExecutableRefTestSource> clazz = factory.Class().get(ExecutableRefTestSource.class);
    Assert.assertNotNull(clazz);
    List<CtMethod<?>> methods = clazz.getMethodsByName(methodName);
    assertEquals(1, methods.size());
    CtMethod<?> ctMethod = methods.get(0);
    CtBlock<?> ctBody = (CtBlock<?>) ctMethod.getBody();
    Assert.assertNotNull(ctBody);
    List<CtStatement> ctStatements = ctBody.getStatements();
    assertEquals(1, ctStatements.size());
    CtStatement ctStatement = ctStatements.get(0);
    Assert.assertTrue(ctStatement instanceof CtAbstractInvocation<?>);
    return (CtAbstractInvocation<?>) ctStatement;
}
Also used : CtBlock(spoon.reflect.code.CtBlock) CtStatement(spoon.reflect.code.CtStatement) ExecutableRefTestSource(spoon.test.executable.testclasses.ExecutableRefTestSource) CtAbstractInvocation(spoon.reflect.code.CtAbstractInvocation) Factory(spoon.reflect.factory.Factory) CtMethod(spoon.reflect.declaration.CtMethod)

Aggregations

CtAbstractInvocation (spoon.reflect.code.CtAbstractInvocation)1 CtBlock (spoon.reflect.code.CtBlock)1 CtStatement (spoon.reflect.code.CtStatement)1 CtMethod (spoon.reflect.declaration.CtMethod)1 Factory (spoon.reflect.factory.Factory)1 ExecutableRefTestSource (spoon.test.executable.testclasses.ExecutableRefTestSource)1