DefaultResultAdapterContext implements ResultAdapterContext { @Override public Object adapt(Invocation invocation, Object originalResult) { log.info("Adapting the result of invocation to type " + invocation.getMethod().getReturnType()); for (ResultAdapter<?> adapter : adapters) { if (adapter.accepts(invocation, originalResult)) { return adapter.adapt(invocation, originalResult); } } log.error("Could not find any result adapter that was capable of adapting the result of the invocation to type " + invocation.getMethod().getReturnType()); throw new ResultAdapterFailureException(originalResult, invocation.getMethod().getReturnType()); } DefaultResultAdapterContext();  DefaultResultAdapterContext(boolean registerDefaults); @Override synchronized void register(ResultAdapter<?> adapter); @Override Object adapt(Invocation invocation, Object originalResult); @Override Collection<ResultAdapter<?>> getAdapters();  }
@Test(expectedExceptions = ResultAdapterFailureException.class) public void testInvalidConversion() throws Exception { final DefaultResultAdapterContext context = new DefaultResultAdapterContext(); context.adapt(new ImmutableInvocation(ReturnTypeSampleRepository.class.getMethod("findPerson"), new Object[]{}), new Address()); }