Search in sources :

Example 6 with ZSearchResult

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

the class TestMinusOperator method testExcludeRecipient.

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

Example 7 with ZSearchResult

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

the class TestDataSource method testPop3.

@Test
public void testPop3() throws Exception {
    Account pop3acct = TestUtil.getAccount(TEST_USER_NAME);
    ZMailbox pop3mbox = TestUtil.getZMailbox(TEST_USER_NAME);
    ZMailbox mbox = TestUtil.getZMailbox(USER_NAME);
    String pop3DSFolder = NAME_PREFIX + " testPop3 source";
    String pop3DSFolderId = createFolderForDataSource(mbox, pop3DSFolder);
    String dsId = createPop3DataSource(mbox, pop3acct.getName(), pop3DSFolderId);
    String subj = NAME_PREFIX + " testtrashpop3";
    addMessage(pop3mbox, subj, "test");
    refreshPop3DatasourceData(mbox, dsId);
    ZSearchParams params = new ZSearchParams(String.format("subject:\"%s\"", subj));
    params.setTypes("MESSAGE");
    ZSearchResult result = mbox.search(params);
    ZSearchHit hit = result.getHits().get(0);
    String id = hit.getId();
    try {
        mbox.trashMessage(id);
    } catch (SoapFaultException sfe) {
        fail("SoapFaultException caught when deleting item from Pop3 datasource folder - " + sfe.getMessage());
    }
    params = new ZSearchParams("in:Trash");
    params.setTypes("MESSAGE");
    result = mbox.search(params);
    List<ZSearchHit> hits = result.getHits();
    assertEquals(1, hits.size());
    assertEquals(id, hits.get(0).getId());
}
Also used : ZSearchResult(com.zimbra.client.ZSearchResult) Account(com.zimbra.cs.account.Account) ZSearchHit(com.zimbra.client.ZSearchHit) ZMailbox(com.zimbra.client.ZMailbox) ZSearchParams(com.zimbra.client.ZSearchParams) SoapFaultException(com.zimbra.common.soap.SoapFaultException) Test(org.junit.Test)

Example 8 with ZSearchResult

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

the class TestUtil method searchMessageIds.

public static List<String> searchMessageIds(ZMailbox mbox, ZSearchParams params) throws ServiceException {
    List<String> msgsIds = new ArrayList<String>();
    ZSearchResult results = mbox.search(params);
    for (ZSearchHit hit : results.getHits()) {
        msgsIds.add(hit.getId());
    }
    return msgsIds;
}
Also used : ZSearchResult(com.zimbra.client.ZSearchResult) ZSearchHit(com.zimbra.client.ZSearchHit) ArrayList(java.util.ArrayList)

Example 9 with ZSearchResult

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

the class ZMailboxUtil method doSearchConvRedisplay.

private void doSearchConvRedisplay() {
    ZSearchResult sr = mConvSearchResult;
    if (sr == null)
        return;
    dumpConvSearch(mConvSearchResult, verboseOpt());
}
Also used : ZSearchResult(com.zimbra.client.ZSearchResult)

Example 10 with ZSearchResult

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

the class TestPurgeDataSource method doSearch.

private List<ZSearchHit> doSearch(String query) throws ServiceException {
    ZSearchParams params = new ZSearchParams(query);
    params.setFetch(Fetch.all);
    params.setSortBy(SearchSortBy.dateDesc);
    ZSearchResult result = mbox.search(params);
    List<ZSearchHit> hits = result.getHits();
    return hits;
}
Also used : ZSearchResult(com.zimbra.client.ZSearchResult) ZSearchHit(com.zimbra.client.ZSearchHit) ZSearchParams(com.zimbra.client.ZSearchParams)

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