### Question:
LambdaInvocationHandler implements InvocationHandler { InvokeRequest buildInvokeRequest(Method method, Object object) throws IOException { final LambdaFunction lambdaFunction = method.getAnnotation(LambdaFunction.class); final InvokeRequest invokeRequest = new InvokeRequest(); if (lambdaFunction.functionName().isEmpty()) { invokeRequest.setFunctionName(method.getName()); } else { invokeRequest.setFunctionName(lambdaFunction.functionName()); } invokeRequest.setLogType(lambdaFunction.logType()); if (!LogType.None.toString().equals(lambdaFunction.logType())) { invokeRequest.setInvocationType(InvocationType.RequestResponse); } else { invokeRequest.setInvocationType(lambdaFunction.invocationType()); } if (!lambdaFunction.qualifier().isEmpty()) { invokeRequest.setQualifier(lambdaFunction.qualifier()); } if (clientContext != null) { invokeRequest.setClientContext(clientContext.toBase64String()); } invokeRequest.setPayload(ByteBuffer.wrap(binder.serialize(object))); return invokeRequest; } LambdaInvocationHandler(AWSLambda lambda, LambdaDataBinder binder,
            ClientContext clientContext); @Override Object invoke(Object proxy, Method method, Object[] args);  }### Answer:
@Test public void testBuildInvokeRequest() throws Exception { Method echo = getMethod("echo", String.class); String input = "hello world"; InvokeRequest request = handler.buildInvokeRequest(echo, input); assertEquals("function name", "echo", request.getFunctionName()); assertEquals("invocation type", "RequestResponse", request.getInvocationType()); assertNull("default qualifier", request.getQualifier()); String json = "\"" + input + "\""; ByteBuffer payload = stringToByteBuffer(json); assertArrayEquals("payload", payload.array(), request.getPayload().array()); }
@Test public void testBuildInvokeRequestOverride() throws Exception { Method echoAlias = getMethod("echoAlias", String.class); String input = "hello world"; InvokeRequest request = handler.buildInvokeRequest(echoAlias, input); assertEquals("function name", "echo", request.getFunctionName()); assertEquals("invocation type", "Event", request.getInvocationType()); }
@Test public void testBuildInvokeLogAndRequestOverride() throws Exception { Method echoAlias = getMethod("echoAliasLogTail", String.class); String input = "hello world"; InvokeRequest request = handler.buildInvokeRequest(echoAlias, input); assertEquals("function name", "echo", request.getFunctionName()); assertEquals("invocation type", "RequestResponse", request.getInvocationType()); }
@Test public void testBuildInvokeRequestVersion() throws Exception { Method echoVersion = getMethod("echoVersion", String.class); String input = "hello world"; InvokeRequest request = handler.buildInvokeRequest(echoVersion, input); assertEquals("function name", "echoVersion", request.getFunctionName()); assertEquals("qualifier", "version", request.getQualifier()); }