use of com.zimbra.cs.mime.ParsedContact in project zm-mailbox by Zimbra.
the class ContactTest method tooLongSender.
@Test
public void tooLongSender() throws Exception {
Mailbox mbox = MailboxManager.getInstance().getMailboxByAccountId(MockProvisioning.DEFAULT_ACCOUNT_ID);
Map<String, Object> fields = new HashMap<String, Object>();
fields.put(ContactConstants.A_firstName, Strings.repeat("F", 129));
Contact contact = mbox.createContact(null, new ParsedContact(fields), Mailbox.ID_FOLDER_CONTACTS, null);
DbConnection conn = DbPool.getConnection(mbox);
Assert.assertEquals(Strings.repeat("F", 128), DbUtil.executeQuery(conn, "SELECT sender FROM mboxgroup1.mail_item WHERE mailbox_id = ? AND id = ?", mbox.getId(), contact.getId()).getString(1));
fields.put(ContactConstants.A_firstName, null);
fields.put(ContactConstants.A_lastName, Strings.repeat("L", 129));
mbox.modifyContact(null, contact.getId(), new ParsedContact(fields));
Assert.assertEquals(Strings.repeat("L", 128), DbUtil.executeQuery(conn, "SELECT sender FROM mboxgroup1.mail_item WHERE mailbox_id = ? AND id = ?", mbox.getId(), contact.getId()).getString(1));
conn.closeQuietly();
}
use of com.zimbra.cs.mime.ParsedContact in project zm-mailbox by Zimbra.
the class ContactTest method testEncodeContact.
@Test
public void testEncodeContact() throws Exception {
Mailbox mbox = MailboxManager.getInstance().getMailboxByAccountId(MockProvisioning.DEFAULT_ACCOUNT_ID);
Map<String, Object> fields = new HashMap<String, Object>();
fields.put(ContactConstants.A_userCertificate, "{\"ZMVAL\":[\"Cert1149638887753217\"]}");
Contact contact = mbox.createContact(null, new ParsedContact(fields), Mailbox.ID_FOLDER_CONTACTS, null);
Element response = new Element.XMLElement(MailConstants.MODIFY_CONTACT_RESPONSE);
Account acct = Provisioning.getInstance().get(Key.AccountBy.name, "test@zimbra.com");
ToXML.encodeContact(response, new ItemIdFormatter(), new OperationContext(acct), contact, true, null);
Assert.assertEquals(response.getElement("cn").getElement("a").getText(), "Cert1149638887753217");
}
use of com.zimbra.cs.mime.ParsedContact in project zm-mailbox by Zimbra.
the class ContactAutoCompleteTest method reservedQueryTerm.
@Test
public void reservedQueryTerm() throws Exception {
Mailbox mbox = MailboxManager.getInstance().getMailboxByAccountId(MockProvisioning.DEFAULT_ACCOUNT_ID);
Map<String, Object> fields = new HashMap<String, Object>();
fields.put(ContactConstants.A_firstName, "not and or");
fields.put(ContactConstants.A_lastName, "subject: from:");
fields.put(ContactConstants.A_email, "test@zimbra.com");
mbox.createContact(null, new ParsedContact(fields), Mailbox.ID_FOLDER_CONTACTS, null);
ContactAutoComplete autocomplete = new ContactAutoComplete(mbox.getAccount(), new OperationContext(mbox));
Assert.assertEquals(1, autocomplete.query("not", null, 100).entries.size());
Assert.assertEquals(1, autocomplete.query("not and", null, 100).entries.size());
Assert.assertEquals(1, autocomplete.query("not and or", null, 100).entries.size());
Assert.assertEquals(1, autocomplete.query("subject:", null, 100).entries.size());
Assert.assertEquals(1, autocomplete.query("subject: from:", null, 100).entries.size());
}
use of com.zimbra.cs.mime.ParsedContact in project zm-mailbox by Zimbra.
the class ContactAutoCompleteTest method spaceInFirstName.
@Test
public void spaceInFirstName() throws Exception {
Mailbox mbox = MailboxManager.getInstance().getMailboxByAccountId(MockProvisioning.DEFAULT_ACCOUNT_ID);
Map<String, Object> fields = new HashMap<String, Object>();
fields.put(ContactConstants.A_firstName, "First Second Third Forth");
fields.put(ContactConstants.A_lastName, "Last");
fields.put(ContactConstants.A_email, "test@zimbra.com");
mbox.createContact(null, new ParsedContact(fields), Mailbox.ID_FOLDER_CONTACTS, null);
ContactAutoComplete autocomplete = new ContactAutoComplete(mbox.getAccount(), new OperationContext(mbox));
Assert.assertEquals(1, autocomplete.query("first second third forth", null, 100).entries.size());
}
use of com.zimbra.cs.mime.ParsedContact in project zm-mailbox by Zimbra.
the class ContactAutoCompleteTest method lastNameFirstName.
@Test
public void lastNameFirstName() throws Exception {
Mailbox mbox = MailboxManager.getInstance().getMailboxByAccountId(MockProvisioning.DEFAULT_ACCOUNT_ID);
Map<String, Object> fields = new HashMap<String, Object>();
fields.put(ContactConstants.A_firstName, "First");
fields.put(ContactConstants.A_lastName, "Last");
fields.put(ContactConstants.A_email, "test@zimbra.com");
mbox.createContact(null, new ParsedContact(fields), Mailbox.ID_FOLDER_CONTACTS, null);
ContactAutoComplete autocomplete = new ContactAutoComplete(mbox.getAccount(), new OperationContext(mbox));
Assert.assertEquals(1, autocomplete.query("first last", null, 100).entries.size());
Assert.assertEquals(1, autocomplete.query("last first", null, 100).entries.size());
}
Aggregations