### Question:
LambdaInvocationHandler implements InvocationHandler { @Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { validateInterfaceMethod(method, args); final Object buildArg = (args == null || args.length == 0) ? null : args[0]; final InvokeRequest invokeRequest = buildInvokeRequest(method, buildArg); final InvokeResult invokeResult = lambda.invoke(invokeRequest); return processInvokeResult(method, invokeResult); } LambdaInvocationHandler(AWSLambda lambda, LambdaDataBinder binder,
            ClientContext clientContext); @Override Object invoke(Object proxy, Method method, Object[] args);  }### Answer:
@Test public void testInvoke() { String input = "Hello world!"; InvokeResult invokeResult = createInvokeResult(200, null, "\"" + input + "\""); Mockito.when(lambda.invoke(Matchers.any(InvokeRequest.class))).thenReturn(invokeResult); String result = invoker.echo(input); assertEquals("echo", input, result); }
@Test public void testInvokeNoArgument() throws Exception { String echoResult = "No argument"; InvokeResult invokeResult = createInvokeResult(200, null, "\"" + echoResult + "\""); Mockito.when(lambda.invoke(Matchers.any(InvokeRequest.class))).thenReturn(invokeResult); String result = invoker.echoNoArgument(); assertEquals("echoNoArgument", echoResult, result); }
@Test(expected = LambdaFunctionException.class) public void testInvokeException() { String input = "Hello world!"; String error = "Panic!"; String payload = "Bulls eye"; InvokeResult invokeResult = createInvokeResult(200, error, payload); Mockito.when(lambda.invoke(Matchers.any(InvokeRequest.class))).thenReturn(invokeResult); try { invoker.echo(input); } catch (LambdaFunctionException lfe) { assertEquals("error message", error, lfe.getMessage()); assertEquals("payload", payload, lfe.getDetails()); throw lfe; } }