### Question:
BoonInvocationHandlerForSendQueue implements InvocationHandler { @Override public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable { switch (method.getName()) { case "clientProxyFlush": case "flush": sendQueue.flushSends(); return null; case "stop": sendQueue.stop(); return null; case "toString": return sputs("{Local Proxy", serviceName, "}"); case "equals": return proxy == args[0]; case "hashCode": return proxy.hashCode(); } if (isPromise(method)) { final MethodCallBuilder methodCallBuilder = createMethodBuilder(method, args); return new InvokePromiseWithSendQueue(sendQueue, methodCallBuilder, beforeMethodSent); } else { return doInvoke(method, args); } } BoonInvocationHandlerForSendQueue(SendQueue<MethodCall<Object>> sendQueue,
                                             Class<?> serviceInterface,
                                             String serviceName,
                                             BeforeMethodSent beforeMethodSent); @Override Object invoke(final Object proxy, final Method method, final Object[] args);  }### Answer:
@Test public void testInvoke() throws Exception { try { boonInvocationHandlerForSendQueue.invoke(new Object(), methodFoo, new Object[]{1, 2}); } catch (Throwable throwable) { throw new IllegalStateException(throwable); } verify(sendQueue, times(1)).send(any()); }
@Test public void testInvokeWithPromise() throws Exception { final Object returnObject; try { returnObject = boonInvocationHandlerForSendQueue.invoke(new Object(), methodFooPromise, new Object[]{1, 2}); } catch (Throwable throwable) { throw new IllegalStateException(throwable); } verify(sendQueue, never()).send(any()); assertTrue(returnObject instanceof Promise); assertTrue(returnObject instanceof Invokable); final Promise<String> promise = (Promise<String>) returnObject; verify(sendQueue, never()).send(any()); promise.invoke(); verify(sendQueue, times(1)).send(any()); }