Search in sources :

Example 36 with RetentionPolicy

use of com.zimbra.soap.mail.type.RetentionPolicy in project zm-mailbox by Zimbra.

the class PurgeTest method multipleUserPolicy.

@Test
public void multipleUserPolicy() throws Exception {
    Mailbox mbox = MailboxManager.getInstance().getMailboxByAccountId(MockProvisioning.DEFAULT_ACCOUNT_ID);
    Folder folder = mbox.createFolder(null, "/multipleUserPolicy", new Folder.FolderOptions().setDefaultView(MailItem.Type.MESSAGE));
    List<Policy> list = Arrays.asList(Policy.newUserPolicy("45d"), Policy.newUserPolicy("60d"));
    RetentionPolicy purgePolicy = new RetentionPolicy(null, list);
    try {
        mbox.setRetentionPolicy(null, folder.getId(), MailItem.Type.FOLDER, purgePolicy);
        fail("Multiple purge policies.");
    } catch (ServiceException e) {
    }
    purgePolicy = new RetentionPolicy(list, null);
    try {
        mbox.setRetentionPolicy(null, folder.getId(), MailItem.Type.FOLDER, purgePolicy);
        fail("Multiple keep policies.");
    } catch (ServiceException e) {
    }
}
Also used : Policy(com.zimbra.soap.mail.type.Policy) RetentionPolicy(com.zimbra.soap.mail.type.RetentionPolicy) ServiceException(com.zimbra.common.service.ServiceException) RetentionPolicy(com.zimbra.soap.mail.type.RetentionPolicy) Test(org.junit.Test)

Example 37 with RetentionPolicy

use of com.zimbra.soap.mail.type.RetentionPolicy in project zm-mailbox by Zimbra.

the class JaxbToElementTest method standalonElementToJaxbTest.

@Test
public void standalonElementToJaxbTest() throws Exception {
    InputStream is = getClass().getResourceAsStream("retentionPolicy.xml");
    Element elem = Element.parseXML(is);
    String eXml = elem.toString();
    ZimbraLog.test.debug("retentionPolicy.xml from Element:\n%s", eXml);
    RetentionPolicy rp = JaxbUtil.elementToJaxb(elem, RetentionPolicy.class);
    Assert.assertNotNull("elementToJaxb RetentionPolicy returned object", rp);
    Element elem2 = JaxbUtil.jaxbToElement(rp, XMLElement.mFactory);
    String eXml2 = elem2.toString();
    ZimbraLog.test.debug("Round tripped retentionPolicy.xml from Element:\n%s", eXml2);
    XMLAssert.assertXMLEqual(eXml, eXml2);
}
Also used : InputStream(java.io.InputStream) Element(com.zimbra.common.soap.Element) XMLElement(com.zimbra.common.soap.Element.XMLElement) JSONElement(com.zimbra.common.soap.Element.JSONElement) JAXBElement(javax.xml.bind.JAXBElement) RetentionPolicy(com.zimbra.soap.mail.type.RetentionPolicy) Test(org.junit.Test)

Aggregations

RetentionPolicy (com.zimbra.soap.mail.type.RetentionPolicy)37 Policy (com.zimbra.soap.mail.type.Policy)22 Test (org.junit.Test)15 Config (com.zimbra.cs.account.Config)7 Element (com.zimbra.common.soap.Element)6 Mailbox (com.zimbra.cs.mailbox.Mailbox)6 ServiceException (com.zimbra.common.service.ServiceException)4 Cos (com.zimbra.cs.account.Cos)4 ZFolder (com.zimbra.client.ZFolder)3 ZMailbox (com.zimbra.client.ZMailbox)3 NoSuchItemException (com.zimbra.cs.mailbox.MailServiceException.NoSuchItemException)3 ZimbraSoapContext (com.zimbra.soap.ZimbraSoapContext)3 Color (com.zimbra.common.mailbox.Color)2 XMLElement (com.zimbra.common.soap.Element.XMLElement)2 AccountServiceException (com.zimbra.cs.account.AccountServiceException)2 Provisioning (com.zimbra.cs.account.Provisioning)2 DbTag (com.zimbra.cs.db.DbTag)2 Mountpoint (com.zimbra.cs.mailbox.Mountpoint)2 OperationContext (com.zimbra.cs.mailbox.OperationContext)2 AlterItemTag (com.zimbra.cs.redolog.op.AlterItemTag)2