|
44 | 44 | import com.fasterxml.jackson.databind.ObjectMapper;
|
45 | 45 | import org.junit.jupiter.api.BeforeEach;
|
46 | 46 | import org.junit.jupiter.api.Test;
|
| 47 | +import org.mockito.Mockito; |
47 | 48 | import reactor.core.publisher.Flux;
|
48 | 49 | import reactor.core.publisher.Mono;
|
49 | 50 |
|
@@ -784,7 +785,7 @@ public void testLBEventAsMessage() throws Exception {
|
784 | 785 |
|
785 | 786 | InputStream targetStream = new ByteArrayInputStream(this.sampleLBEvent.getBytes());
|
786 | 787 | ByteArrayOutputStream output = new ByteArrayOutputStream();
|
787 |
| - invoker.handleRequest(targetStream, output, null); |
| 788 | + invoker.handleRequest(targetStream, output, Mockito.mock(Context.class)); |
788 | 789 |
|
789 | 790 | Map result = mapper.readValue(output.toByteArray(), Map.class);
|
790 | 791 | assertThat(result.get("body")).isEqualTo("\"Hello from ELB\"");
|
@@ -1004,26 +1005,6 @@ public void testApiGatewayInAndOutV2() throws Exception {
|
1004 | 1005 | assertThat(headers.get("foo")).isEqualTo("bar");
|
1005 | 1006 | }
|
1006 | 1007 |
|
1007 |
| -// @SuppressWarnings("rawtypes") |
1008 |
| -// @Test |
1009 |
| -// public void testApiGatewayInAndOutWithException() throws Exception { |
1010 |
| -// System.setProperty("MAIN_CLASS", ApiGatewayConfiguration.class.getName()); |
1011 |
| -// System.setProperty("spring.cloud.function.definition", "inputOutputApiEventException"); |
1012 |
| -// FunctionInvoker invoker = new FunctionInvoker(); |
1013 |
| -// |
1014 |
| -// InputStream targetStream = new ByteArrayInputStream(this.apiGatewayEvent.getBytes()); |
1015 |
| -// ByteArrayOutputStream output = new ByteArrayOutputStream(); |
1016 |
| -// invoker.handleRequest(targetStream, output, null); |
1017 |
| -// |
1018 |
| -// Map result = mapper.readValue(output.toByteArray(), Map.class); |
1019 |
| -// assertThat(result.get("body")).isEqualTo("Intentional"); |
1020 |
| -// |
1021 |
| -// Map headers = (Map) result.get("headers"); |
1022 |
| -// assertThat(headers.get("foo")).isEqualTo("bar"); |
1023 |
| -// } |
1024 |
| - |
1025 |
| - |
1026 |
| - |
1027 | 1008 | @SuppressWarnings("rawtypes")
|
1028 | 1009 | @Test
|
1029 | 1010 | public void testApiGatewayEventAsMessage() throws Exception {
|
@@ -1347,9 +1328,10 @@ public Function<ApplicationLoadBalancerRequestEvent, ApplicationLoadBalancerResp
|
1347 | 1328 |
|
1348 | 1329 | @Bean
|
1349 | 1330 | public Function<Message<ApplicationLoadBalancerRequestEvent>, String> inputLBEventAsMessage(JsonMapper jsonMapper) {
|
1350 |
| - return v -> { |
1351 |
| - System.out.println("Received: " + v); |
1352 |
| - return v.getPayload().getBody(); |
| 1331 | + return message -> { |
| 1332 | + System.out.println("Received: " + message); |
| 1333 | + assertThat(message.getHeaders().get(AWSLambdaUtils.AWS_CONTEXT)).isNotNull(); |
| 1334 | + return message.getPayload().getBody(); |
1353 | 1335 | };
|
1354 | 1336 | }
|
1355 | 1337 |
|
|
0 commit comments