From 768bcfb5092fb240adbe528103c06d7796a709bc Mon Sep 17 00:00:00 2001 From: Pierre Villard Date: Tue, 25 Sep 2018 22:53:28 +0200 Subject: [PATCH] NIFI-5635 - Description PutEmail properties with multiple senders/recipients This closes #3031 Signed-off-by: Mike Moser --- .../apache/nifi/processors/standard/PutEmail.java | 12 ++++++++---- .../nifi/processors/standard/TestPutEmail.java | 14 ++++++++++---- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/PutEmail.java b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/PutEmail.java index 8fdcc14e8e..b7b8232802 100644 --- a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/PutEmail.java +++ b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/PutEmail.java @@ -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) diff --git a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestPutEmail.java b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestPutEmail.java index 7df04ba61d..97ff77effd 100644 --- a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestPutEmail.java +++ b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestPutEmail.java @@ -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 attributes = new HashMap(); @@ -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()); } }