@@ -44,6 +44,7 @@ import com.amazonaws.services.lambda.runtime.events.SQSEvent;
|
|||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.mockito.Mockito;
|
||||||
import reactor.core.publisher.Flux;
|
import reactor.core.publisher.Flux;
|
||||||
import reactor.core.publisher.Mono;
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
@@ -802,7 +803,7 @@ public class FunctionInvokerTests {
|
|||||||
|
|
||||||
InputStream targetStream = new ByteArrayInputStream(this.sampleLBEvent.getBytes());
|
InputStream targetStream = new ByteArrayInputStream(this.sampleLBEvent.getBytes());
|
||||||
ByteArrayOutputStream output = new ByteArrayOutputStream();
|
ByteArrayOutputStream output = new ByteArrayOutputStream();
|
||||||
invoker.handleRequest(targetStream, output, null);
|
invoker.handleRequest(targetStream, output, Mockito.mock(Context.class));
|
||||||
|
|
||||||
Map result = mapper.readValue(output.toByteArray(), Map.class);
|
Map result = mapper.readValue(output.toByteArray(), Map.class);
|
||||||
assertThat(result.get("body")).isEqualTo("\"Hello from ELB\"");
|
assertThat(result.get("body")).isEqualTo("\"Hello from ELB\"");
|
||||||
@@ -1022,26 +1023,6 @@ public class FunctionInvokerTests {
|
|||||||
assertThat(headers.get("foo")).isEqualTo("bar");
|
assertThat(headers.get("foo")).isEqualTo("bar");
|
||||||
}
|
}
|
||||||
|
|
||||||
// @SuppressWarnings("rawtypes")
|
|
||||||
// @Test
|
|
||||||
// public void testApiGatewayInAndOutWithException() throws Exception {
|
|
||||||
// System.setProperty("MAIN_CLASS", ApiGatewayConfiguration.class.getName());
|
|
||||||
// System.setProperty("spring.cloud.function.definition", "inputOutputApiEventException");
|
|
||||||
// FunctionInvoker invoker = new FunctionInvoker();
|
|
||||||
//
|
|
||||||
// InputStream targetStream = new ByteArrayInputStream(this.apiGatewayEvent.getBytes());
|
|
||||||
// ByteArrayOutputStream output = new ByteArrayOutputStream();
|
|
||||||
// invoker.handleRequest(targetStream, output, null);
|
|
||||||
//
|
|
||||||
// Map result = mapper.readValue(output.toByteArray(), Map.class);
|
|
||||||
// assertThat(result.get("body")).isEqualTo("Intentional");
|
|
||||||
//
|
|
||||||
// Map headers = (Map) result.get("headers");
|
|
||||||
// assertThat(headers.get("foo")).isEqualTo("bar");
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
@Test
|
@Test
|
||||||
public void testApiGatewayEventAsMessage() throws Exception {
|
public void testApiGatewayEventAsMessage() throws Exception {
|
||||||
@@ -1373,9 +1354,10 @@ public class FunctionInvokerTests {
|
|||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public Function<Message<ApplicationLoadBalancerRequestEvent>, String> inputLBEventAsMessage(JsonMapper jsonMapper) {
|
public Function<Message<ApplicationLoadBalancerRequestEvent>, String> inputLBEventAsMessage(JsonMapper jsonMapper) {
|
||||||
return v -> {
|
return message -> {
|
||||||
System.out.println("Received: " + v);
|
System.out.println("Received: " + message);
|
||||||
return v.getPayload().getBody();
|
assertThat(message.getHeaders().get(AWSLambdaUtils.AWS_CONTEXT)).isNotNull();
|
||||||
|
return message.getPayload().getBody();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user