NIFI-5635 - Description PutEmail properties with multiple senders/recipients

This closes #3031

Signed-off-by: Mike Moser <mosermw@apache.org>
This commit is contained in:
Pierre Villard 2018-09-25 22:53:28 +02:00 committed by Mike Moser
parent 246c090526
commit 768bcfb509
2 changed files with 18 additions and 8 deletions

View File

@ -165,28 +165,32 @@ public class PutEmail extends AbstractProcessor {
.build();
public static final PropertyDescriptor FROM = new PropertyDescriptor.Builder()
.name("From")
.description("Specifies the Email address to use as the sender")
.description("Specifies the Email address to use as the sender. "
+ "Comma separated sequence of addresses following RFC822 syntax.")
.required(true)
.expressionLanguageSupported(ExpressionLanguageScope.FLOWFILE_ATTRIBUTES)
.addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
.build();
public static final PropertyDescriptor TO = new PropertyDescriptor.Builder()
.name("To")
.description("The recipients to include in the To-Line of the email")
.description("The recipients to include in the To-Line of the email. "
+ "Comma separated sequence of addresses following RFC822 syntax.")
.required(false)
.expressionLanguageSupported(ExpressionLanguageScope.FLOWFILE_ATTRIBUTES)
.addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
.build();
public static final PropertyDescriptor CC = new PropertyDescriptor.Builder()
.name("CC")
.description("The recipients to include in the CC-Line of the email")
.description("The recipients to include in the CC-Line of the email. "
+ "Comma separated sequence of addresses following RFC822 syntax.")
.required(false)
.expressionLanguageSupported(ExpressionLanguageScope.FLOWFILE_ATTRIBUTES)
.addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
.build();
public static final PropertyDescriptor BCC = new PropertyDescriptor.Builder()
.name("BCC")
.description("The recipients to include in the BCC-Line of the email")
.description("The recipients to include in the BCC-Line of the email. "
+ "Comma separated sequence of addresses following RFC822 syntax.")
.required(false)
.expressionLanguageSupported(ExpressionLanguageScope.FLOWFILE_ATTRIBUTES)
.addValidator(StandardValidators.NON_EMPTY_VALIDATOR)

View File

@ -264,9 +264,11 @@ public class TestPutEmail {
// verifies that are set on the outgoing Message correctly
runner.setProperty(PutEmail.SMTP_HOSTNAME, "smtp-host");
runner.setProperty(PutEmail.HEADER_XMAILER, "TestingNiFi");
runner.setProperty(PutEmail.FROM, "test@apache.org");
runner.setProperty(PutEmail.FROM, "test@apache.org,from@apache.org");
runner.setProperty(PutEmail.MESSAGE, "${body}");
runner.setProperty(PutEmail.TO, "recipient@apache.org");
runner.setProperty(PutEmail.TO, "recipient@apache.org,another@apache.org");
runner.setProperty(PutEmail.CC, "recipientcc@apache.org,anothercc@apache.org");
runner.setProperty(PutEmail.BCC, "recipientbcc@apache.org,anotherbcc@apache.org");
runner.setProperty(PutEmail.CONTENT_AS_MESSAGE, "${sendContent}");
Map<String, String> attributes = new HashMap<String, String>();
@ -283,11 +285,15 @@ public class TestPutEmail {
assertEquals("Expected a single message to be sent", 1, processor.getMessages().size());
Message message = processor.getMessages().get(0);
assertEquals("test@apache.org", message.getFrom()[0].toString());
assertEquals("from@apache.org", message.getFrom()[1].toString());
assertEquals("X-Mailer Header", "TestingNiFi", message.getHeader("X-Mailer")[0]);
assertEquals("Some Text", message.getContent());
assertEquals("recipient@apache.org", message.getRecipients(RecipientType.TO)[0].toString());
assertNull(message.getRecipients(RecipientType.BCC));
assertNull(message.getRecipients(RecipientType.CC));
assertEquals("another@apache.org", message.getRecipients(RecipientType.TO)[1].toString());
assertEquals("recipientcc@apache.org", message.getRecipients(RecipientType.CC)[0].toString());
assertEquals("anothercc@apache.org", message.getRecipients(RecipientType.CC)[1].toString());
assertEquals("recipientbcc@apache.org", message.getRecipients(RecipientType.BCC)[0].toString());
assertEquals("anotherbcc@apache.org", message.getRecipients(RecipientType.BCC)[1].toString());
}
}