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;
}
Aggregations