Light, fluffy, and always free - The AWS Local Emulator alternative
Fix/sns put timestamp in message envelope (#268)
GitMarco2dca5239079a
diff --git a/src/main/java/io/github/hectorvent/floci/services/sns/SnsService.java b/src/main/java/io/github/hectorvent/floci/services/sns/SnsService.javaindex aaf48c0844..c4d73ddfea 100644--- a/src/main/java/io/github/hectorvent/floci/services/sns/SnsService.java+++ b/src/main/java/io/github/hectorvent/floci/services/sns/SnsService.java@@ -682,10 +682,12 @@ public class SnsService {Map<String, MessageAttributeValue> messageAttributes,String topicArn, String messageId) {try {+ String timestamp = DateTimeFormatter.ISO_INSTANT.format(Instant.now());ObjectNode node = objectMapper.createObjectNode();node.put("Type", "Notification");node.put("MessageId", messageId);node.put("TopicArn", topicArn);+ node.put("Timestamp", timestamp);if (subject != null) {node.put("Subject", subject);}diff --git a/src/test/java/io/github/hectorvent/floci/services/sns/SnsIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/sns/SnsIntegrationTest.javaindex 17eec88693..4385c59209 100644--- a/src/test/java/io/github/hectorvent/floci/services/sns/SnsIntegrationTest.java+++ b/src/test/java/io/github/hectorvent/floci/services/sns/SnsIntegrationTest.java@@ -12,6 +12,7 @@ import java.util.UUID;import static io.restassured.RestAssured.given;import static org.hamcrest.Matchers.*;+import static org.junit.jupiter.api.Assertions.assertTrue;/*** Integration tests for SNS via the query (form-encoded) protocol.@@ -191,7 +192,7 @@ class SnsIntegrationTest {.body(containsString("<MessageId>"));// Verify the message arrived in the SQS queue- given()+ String jsonBodyInResponse = given().contentType("application/x-www-form-urlencoded").formParam("Action", "ReceiveMessage").formParam("QueueUrl", sqsQueueUrl)@@ -200,8 +201,14 @@ class SnsIntegrationTest {.post("/").then().statusCode(200)- .body(containsString("Hello from SNS!"))- .body(containsString("Notification"));+ .log().body()+ .body(containsString("Hello from SNS!"))+ .body(containsString("Notification"))+ .extract().xmlPath().getString(+ "ReceiveMessageResponse.ReceiveMessageResult.Message.Body");+ ;++ assertTrue(jsonBodyInResponse.contains("\"Timestamp\""));}@Test