-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support Collection of strings and JsonArray as mail recipients in Mai…
…lActivityBehavior (#3671) Co-authored-by: Roman Saratz <[email protected]>
- Loading branch information
Showing
5 changed files
with
261 additions
and
83 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,7 @@ | |
import java.nio.charset.Charset; | ||
import java.nio.charset.StandardCharsets; | ||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
|
@@ -41,6 +42,9 @@ | |
import org.subethamail.wiser.Wiser; | ||
import org.subethamail.wiser.WiserMessage; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.fasterxml.jackson.databind.node.ArrayNode; | ||
|
||
/** | ||
* @author Joram Barrez | ||
*/ | ||
|
@@ -162,6 +166,44 @@ public void testTextMailExpressions() { | |
|
||
} | ||
|
||
@Test | ||
@CmmnDeployment(resources = "org/flowable/cmmn/test/task/CmmnMailTaskTest.testTextMailExpressions.cmmn") | ||
public void testDynamicRecipientsStringList() throws MessagingException { | ||
String recipients = "flowable@localhost, [email protected]"; | ||
testDynamicRecipientsInternal(recipients); | ||
} | ||
|
||
@Test | ||
@CmmnDeployment(resources = "org/flowable/cmmn/test/task/CmmnMailTaskTest.testTextMailExpressions.cmmn") | ||
public void testDynamicRecipientsArrayList() throws MessagingException { | ||
List<String> recipients = Arrays.asList("flowable@localhost", "[email protected]"); | ||
testDynamicRecipientsInternal(recipients); | ||
} | ||
|
||
@Test | ||
@CmmnDeployment(resources = "org/flowable/cmmn/test/task/CmmnMailTaskTest.testTextMailExpressions.cmmn") | ||
public void testDynamicRecipientsArrayNode() throws MessagingException { | ||
ArrayNode recipients = new ObjectMapper().createArrayNode().add("flowable@localhost").add("[email protected]"); | ||
testDynamicRecipientsInternal(recipients); | ||
} | ||
|
||
private void testDynamicRecipientsInternal(Object recipients) throws MessagingException { | ||
cmmnRuntimeService.createCaseInstanceBuilder() | ||
.caseDefinitionKey("testMail") | ||
.variable("toVar", recipients) | ||
.variable("fromVar", "[email protected]") | ||
.variable("ccVar", recipients) | ||
.variable("bccVar", recipients) | ||
.variable("subjectVar", "Testing") | ||
.variable("bodyVar", "The test body") | ||
.start(); | ||
List<WiserMessage> messages = wiser.getMessages(); | ||
MimeMessage mimeMessage = messages.get(0).getMimeMessage(); | ||
assertThat(mimeMessage.getHeader("To", null)).isEqualTo("flowable@localhost, [email protected]"); | ||
assertThat(mimeMessage.getHeader("Cc", null)).isEqualTo("flowable@localhost, [email protected]"); | ||
|
||
} | ||
|
||
@Test | ||
@CmmnDeployment | ||
public void testCcBccWithoutTo() { | ||
|
Oops, something went wrong.