@Test public void buildShouldBuildAProxyWithCRestInvocationHandler() throws Exception, IllegalAccessException { TestInterface expected = mock(TestInterface.class); ArgumentCaptor<ObjectMethodsAwareInvocationHandler> objectMethodsAwareInvocationHandlerCaptor = ArgumentCaptor.forClass(ObjectMethodsAwareInvocationHandler.class); when(proxyFactory.createProxy(eq(TestInterface.class.getClassLoader()), objectMethodsAwareInvocationHandlerCaptor.capture(), eq(new Class[]{TestInterface.class}))).thenReturn(expected); when(configFactory.newConfig(TestInterface.class)).thenReturn(config); TestInterface actual = toTest.build(TestInterface.class); assertSame(expected,actual); assertEquals("CRestInvocationHandler", objectMethodsAwareInvocationHandlerCaptor.getValue().getClass().getSimpleName()); assertEquals(config, Classes.getFieldValue(objectMethodsAwareInvocationHandlerCaptor.getValue(), "interfaceConfig")); }
@SuppressWarnings("unchecked") public <T> T build(Class<T> interfaze) throws CRestException { try { InterfaceConfig interfaceConfig = configFactory.newConfig(interfaze); return (T) proxyFactory.createProxy(interfaze.getClassLoader(), new CRestInvocationHandler(interfaceConfig), new Class[]{interfaze}); } catch (Exception e) { throw CRestException.handle(e); } }
DefaultCRest extends CRest { @SuppressWarnings("unchecked") public <T> T build(Class<T> interfaze) throws CRestException { try { InterfaceConfig interfaceConfig = configFactory.newConfig(interfaze); return (T) proxyFactory.createProxy(interfaze.getClassLoader(), new CRestInvocationHandler(interfaceConfig), new Class[]{interfaze}); } catch (Exception e) { throw CRestException.handle(e); } } }
DefaultCRest extends CRest { @SuppressWarnings("unchecked") public <T> T build(Class<T> interfaze) throws CRestException { try { InterfaceConfig interfaceConfig = configFactory.newConfig(interfaze); return (T) proxyFactory.createProxy(interfaze.getClassLoader(), new CRestInvocationHandler(interfaceConfig), new Class[]{interfaze}); } catch (Exception e) { throw CRestException.handle(e); } } DefaultCRest(ProxyFactory proxyFactory, RequestExecutor requestExecutor, RequestBuilderFactory requestBuilderFactory, InterfaceConfigFactory configFactory); }
DefaultCRest extends CRest { @SuppressWarnings("unchecked") public <T> T build(Class<T> interfaze) throws CRestException { try { InterfaceConfig interfaceConfig = configFactory.newConfig(interfaze); return (T) proxyFactory.createProxy(interfaze.getClassLoader(), new CRestInvocationHandler(interfaceConfig), new Class[]{interfaze}); } catch (Exception e) { throw CRestException.handle(e); } } DefaultCRest(ProxyFactory proxyFactory, RequestExecutor requestExecutor, RequestBuilderFactory requestBuilderFactory, InterfaceConfigFactory configFactory); @SuppressWarnings("unchecked") T build(Class<T> interfaze); }
DefaultCRest extends CRest { @SuppressWarnings("unchecked") public <T> T build(Class<T> interfaze) throws CRestException { try { InterfaceConfig interfaceConfig = configFactory.newConfig(interfaze); return (T) proxyFactory.createProxy(interfaze.getClassLoader(), new CRestInvocationHandler(interfaceConfig), new Class[]{interfaze}); } catch (Exception e) { throw CRestException.handle(e); } } DefaultCRest(ProxyFactory proxyFactory, RequestExecutor requestExecutor, RequestBuilderFactory requestBuilderFactory, InterfaceConfigFactory configFactory); @SuppressWarnings("unchecked") T build(Class<T> interfaze);  }