GH-943 Enhance AWS FunctionInvoker

This adds another constructor which allows function.definition to be passed as a constructor argument rather then rely on the property

Resolves #943
This commit is contained in:
Oleg Zhurakousky
2022-11-02 09:35:38 +01:00
parent c7b2f7ebb4
commit 3c0a7fbc19
2 changed files with 37 additions and 14 deletions

View File

@@ -578,6 +578,19 @@ public class FunctionInvokerTests {
assertThat(result).contains("arn:aws:sqs:eu-central-1:123456789012:MyQueue");
}
@Test
public void testSQSEventWithConstructorArg() throws Exception {
System.setProperty("MAIN_CLASS", SQSConfiguration.class.getName());
FunctionInvoker invoker = new FunctionInvoker("inputSQSEvent");
InputStream targetStream = new ByteArrayInputStream(this.sampleSQSEvent.getBytes());
ByteArrayOutputStream output = new ByteArrayOutputStream();
invoker.handleRequest(targetStream, output, null);
String result = new String(output.toByteArray(), StandardCharsets.UTF_8);
assertThat(result).contains("arn:aws:sqs:eu-central-1:123456789012:MyQueue");
}
@Test
public void testSQSEventAsMessage() throws Exception {
System.setProperty("MAIN_CLASS", SQSConfiguration.class.getName());