@Test(expected = MessageProcessorException.class) public void invoke_functionError() throws Exception { SQSMessageProcessorRequest sqsMessageProcessorRequest = new SQSMessageProcessorRequest(); sqsMessageProcessorRequest.setMessages(MESSAGES); InvokeResult invokeResult = mock(InvokeResult.class); when(invokeResult.getFunctionError()).thenReturn("Unhandled"); when(lambda.invoke(any(InvokeRequest.class))).thenReturn(invokeResult); messageProcessorProxy.invoke(sqsMessageProcessorRequest); }
public SQSMessageProcessorResponse invoke(final SQSMessageProcessorRequest request) throws MessageProcessorException { log.info("Invoking message processor lambda to process {} messages", request.getMessages().size()); String requestPayload = GSON.toJson(request); InvokeRequest invokeRequest = new InvokeRequest() .withFunctionName(messageProcessorFunctionName) .withInvocationType(InvocationType.RequestResponse) .withPayload(requestPayload); InvokeResult result = lambda.invoke(invokeRequest); if (result.getFunctionError() != null) { throw new MessageProcessorException(result); } return GSON.fromJson(LambdaUtil.getPayloadAsString(result), SQSMessageProcessorResponse.class); }
MessageProcessorProxy { public SQSMessageProcessorResponse invoke(final SQSMessageProcessorRequest request) throws MessageProcessorException { log.info("Invoking message processor lambda to process {} messages", request.getMessages().size()); String requestPayload = GSON.toJson(request); InvokeRequest invokeRequest = new InvokeRequest() .withFunctionName(messageProcessorFunctionName) .withInvocationType(InvocationType.RequestResponse) .withPayload(requestPayload); InvokeResult result = lambda.invoke(invokeRequest); if (result.getFunctionError() != null) { throw new MessageProcessorException(result); } return GSON.fromJson(LambdaUtil.getPayloadAsString(result), SQSMessageProcessorResponse.class); } }
MessageProcessorProxy { public SQSMessageProcessorResponse invoke(final SQSMessageProcessorRequest request) throws MessageProcessorException { log.info("Invoking message processor lambda to process {} messages", request.getMessages().size()); String requestPayload = GSON.toJson(request); InvokeRequest invokeRequest = new InvokeRequest() .withFunctionName(messageProcessorFunctionName) .withInvocationType(InvocationType.RequestResponse) .withPayload(requestPayload); InvokeResult result = lambda.invoke(invokeRequest); if (result.getFunctionError() != null) { throw new MessageProcessorException(result); } return GSON.fromJson(LambdaUtil.getPayloadAsString(result), SQSMessageProcessorResponse.class); }  }
MessageProcessorProxy { public SQSMessageProcessorResponse invoke(final SQSMessageProcessorRequest request) throws MessageProcessorException { log.info("Invoking message processor lambda to process {} messages", request.getMessages().size()); String requestPayload = GSON.toJson(request); InvokeRequest invokeRequest = new InvokeRequest() .withFunctionName(messageProcessorFunctionName) .withInvocationType(InvocationType.RequestResponse) .withPayload(requestPayload); InvokeResult result = lambda.invoke(invokeRequest); if (result.getFunctionError() != null) { throw new MessageProcessorException(result); } return GSON.fromJson(LambdaUtil.getPayloadAsString(result), SQSMessageProcessorResponse.class); }  SQSMessageProcessorResponse invoke(final SQSMessageProcessorRequest request); }
MessageProcessorProxy { public SQSMessageProcessorResponse invoke(final SQSMessageProcessorRequest request) throws MessageProcessorException { log.info("Invoking message processor lambda to process {} messages", request.getMessages().size()); String requestPayload = GSON.toJson(request); InvokeRequest invokeRequest = new InvokeRequest() .withFunctionName(messageProcessorFunctionName) .withInvocationType(InvocationType.RequestResponse) .withPayload(requestPayload); InvokeResult result = lambda.invoke(invokeRequest); if (result.getFunctionError() != null) { throw new MessageProcessorException(result); } return GSON.fromJson(LambdaUtil.getPayloadAsString(result), SQSMessageProcessorResponse.class); }  SQSMessageProcessorResponse invoke(final SQSMessageProcessorRequest request);  }