Map<?, ?> map = (Map<?, ?>) object;
T value = getValue(map.get("value"), retClass);
String error = (String) map.get("error");
if (value != null) {
if (error == null) {
return new Returns<>((T) new MockAction(
actionDef.getDescriptor(), State.SUCCESS, value));
}
} else {
if (error != null) {
try {
new ThrowsExceptionClass<T>(error).answer();
} catch (Throwable e) {
return new Returns<>((T) new MockAction(
actionDef.getDescriptor(), State.ERROR, null,
null, null, ImmutableList.<Object> of(e)));
}
}
}