use of com.zimbra.client.ZEmailAddress in project zm-mailbox by Zimbra.
the class TestFilter method testNotifyActionUseOrigHeaders.
@Test
public void testNotifyActionUseOrigHeaders() throws Exception {
if (mAvailableRFCCompliantNotify) {
fail("Unable to test because 'zimbraSieveNotifyActionRFCCompliant' is set to TRUE");
return;
}
List<ZFilterRule> rules = new ArrayList<ZFilterRule>();
List<ZFilterCondition> conditions = new ArrayList<ZFilterCondition>();
List<ZFilterAction> actions = new ArrayList<ZFilterAction>();
conditions.add(new ZFilterCondition.ZTrueCondition());
// add an action to notify user2
// copy headers From,To,Cc,Subject from the original message onto the notification message
actions.add(new ZFilterAction.ZNotifyAction(TestUtil.getAddress(REMOTE_USER_NAME), null, "${BODY}", -1, "From,To,Cc,Subject"));
rules.add(new ZFilterRule("testNotifyActionUseOrigHeaders", true, false, conditions, actions));
saveIncomingRules(mMbox, new ZFilterRules(rules));
String subject = NAME_PREFIX + " testNotifyActionUseOrigHeaders";
String body = "Hi, How r u?";
String msg = new MessageBuilder().withFrom(REMOTE_USER_NAME).withToRecipient(USER_NAME).withCcRecipient(USER_NAME).withSubject(subject).withBody(body).create();
// send msg to user1
TestUtil.addMessageLmtp(new String[] { USER_NAME }, REMOTE_USER_NAME, msg);
// check notification msg from user1 in user2's mailbox
ZMessage zMessage = TestUtil.waitForMessage(TestUtil.getZMailbox(REMOTE_USER_NAME), "in:inbox subject:\"" + subject + "\"");
boolean checkedFrom = false, checkedTo = false, checkedCc = false;
List<ZEmailAddress> msgAddrs = zMessage.getEmailAddresses();
for (ZEmailAddress addr : msgAddrs) {
if ("f".equals(addr.getType())) {
assertEquals(TestUtil.addDomainIfNecessary(REMOTE_USER_NAME), addr.getAddress());
if (!checkedFrom) {
checkedFrom = true;
} else {
fail("multiple From addresses");
}
}
if ("t".equals(addr.getType())) {
assertEquals(TestUtil.addDomainIfNecessary(USER_NAME), addr.getAddress());
if (!checkedTo) {
checkedTo = true;
} else {
fail("multiple To addresses");
}
}
if ("c".equals(addr.getType())) {
assertEquals(TestUtil.addDomainIfNecessary(USER_NAME), addr.getAddress());
if (!checkedCc) {
checkedCc = true;
} else {
fail("multiple Cc addresses");
}
}
}
assertEquals(subject, zMessage.getSubject());
}
use of com.zimbra.client.ZEmailAddress in project zm-mailbox by Zimbra.
the class TestDraftCount method testSomeDraftsHaveRecipients.
@Test
public void testSomeDraftsHaveRecipients() throws Exception {
for (int i = 0; i < numMsgs; i++) {
ZOutgoingMessage msg = new ZOutgoingMessage();
msg.setMessagePart(new MessagePart("text/plain", "test body " + i));
msg.setSubject("test message " + i);
List<ZEmailAddress> addresses = new ArrayList<ZEmailAddress>();
if (i % 2 == 0) {
addresses.add(new ZEmailAddress("testuser" + i, null, null, "t"));
msg.setAddresses(addresses);
}
ZMessage saved = mbox.saveDraft(msg, null, "6");
}
checkMessageCount("in:drafts", numMsgs);
deleteFromQuery("in:drafts");
}
use of com.zimbra.client.ZEmailAddress in project zm-mailbox by Zimbra.
the class TestDraftCount method testAllDraftsHaveRecipients.
@Test
public void testAllDraftsHaveRecipients() throws Exception {
for (int i = 0; i < numMsgs; i++) {
ZOutgoingMessage msg = new ZOutgoingMessage();
msg.setMessagePart(new MessagePart("text/plain", "test body " + i));
msg.setSubject("test message " + i);
List<ZEmailAddress> addresses = new ArrayList<ZEmailAddress>();
addresses.add(new ZEmailAddress("testuser" + i, null, null, "t"));
msg.setAddresses(addresses);
ZMessage saved = mbox.saveDraft(msg, null, "6");
}
checkMessageCount("in:drafts", numMsgs);
deleteFromQuery("in:drafts");
}
use of com.zimbra.client.ZEmailAddress in project zm-mailbox by Zimbra.
the class ZConversationSummaryEvent method toZJSONObject.
public ZJSONObject toZJSONObject() throws JSONException {
try {
ZJSONObject zjo = new ZJSONObject();
zjo.put("id", getId());
if (getFlags(null) != null)
zjo.put("flags", getFlags(null));
if (getTagIds(null) != null)
zjo.put("tags", getTagIds(null));
if (getSubject(null) != null)
zjo.put("subject", getSubject(null));
if (getFragment(null) != null)
zjo.put("fragment", getFragment(null));
if (getMessageCount(-1) != -1)
zjo.put("messageCount", getMessageCount(-1));
if (getDate(-1) != -1)
zjo.put("date", getDate(-1));
List<ZEmailAddress> addrs = getRecipients(null);
if (addrs != null)
zjo.put("recipients", addrs);
return zjo;
} catch (ServiceException se) {
throw new JSONException(se);
}
}
use of com.zimbra.client.ZEmailAddress in project zm-mailbox by Zimbra.
the class ZCreateMessageEvent method toZJSONObject.
public ZJSONObject toZJSONObject() throws JSONException {
try {
ZJSONObject zjo = new ZJSONObject();
zjo.put("id", getId());
if (getFolderId(null) != null)
zjo.put("folderId", getFolderId(null));
if (getConversationId(null) != null)
zjo.put("conversationId", getConversationId(null));
if (getFlags(null) != null)
zjo.put("flags", getFlags(null));
if (getTagIds(null) != null)
zjo.put("tags", getTagIds(null));
if (getSubject(null) != null)
zjo.put("subject", getSubject(null));
if (getFragment(null) != null)
zjo.put("fragment", getFragment(null));
if (getSize(-1) != -1)
zjo.put("size", getSize(-1));
if (getReceivedDate(-1) != -1)
zjo.put("receivedDate", getReceivedDate(-1));
if (getSentDate(-1) != -1)
zjo.put("sentDate", getSentDate(-1));
List<ZEmailAddress> addrs = getEmailAddresses(null);
if (addrs != null)
zjo.put("addresses", addrs);
return zjo;
} catch (ServiceException se) {
throw new JSONException(se);
}
}
Aggregations