Search in sources :

Example 16 with ZSearchParams

use of com.zimbra.client.ZSearchParams in project zm-mailbox by Zimbra.

the class ZMailboxUtil method doSearchConvPrevious.

private void doSearchConvPrevious() throws ServiceException {
    ZSearchParams sp = mConvSearchParams;
    ZSearchResult sr = mConvSearchResult;
    if (sp == null || sr == null || sp.getOffset() == 0)
        return;
    sp.setOffset(sp.getOffset() - sr.getHits().size());
    dumpConvSearch(mMbox.searchConversation(mConvSearchConvId, sp), verboseOpt());
}
Also used : ZSearchResult(com.zimbra.client.ZSearchResult) ZSearchParams(com.zimbra.client.ZSearchParams)

Example 17 with ZSearchParams

use of com.zimbra.client.ZSearchParams in project zm-mailbox by Zimbra.

the class TestDraftCount method checkMessageCount.

private void checkMessageCount(String query, int expected) throws Exception {
    ZSearchParams params = new ZSearchParams(query);
    params.setTypes("message");
    params.setOffset(0);
    params.setSortBy(SearchSortBy.rcptAsc);
    ZSearchResult results = mbox.search(params);
    assertEquals(expected, results.getHits().size());
    params.setSortBy(SearchSortBy.rcptDesc);
    results = mbox.search(params);
    assertEquals(expected, results.getHits().size());
}
Also used : ZSearchResult(com.zimbra.client.ZSearchResult) ZSearchParams(com.zimbra.client.ZSearchParams)

Example 18 with ZSearchParams

use of com.zimbra.client.ZSearchParams in project zm-mailbox by Zimbra.

the class TestDraftCount method deleteFromQuery.

private void deleteFromQuery(String query) throws Exception {
    //delete all messages currently in drafts folder
    ZSearchParams params = new ZSearchParams(query);
    params.setTypes("message");
    params.setOffset(0);
    ZSearchResult results = mbox.search(params);
    for (ZSearchHit hit : results.getHits()) {
        ZMessageHit msg = (ZMessageHit) hit;
        mbox.deleteMessage(hit.getId());
    }
}
Also used : ZSearchResult(com.zimbra.client.ZSearchResult) ZSearchHit(com.zimbra.client.ZSearchHit) ZSearchParams(com.zimbra.client.ZSearchParams) ZMessageHit(com.zimbra.client.ZMessageHit)

Example 19 with ZSearchParams

use of com.zimbra.client.ZSearchParams in project zm-mailbox by Zimbra.

the class TestTrashImapMessage method testTrashImapMessage.

@Test
public void testTrashImapMessage() throws Exception {
    String subj = "testtrashimap";
    addMessage(imapDsMbox1, subj, "test");
    refreshImapData();
    ZSearchParams params = new ZSearchParams("subject:" + subj);
    params.setTypes("MESSAGE");
    ZSearchResult result = mbox.search(params);
    ZSearchHit hit = result.getHits().get(0);
    String id = hit.getId();
    msgIds.add(id);
    mbox.trashMessage(id);
    params = new ZSearchParams("in:\"" + IMAP_DS_1_FOLDER_NAME + "/Trash\"");
    params.setTypes("MESSAGE");
    result = mbox.search(params);
    List<ZSearchHit> hits = result.getHits();
    Assert.assertEquals(1, hits.size());
    Assert.assertEquals(id, hits.get(0).getId());
}
Also used : ZSearchResult(com.zimbra.client.ZSearchResult) ZSearchHit(com.zimbra.client.ZSearchHit) ZSearchParams(com.zimbra.client.ZSearchParams) Test(org.junit.Test)

Example 20 with ZSearchParams

use of com.zimbra.client.ZSearchParams in project zm-mailbox by Zimbra.

the class TestSearchConv method searchConversation.

@Test
public void searchConversation() throws Exception {
    ZimbraLog.search.debug("test %s", toString());
    markMessagesUnreadByIndex(unread);
    ZSearchParams params = new ZSearchParams(query);
    params.setFetch(fetch);
    ZSearchResult result = mbox.searchConversation(convId, params);
    List<ZSearchHit> hits = result.getHits();
    List<String> expandedList = new ArrayList<String>();
    for (Integer idx : expected) {
        expandedList.add(msgIds.get(idx));
    }
    for (ZSearchHit hit : hits) {
        boolean expanded = isExpanded(hit);
        if (expandedList.contains(hit.getId())) {
            assertTrue(String.format("%s expanded should be true for msgId=%s", toString(), hit.getId()), expanded);
            expandedList.remove(hit.getId());
        } else {
            assertFalse(String.format("%s expanded should be false for msgId=%s", toString(), hit.getId()), expanded);
        }
    }
    assertEquals(String.format("%s expandedList size", toString()), 0, expandedList.size());
}
Also used : ZSearchResult(com.zimbra.client.ZSearchResult) ZSearchHit(com.zimbra.client.ZSearchHit) ZSearchParams(com.zimbra.client.ZSearchParams) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Aggregations

ZSearchParams (com.zimbra.client.ZSearchParams)31 Test (org.junit.Test)21 ZSearchResult (com.zimbra.client.ZSearchResult)17 ArrayList (java.util.ArrayList)12 ZMailbox (com.zimbra.client.ZMailbox)11 ZSearchHit (com.zimbra.client.ZSearchHit)9 ServiceException (com.zimbra.common.service.ServiceException)9 Mailbox (com.zimbra.cs.mailbox.Mailbox)9 Message (com.zimbra.cs.mailbox.Message)9 ZMessage (com.zimbra.client.ZMessage)5 Cursor (com.zimbra.client.ZSearchParams.Cursor)4 ParsedMessage (com.zimbra.cs.mime.ParsedMessage)2 SearchSortBy (com.zimbra.soap.type.SearchSortBy)2 ZMessageHit (com.zimbra.client.ZMessageHit)1 ZSearchPagerResult (com.zimbra.client.ZSearchPagerResult)1 SoapFaultException (com.zimbra.common.soap.SoapFaultException)1 Account (com.zimbra.cs.account.Account)1 Date (java.util.Date)1