From 253f6259b8890947b4c057ade547541273047324 Mon Sep 17 00:00:00 2001 From: Oleg Zhurakousky Date: Mon, 23 Oct 2023 17:38:01 +0200 Subject: [PATCH] GH-953 Modify test to show returning non-default status code Resolves #953 --- .../cloud/function/adapter/aws/FunctionInvokerTests.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/spring-cloud-function-adapters/spring-cloud-function-adapter-aws/src/test/java/org/springframework/cloud/function/adapter/aws/FunctionInvokerTests.java b/spring-cloud-function-adapters/spring-cloud-function-adapter-aws/src/test/java/org/springframework/cloud/function/adapter/aws/FunctionInvokerTests.java index f03c2a303..b02998c76 100644 --- a/spring-cloud-function-adapters/spring-cloud-function-adapter-aws/src/test/java/org/springframework/cloud/function/adapter/aws/FunctionInvokerTests.java +++ b/spring-cloud-function-adapters/spring-cloud-function-adapter-aws/src/test/java/org/springframework/cloud/function/adapter/aws/FunctionInvokerTests.java @@ -1225,6 +1225,7 @@ public void testResponseBase64Encoded() throws Exception { String result = new String(output.toByteArray(), StandardCharsets.UTF_8); Map resultMap = mapper.fromJson(result, Map.class); assertThat((boolean) resultMap.get(AWSLambdaUtils.IS_BASE64_ENCODED)).isTrue(); + assertThat((int) resultMap.get(AWSLambdaUtils.STATUS_CODE)).isEqualTo(201); String body = new String(Base64.getDecoder().decode((String) resultMap.get(AWSLambdaUtils.BODY)), StandardCharsets.UTF_8); assertThat(body).isEqualTo("hello"); } @@ -1694,7 +1695,10 @@ public Supplier supply() { public Function, Message> echoStringMessage() { return m -> { String encodedPayload = Base64.getEncoder().encodeToString(m.getPayload().getBytes(StandardCharsets.UTF_8)); - return MessageBuilder.withPayload(encodedPayload).setHeader("isBase64Encoded", true).build(); + return MessageBuilder.withPayload(encodedPayload) + .setHeader("isBase64Encoded", true) + .setHeader("statusCode", 201) + .build(); }; }