Search in sources :

Example 1 with ZSearchResult

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

the class TestSearchHeaders method testSearchNonTopLevelHeaders.

@Test
public void testSearchNonTopLevelHeaders() throws ServiceException {
    ZSearchParams params = new ZSearchParams("\"header search test\" #Content-Transfer-Encoding:8bit");
    params.setTypes("message");
    ZSearchResult result = mbox.search(params);
    boolean found = false;
    for (ZSearchHit hit : result.getHits()) {
        if (found == false && hit.getId().equals(id)) {
            found = true;
        }
    }
    assertTrue(found);
}
Also used : ZSearchResult(com.zimbra.client.ZSearchResult) ZSearchHit(com.zimbra.client.ZSearchHit) ZSearchParams(com.zimbra.client.ZSearchParams) Test(org.junit.Test)

Example 2 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 3 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 4 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));
    Assert.assertEquals(search1.getHits().size(), 1);
    ZSearchResult search2 = mbox.search(new ZSearchParams("in:sent -to:" + REMOTE_USER_NAME));
    Assert.assertEquals(search2.getHits().size(), 0);
}
Also used : ZSearchResult(com.zimbra.client.ZSearchResult) ZSearchParams(com.zimbra.client.ZSearchParams) Test(org.junit.Test)

Example 5 with ZSearchResult

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

the class TestSearchJunkTrash method testTrash.

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

Aggregations

ZSearchResult (com.zimbra.client.ZSearchResult)21 ZSearchParams (com.zimbra.client.ZSearchParams)19 Test (org.junit.Test)14 ZSearchHit (com.zimbra.client.ZSearchHit)9 ZMailbox (com.zimbra.client.ZMailbox)3 ArrayList (java.util.ArrayList)2 ZMessageHit (com.zimbra.client.ZMessageHit)1 SoapFaultException (com.zimbra.common.soap.SoapFaultException)1 Account (com.zimbra.cs.account.Account)1 Mailbox (com.zimbra.cs.mailbox.Mailbox)1