Search in sources :

Example 1 with CreateTagRequest

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

the class TestTags method testAddTag.

@SuppressWarnings("deprecation")
@Test
public void testAddTag() throws Exception {
    CreateTagRequest createTagReq = new CreateTagRequest();
    TagSpec tag = new TagSpec("tag150146840461812563");
    tag.setColor((byte) 5);
    createTagReq.setTag(tag);
    ZMailbox zMbox = TestUtil.getZMailbox(USER);
    CreateTagResponse createResp = zMbox.invokeJaxb(createTagReq);
    assertNotNull("CreateTagResponse should not be null", createResp);
    TagInfo createdTag = createResp.getTag();
    assertNotNull("CreateTagResponse/tag should not be null", createdTag);
    assertNotNull("Created tag should have an ID", createdTag.getId());
    assertNotNull("Created tag should have a color", createdTag.getColor());
    assertTrue("Color of created tag should be 5", createdTag.getColor() == (byte) 5);
    // use "update" and "t" element
    ActionSelector msgAction = ActionSelector.createForIdsAndOperation(Integer.toString(mMessage1.getId()), MailConstants.OP_UPDATE);
    msgAction.setTags(createdTag.getId());
    MsgActionRequest msgActionReq = new MsgActionRequest(msgAction);
    MsgActionResponse msgActionResp = zMbox.invokeJaxb(msgActionReq);
    assertNotNull("MsgActionResponse should not be null", msgActionResp);
    ActionResult res = msgActionResp.getAction();
    assertNotNull("MsgActionResponse/action should not be null", res);
    // use "tag" and "tag" element
    msgAction = ActionSelector.createForIdsAndOperation(Integer.toString(mMessage3.getId()), MailConstants.OP_TAG);
    msgAction.setTag(Integer.parseInt(createdTag.getId()));
    msgActionReq = new MsgActionRequest(msgAction);
    msgActionResp = zMbox.invokeJaxb(msgActionReq);
    assertNotNull("MsgActionResponse should not be null", msgActionResp);
    res = msgActionResp.getAction();
    assertNotNull("MsgActionResponse/action should not be null", res);
}
Also used : TagSpec(com.zimbra.soap.mail.type.TagSpec) MsgActionRequest(com.zimbra.soap.mail.message.MsgActionRequest) ZMailbox(com.zimbra.client.ZMailbox) ActionResult(com.zimbra.soap.mail.type.ActionResult) TagInfo(com.zimbra.soap.mail.type.TagInfo) MsgActionResponse(com.zimbra.soap.mail.message.MsgActionResponse) CreateTagRequest(com.zimbra.soap.mail.message.CreateTagRequest) CreateTagResponse(com.zimbra.soap.mail.message.CreateTagResponse) ActionSelector(com.zimbra.soap.mail.type.ActionSelector) Test(org.junit.Test)

Aggregations

ZMailbox (com.zimbra.client.ZMailbox)1 CreateTagRequest (com.zimbra.soap.mail.message.CreateTagRequest)1 CreateTagResponse (com.zimbra.soap.mail.message.CreateTagResponse)1 MsgActionRequest (com.zimbra.soap.mail.message.MsgActionRequest)1 MsgActionResponse (com.zimbra.soap.mail.message.MsgActionResponse)1 ActionResult (com.zimbra.soap.mail.type.ActionResult)1 ActionSelector (com.zimbra.soap.mail.type.ActionSelector)1 TagInfo (com.zimbra.soap.mail.type.TagInfo)1 TagSpec (com.zimbra.soap.mail.type.TagSpec)1 Test (org.junit.Test)1