@Test public void quick() throws Exception { Mailbox mbox = MailboxManager.getInstance().getMailboxByAccountId(MockProvisioning.DEFAULT_ACCOUNT_ID); Contact contact = mbox.createContact( null, new ParsedContact( Collections.singletonMap(ContactConstants.A_email, "*****@*****.**")), Mailbox.ID_FOLDER_CONTACTS, null); MailboxTestUtil.index(mbox); mbox.createContact( null, new ParsedContact(Collections.singletonMap(ContactConstants.A_email, "*****@*****.**")), Mailbox.ID_FOLDER_CONTACTS, null); SearchParams params = new SearchParams(); params.setQueryString("test"); params.setSortBy(SortBy.NONE); params.setTypes(EnumSet.of(MailItem.Type.CONTACT)); params.setQuick(true); ZimbraQuery query = new ZimbraQuery(new OperationContext(mbox), SoapProtocol.Soap12, mbox, params); ZimbraQueryResults result = query.execute(); Assert.assertTrue(result.hasNext()); Assert.assertEquals(contact.getId(), result.getNext().getItemId()); Assert.assertFalse(result.hasNext()); Closeables.closeQuietly(result); }
@Test public void suggest() throws Exception { Mailbox mbox = MailboxManager.getInstance().getMailboxByAccountId(MockProvisioning.DEFAULT_ACCOUNT_ID); DeliveryOptions dopt = new DeliveryOptions().setFolderId(Mailbox.ID_FOLDER_INBOX); Message msg = mbox.addMessage( null, new ParsedMessage("Subject: all hands meeting".getBytes(), false), dopt, null); MailboxTestUtil.index(mbox); SearchParams params = new SearchParams(); params.setQueryString("all hands me"); params.setSortBy(SortBy.NONE); params.setTypes(EnumSet.of(MailItem.Type.MESSAGE)); params.setQuick(true); ZimbraQuery query = new ZimbraQuery(new OperationContext(mbox), SoapProtocol.Soap12, mbox, params); ZimbraQueryResults result = query.execute(); Assert.assertEquals(msg.getId(), result.getNext().getItemId()); Closeables.closeQuietly(result); }
@Before public void setUp() throws Exception { MailboxTestUtil.clearData(); }
@BeforeClass public static void init() throws Exception { MailboxTestUtil.initServer(); Provisioning prov = Provisioning.getInstance(); prov.createAccount("*****@*****.**", "secret", new HashMap<String, Object>()); }