return new Answer()
{
public Object answer(InvocationOnMock invocation) throws Throwable
{
MimeType mime = mimeType;
DataType ret = ((MockIBean)ibean).ibeanReturnType();
if(ret!=null) ret.setMimeType(mime.toString());
Object data;
/**
* We need to have some special handling when dealing with a Mockito mock
* 1) If the return type on the ibeans is not set, use the method return type
* 2) the return annotation changes the return type so use the one defined on the actual Method
* 3) If the return type and the method return type are not assignable, then use the method return type
*/
if (ret == null || invocation.getMethod().isAnnotationPresent(Return.class) ||
!invocation.getMethod().getReturnType().isAssignableFrom(ret.getType()))
{
ret = DataTypeFactory.createFromReturnType(invocation.getMethod());
mime = null;
}