Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,13 @@ public TaskResult runTask()

List<String> toList;
try {
toList = params.getList("to", String.class);
toList = params.parseList("to", String.class);
}
catch (ConfigException ex) {
toList = ImmutableList.of(params.get("to", String.class));
}
List<String> bccList = params.getListOrEmpty("bcc", String.class);
List<String> ccList = params.getListOrEmpty("cc", String.class);
List<String> bccList = params.parseListOrGetEmpty("bcc", String.class);
List<String> ccList = params.parseListOrGetEmpty("cc", String.class);

boolean isHtml = params.get("html", boolean.class, false);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,68 @@ public void errorCheckStringBcc()
}
}

@Test
public void sendToWithArrayVariable()
{
// This test simulates what happens when you write:
// _export:
// address_list: ["bob@example.com", "charlie@example.com"]
// +task:
// mail>:
// to: ${address_list}
//
// After template substitution, the "to" parameter becomes a JSON string like:
// '["bob@example.com", "charlie@example.com"]'
//
// The parseList method should parse this JSON string and convert it to a List
Config config = mailConfig.deepCopy();
config.set("to", "[\"bob@example.com\", \"charlie@example.com\"]");

Operator op = factory.newOperator(newContext(
tempPath,
newTaskRequest().withConfig(config)));
op.run();
greenMail.waitForIncomingEmail(5000, 2);
receiveCheck("bob@example.com", 1);
receiveCheck("charlie@example.com", 1);
}

@Test
public void sendCcWithArrayVariable()
{
// After template substitution, the "cc" parameter becomes a JSON string
Config config = mailConfig.deepCopy();
config.set("to", "bob@example.com");
config.set("cc", "[\"charlie@example.com\", \"david@example.com\"]");

Operator op = factory.newOperator(newContext(
tempPath,
newTaskRequest().withConfig(config)));
op.run();
greenMail.waitForIncomingEmail(5000, 3);
receiveCheck("bob@example.com", 1);
receiveCheck("charlie@example.com", 1);
receiveCheck("david@example.com", 1);
}

@Test
public void sendBccWithArrayVariable()
{
// After template substitution, the "bcc" parameter becomes a JSON string
Config config = mailConfig.deepCopy();
config.set("to", "bob@example.com");
config.set("bcc", "[\"charlie@example.com\", \"david@example.com\"]");

Operator op = factory.newOperator(newContext(
tempPath,
newTaskRequest().withConfig(config)));
op.run();
greenMail.waitForIncomingEmail(5000, 3);
receiveCheck("bob@example.com", 1);
receiveCheck("charlie@example.com", 1);
receiveCheck("david@example.com", 1);
}

private void receiveCheck(String user, int size)
{
AbstractServer server = greenMail.getPop3();
Expand Down
Loading