Search in sources :

Example 1 with SearchConvResponse

use of com.zimbra.soap.mail.message.SearchConvResponse in project zm-mailbox by Zimbra.

the class TestExpandGroupInfo method searchConversation.

@Test
public void searchConversation() throws Exception {
    // send a to acct, recipient is a group
    String SUBJECT = getTestName();
    sendMsg(acct, group.getName(), SUBJECT, "blah");
    SoapTransport transport = authUser(acct.getName());
    SearchRequest searchReq = new SearchRequest();
    searchReq.setSearchTypes(MailItem.Type.CONVERSATION.toString());
    searchReq.setQuery(String.format("in:inbox and subject:%s", SUBJECT));
    SearchResponse searchResp = invokeJaxb(transport, searchReq);
    List<SearchHit> searchHits = searchResp.getSearchHits();
    assertEquals(1, searchHits.size());
    SearchHit searchHit = searchHits.get(0);
    String convId = searchHit.getId();
    SearchConvRequest searchConvReq = new SearchConvRequest(convId);
    searchConvReq.setNeedCanExpand(Boolean.TRUE);
    searchConvReq.setFetch(SearchParams.ExpandResults.ALL.toString());
    SearchConvResponse searchConvResp = invokeJaxb(transport, searchConvReq);
    List<MessageHitInfo> hits = searchConvResp.getMessages();
    // 2 - one in inbox, one in sent folder
    assertEquals(2, hits.size());
    verifyGroupInfo(hits.get(0), Boolean.TRUE, Boolean.TRUE);
    verifyGroupInfo(hits.get(1), Boolean.TRUE, Boolean.TRUE);
}
Also used : SearchConvResponse(com.zimbra.soap.mail.message.SearchConvResponse) SearchRequest(com.zimbra.soap.mail.message.SearchRequest) SearchHit(com.zimbra.soap.type.SearchHit) SearchConvRequest(com.zimbra.soap.mail.message.SearchConvRequest) MessageHitInfo(com.zimbra.soap.mail.type.MessageHitInfo) SoapTransport(com.zimbra.common.soap.SoapTransport) SearchResponse(com.zimbra.soap.mail.message.SearchResponse) Test(org.junit.Test)

Aggregations

SoapTransport (com.zimbra.common.soap.SoapTransport)1 SearchConvRequest (com.zimbra.soap.mail.message.SearchConvRequest)1 SearchConvResponse (com.zimbra.soap.mail.message.SearchConvResponse)1 SearchRequest (com.zimbra.soap.mail.message.SearchRequest)1 SearchResponse (com.zimbra.soap.mail.message.SearchResponse)1 MessageHitInfo (com.zimbra.soap.mail.type.MessageHitInfo)1 SearchHit (com.zimbra.soap.type.SearchHit)1 Test (org.junit.Test)1