@Test public void testDecorator() throws Throwable { feignDecorator.setAlternativeFunction(fnArgs -> "AlternativeFunction"); testSubject = new DecoratorInvocationHandler(target, dispatch, feignDecorator); final Object result = testSubject.invoke(testService, greetingMethod, new Object[0]); verify(methodHandler, times(0)).invoke(any()); assertThat(feignDecorator.isCalled()) .describedAs("FeignDecorator is called") .isTrue(); assertThat(result) .describedAs("Return of invocation") .isEqualTo("AlternativeFunction"); }
@Override public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable { switch (method.getName()) { case "equals": return equals(args.length > 0 ? args[0] : null); case "hashCode": return hashCode(); case "toString": return toString(); default: break; } return decoratedDispatch.get(method).apply(args); }
DecoratorInvocationHandler implements InvocationHandler { @Override public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable { switch (method.getName()) { case "equals": return equals(args.length > 0 ? args[0] : null); case "hashCode": return hashCode(); case "toString": return toString(); default: break; } return decoratedDispatch.get(method).apply(args); } }
DecoratorInvocationHandler implements InvocationHandler { @Override public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable { switch (method.getName()) { case "equals": return equals(args.length > 0 ? args[0] : null); case "hashCode": return hashCode(); case "toString": return toString(); default: break; } return decoratedDispatch.get(method).apply(args); } DecoratorInvocationHandler(Target<?> target,
        Map<Method, MethodHandler> dispatch,
        FeignDecorator invocationDecorator); }
DecoratorInvocationHandler implements InvocationHandler { @Override public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable { switch (method.getName()) { case "equals": return equals(args.length > 0 ? args[0] : null); case "hashCode": return hashCode(); case "toString": return toString(); default: break; } return decoratedDispatch.get(method).apply(args); } DecoratorInvocationHandler(Target<?> target,
        Map<Method, MethodHandler> dispatch,
        FeignDecorator invocationDecorator); @Override Object invoke(final Object proxy, final Method method, final Object[] args); @Override boolean equals(Object obj); @Override int hashCode(); @Override String toString(); }
DecoratorInvocationHandler implements InvocationHandler { @Override public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable { switch (method.getName()) { case "equals": return equals(args.length > 0 ? args[0] : null); case "hashCode": return hashCode(); case "toString": return toString(); default: break; } return decoratedDispatch.get(method).apply(args); } DecoratorInvocationHandler(Target<?> target,
        Map<Method, MethodHandler> dispatch,
        FeignDecorator invocationDecorator); @Override Object invoke(final Object proxy, final Method method, final Object[] args); @Override boolean equals(Object obj); @Override int hashCode(); @Override String toString();  }