Search in sources :

Example 6 with Message

use of software.amazon.awssdk.services.sqs.model.Message in project syndesis-qe by syndesisio.

the class SQSValidationSteps method verifyDifferentGroupId.

@Then("verify that all messages in SQS queue {string} have different groupId")
public void verifyDifferentGroupId(String queueName) {
    Set<String> seenIds = new HashSet<>();
    for (Message message : sqs.getMessages(queueName)) {
        assertThat(seenIds).doesNotContain(message.attributes().get(MessageSystemAttributeName.MESSAGE_GROUP_ID));
        seenIds.add(message.attributes().get(MessageSystemAttributeName.MESSAGE_GROUP_ID));
    }
}
Also used : Message(software.amazon.awssdk.services.sqs.model.Message) HashSet(java.util.HashSet) Then(io.cucumber.java.en.Then)

Example 7 with Message

use of software.amazon.awssdk.services.sqs.model.Message in project syndesis-qe by syndesisio.

the class SNSValidationSteps method verifySNSMessage.

@Then("verify that the SQS queue {string} contains notifications related to")
public void verifySNSMessage(String queue, DataTable content) {
    final List<Message> messages = sqs.getMessages(queue);
    Map<String, String> contentMap = content.asMap(String.class, String.class);
    for (Map.Entry<String, String> entry : contentMap.entrySet()) {
        assertThat(messages.stream().filter(m -> {
            JSONObject messageJson = new JSONObject(m.body());
            return messageJson.getString("Subject").equals(entry.getKey()) && messageJson.getString("Message").equals(entry.getValue());
        }).findAny()).as("Expected messages were not received").isPresent();
    }
}
Also used : Message(software.amazon.awssdk.services.sqs.model.Message) JSONObject(org.json.JSONObject) Map(java.util.Map) Then(io.cucumber.java.en.Then)

Aggregations

Message (software.amazon.awssdk.services.sqs.model.Message)7 ReceiveMessageRequest (software.amazon.awssdk.services.sqs.model.ReceiveMessageRequest)5 SqsClient (software.amazon.awssdk.services.sqs.SqsClient)3 Then (io.cucumber.java.en.Then)2 HashSet (java.util.HashSet)2 Map (java.util.Map)2 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 JsonMappingException (com.fasterxml.jackson.databind.JsonMappingException)1 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 IOException (java.io.IOException)1 FALSE (java.lang.Boolean.FALSE)1 TRUE (java.lang.Boolean.TRUE)1 UTF_8 (java.nio.charset.StandardCharsets.UTF_8)1 Clock (java.time.Clock)1 ArrayDeque (java.util.ArrayDeque)1 ArrayList (java.util.ArrayList)1 LinkedHashMap (java.util.LinkedHashMap)1 List (java.util.List)1 NoSuchElementException (java.util.NoSuchElementException)1