Search in sources :

Example 16 with ZSearchResult

use of com.zimbra.client.ZSearchResult 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)

Example 17 with ZSearchResult

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

the class TestSearchJunkTrash method testTrashOrNotJunk.

@Test
public void testTrashOrNotJunk() throws ServiceException {
    //resolves to trash only
    ZSearchParams params = new ZSearchParams(String.format("(in:trash OR NOT in:junk) (inid:%s OR is:local)", folder.getId()));
    ZSearchResult results = mbox.search(params);
    assertEquals(1, results.getHits().size());
}
Also used : ZSearchResult(com.zimbra.client.ZSearchResult) ZSearchParams(com.zimbra.client.ZSearchParams) Test(org.junit.Test)

Example 18 with ZSearchResult

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

the class TestSearchJunkTrash method testJunk.

@Test
public void testJunk() throws ServiceException {
    ZSearchParams params = new ZSearchParams(String.format("(in:junk) (inid:%s OR is:local)", folder.getId()));
    ZSearchResult results = mbox.search(params);
    assertEquals(2, results.getHits().size());
}
Also used : ZSearchResult(com.zimbra.client.ZSearchResult) ZSearchParams(com.zimbra.client.ZSearchParams) Test(org.junit.Test)

Example 19 with ZSearchResult

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

the class TestMinusOperator method testExcludeText.

@Test
public void testExcludeText() throws ServiceException {
    ZSearchResult search1 = mbox.search(new ZSearchParams("in:sent test"));
    //control
    assertEquals(search1.getHits().size(), 1);
    ZSearchResult search2 = mbox.search(new ZSearchParams("in:sent -test"));
    assertEquals(search2.getHits().size(), 0);
}
Also used : ZSearchResult(com.zimbra.client.ZSearchResult) ZSearchParams(com.zimbra.client.ZSearchParams) Test(org.junit.Test)

Aggregations

ZSearchResult (com.zimbra.client.ZSearchResult)19 ZSearchParams (com.zimbra.client.ZSearchParams)17 Test (org.junit.Test)12 ZSearchHit (com.zimbra.client.ZSearchHit)8 ArrayList (java.util.ArrayList)2 ZMailbox (com.zimbra.client.ZMailbox)1 ZMessageHit (com.zimbra.client.ZMessageHit)1 SoapFaultException (com.zimbra.common.soap.SoapFaultException)1 Account (com.zimbra.cs.account.Account)1