-
Notifications
You must be signed in to change notification settings - Fork 5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CAMEL-21608: (aws2-ses) Support message tags
Enhance to add support for message tags to the aws2-ses component. Tags are useful for providing user-defined metadata that will appear in email tracking events related to the sent email.
- Loading branch information
1 parent
a2eff0e
commit 9366d2c
Showing
6 changed files
with
66 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,18 +16,20 @@ | |
*/ | ||
package org.apache.camel.component.aws2.ses; | ||
|
||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import org.apache.camel.BindToRegistry; | ||
import org.apache.camel.Exchange; | ||
import org.apache.camel.Processor; | ||
import org.apache.camel.builder.RouteBuilder; | ||
import org.apache.camel.test.junit5.CamelTestSupport; | ||
import org.junit.jupiter.api.Test; | ||
import software.amazon.awssdk.services.ses.model.MessageTag; | ||
import software.amazon.awssdk.services.ses.model.SendEmailRequest; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
public class SesComponentTest extends CamelTestSupport { | ||
|
||
|
@@ -55,6 +57,8 @@ public void process(Exchange exchange) { | |
assertTrue(sendEmailRequest.replyToAddresses().contains("[email protected]")); | ||
assertTrue(sendEmailRequest.replyToAddresses().contains("[email protected]")); | ||
assertEquals("Subject", getSubject(sendEmailRequest)); | ||
assertFalse(sendEmailRequest.hasTags()); | ||
assertEquals(0, sendEmailRequest.tags().size()); | ||
assertEquals("This is my message text.", getBody(sendEmailRequest)); | ||
} | ||
|
||
|
@@ -81,6 +85,7 @@ public void process(Exchange exchange) { | |
exchange.getIn().setHeader(Ses2Constants.REPLY_TO_ADDRESSES, | ||
"[email protected], [email protected]"); | ||
exchange.getIn().setHeader(Ses2Constants.SUBJECT, "anotherSubject"); | ||
exchange.getIn().setHeader(Ses2Constants.TAGS, Map.of("tagName", "tagValue")); | ||
} | ||
}); | ||
|
||
|
@@ -97,6 +102,24 @@ public void process(Exchange exchange) { | |
assertTrue(sendEmailRequest.replyToAddresses().contains("[email protected]")); | ||
assertEquals("anotherSubject", getSubject(sendEmailRequest)); | ||
assertEquals("This is my message text.", getBody(sendEmailRequest)); | ||
assertTrue(sendEmailRequest.hasTags()); | ||
assertEquals(List.of(MessageTag.builder().name("tagName").value("tagValue").build()), sendEmailRequest.tags()); | ||
} | ||
|
||
@Test | ||
public void sendMessageWithEmptyMessageTagsHeader() { | ||
Exchange exchange = template.send("direct:start", new Processor() { | ||
public void process(Exchange exchange) { | ||
exchange.getIn().setBody("This is my message text."); | ||
exchange.getIn().setHeader(Ses2Constants.TAGS, new HashMap<String, String>()); | ||
} | ||
}); | ||
|
||
assertEquals("1", exchange.getIn().getHeader(Ses2Constants.MESSAGE_ID)); | ||
|
||
SendEmailRequest sendEmailRequest = sesClient.getSendEmailRequest(); | ||
assertFalse(sendEmailRequest.hasTags()); | ||
assertEquals(0, sendEmailRequest.tags().size()); | ||
} | ||
|
||
@Override | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters