<T> T imposterise(MethodInterceptor interceptor, Class<T> mockedType, Class<?>... ancillaryTypes) { return INSTANCE.imposteriseProtected(interceptor, mockedType, ancillaryTypes); } }
private static <T> T createProxyDelegatingToRoot(final WebElement root, Class<T> clazz, final Class<?> webElementType) { return ClassImposterizer.INSTANCE.imposterise(new MethodInterceptor() { @Override public Object intercept(Object obj, Method method, Object[] args, MethodProxy proxy) throws Throwable { List<Method> webElementMethods = Arrays.asList(webElementType.getMethods()); if (webElementMethods.contains(method)) { try { return method.invoke(root, args); } catch (InvocationTargetException e) { // unwrap original exception throw e.getCause(); } } else { return proxy.invokeSuper(obj, args); } } }, clazz, webElementType); }
private static <T> T createProxyDelegatingToRoot(final WebElement root, Class<T> clazz, final Class<?> webElementType) { return ClassImposterizer.INSTANCE.imposterise(new MethodInterceptor() { @Override public Object intercept(Object obj, Method method, Object[] args, MethodProxy proxy) throws Throwable { List<Method> webElementMethods = Arrays.asList(webElementType.getMethods()); if (webElementMethods.contains(method)) { try { return method.invoke(root, args); } catch (InvocationTargetException e) { // unwrap original exception throw e.getCause(); } } else { return proxy.invokeSuper(obj, args); } } }, clazz, webElementType); }
<T> T imposterise(MethodInterceptor interceptor, Class<T> mockedType, Class<?>... ancillaryTypes) { return INSTANCE.imposteriseProtected(interceptor, mockedType, ancillaryTypes); } }