Search in sources :

Example 1 with Pref

use of com.zimbra.soap.account.type.Pref in project zm-mailbox by Zimbra.

the class ModifyPrefsTest method testPrefCalendarInitialViewYear.

@Test
public void testPrefCalendarInitialViewYear() throws Exception {
    Account acct1 = Provisioning.getInstance().get(Key.AccountBy.name, "test@zimbra.com");
    Mailbox mbox = MailboxManager.getInstance().getMailboxByAccount(acct1);
    ModifyPrefsRequest request = new ModifyPrefsRequest();
    Pref pref = new Pref(Provisioning.A_zimbraPrefCalendarInitialView, "year");
    request.addPref(pref);
    Element req = JaxbUtil.jaxbToElement(request);
    new ModifyPrefs().handle(req, ServiceTestUtil.getRequestContext(mbox.getAccount()));
    new ModifyPrefs().handle(req, ServiceTestUtil.getRequestContext(mbox.getAccount()));
    Assert.assertFalse(acct1.getPrefCalendarInitialView().isDay());
    Assert.assertTrue(acct1.getPrefCalendarInitialView().isYear());
}
Also used : Account(com.zimbra.cs.account.Account) Mailbox(com.zimbra.cs.mailbox.Mailbox) Pref(com.zimbra.soap.account.type.Pref) Element(com.zimbra.common.soap.Element) ModifyPrefsRequest(com.zimbra.soap.account.message.ModifyPrefsRequest) ModifyPrefs(com.zimbra.cs.service.account.ModifyPrefs) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 2 with Pref

use of com.zimbra.soap.account.type.Pref in project zm-mailbox by Zimbra.

the class ModifyPrefsTest method testMsgMaxAttr.

@Test
public void testMsgMaxAttr() throws Exception {
    Account acct1 = Provisioning.getInstance().get(Key.AccountBy.name, "test@zimbra.com");
    Mailbox mbox = MailboxManager.getInstance().getMailboxByAccount(acct1);
    acct1.setFeatureMailForwardingEnabled(true);
    acct1.setFeatureAddressVerificationEnabled(true);
    Assert.assertNull(acct1.getPrefMailForwardingAddress());
    Assert.assertNull(acct1.getFeatureAddressUnderVerification());
    ModifyPrefsRequest request = new ModifyPrefsRequest();
    Pref pref = new Pref(Provisioning.A_zimbraPrefMailForwardingAddress, "test1@somedomain.com");
    request.addPref(pref);
    Element req = JaxbUtil.jaxbToElement(request);
    new ModifyPrefs().handle(req, ServiceTestUtil.getRequestContext(mbox.getAccount()));
    /*
         * Verify that the forwarding address is not directly stored into
         * 'zimbraPrefMailForwardingAddress' Instead, it is stored in
         * 'zimbraFeatureAddressUnderVerification' till the time it
         * gets verification
         */
    Assert.assertNull(acct1.getPrefMailForwardingAddress());
    Assert.assertEquals("test1@somedomain.com", acct1.getFeatureAddressUnderVerification());
    /*
         * disable the verification feature and check that the forwarding
         * address is directly stored into 'zimbraPrefMailForwardingAddress'
         */
    acct1.setPrefMailForwardingAddress(null);
    acct1.setFeatureAddressUnderVerification(null);
    acct1.setFeatureAddressVerificationEnabled(false);
    new ModifyPrefs().handle(req, ServiceTestUtil.getRequestContext(mbox.getAccount()));
    Assert.assertNull(acct1.getFeatureAddressUnderVerification());
    Assert.assertEquals("test1@somedomain.com", acct1.getPrefMailForwardingAddress());
    Assert.assertEquals(FeatureAddressVerificationStatus.pending, acct1.getFeatureAddressVerificationStatus());
}
Also used : Account(com.zimbra.cs.account.Account) Mailbox(com.zimbra.cs.mailbox.Mailbox) Pref(com.zimbra.soap.account.type.Pref) Element(com.zimbra.common.soap.Element) ModifyPrefsRequest(com.zimbra.soap.account.message.ModifyPrefsRequest) ModifyPrefs(com.zimbra.cs.service.account.ModifyPrefs) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 3 with Pref

use of com.zimbra.soap.account.type.Pref in project zm-mailbox by Zimbra.

the class JaxbToElementTest method modifyPrefs.

@Test
public void modifyPrefs() throws Exception {
    ModifyPrefsRequest req = new ModifyPrefsRequest();
    req.addPref(new Pref("zimbraPrefGroupMailBy", "message"));
    req.addPref(new Pref("zimbraPrefMailItemsPerPage", "200"));
    // method of adding to multivalue
    req.addPref(new Pref("+zimbraPrefTimeZoneId", "Africa/Harare"));
    // method of setting multivalue
    req.addPref(new Pref("zimbraPrefSpellIgnoreWord", "zimbra"));
    req.addPref(new Pref("zimbraPrefSpellIgnoreWord", "jaxb"));
    Element jsonElem = JacksonUtil.jaxbToJSONElement(req);
    Assert.assertNotNull("JSON Element", jsonElem);
    Assert.assertEquals("JSON", modifyPrefsAsJson, jsonElem.toString());
    req = JaxbUtil.elementToJaxb(jsonElem);
    List<Pref> prefs = req.getPrefs();
    Assert.assertEquals("Number of round tripped prefs", 5, prefs.size());
}
Also used : Pref(com.zimbra.soap.account.type.Pref) 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) ModifyPrefsRequest(com.zimbra.soap.account.message.ModifyPrefsRequest) Test(org.junit.Test)

Example 4 with Pref

use of com.zimbra.soap.account.type.Pref in project zm-mailbox by Zimbra.

the class TestCalDav method setZimbraPrefAppleIcalDelegationEnabled.

private void setZimbraPrefAppleIcalDelegationEnabled(ZMailbox mbox, Boolean val) throws ServiceException {
    ModifyPrefsRequest modPrefsReq = new ModifyPrefsRequest();
    Pref pref = Pref.createPrefWithNameAndValue(ZAttrProvisioning.A_zimbraPrefAppleIcalDelegationEnabled, val.toString().toUpperCase());
    modPrefsReq.addPref(pref);
    ModifyPrefsResponse modPrefsResp = mbox.invokeJaxb(modPrefsReq);
    assertNotNull("null ModifyPrefs Response for forwarding calendar invites/no auto-add", modPrefsResp);
}
Also used : Pref(com.zimbra.soap.account.type.Pref) ModifyPrefsRequest(com.zimbra.soap.account.message.ModifyPrefsRequest) ModifyPrefsResponse(com.zimbra.soap.account.message.ModifyPrefsResponse)

Example 5 with Pref

use of com.zimbra.soap.account.type.Pref in project zm-mailbox by Zimbra.

the class JaxbToElementTest method jaxbWrapperFixupTest.

/**
 * Check that @{link JaxbUtil.elementToJaxb} will accept XML where
 * JAXB expects various attributes that have been specified as elements.
 * Ensure that attributes in wrapped elements are handled
 * @throws Exception
 */
@Test
public void jaxbWrapperFixupTest() throws Exception {
    Element rootElem = Element.XMLElement.mFactory.createElement(AccountConstants.AUTH_REQUEST);
    // JAXB wrapper element name E_PREFS
    Element prefsE = rootElem.addNonUniqueElement(AccountConstants.E_PREFS);
    // JAXB element E_PREF with attribute "name"
    Element prefE = prefsE.addNonUniqueElement(AccountConstants.E_PREF);
    prefE.addNonUniqueElement("name").addText("pref name");
    AuthRequest req = JaxbUtil.elementToJaxb(rootElem);
    List<Pref> prefs = req.getPrefs();
    Assert.assertEquals("Number of prefs", 1, prefs.size());
    Assert.assertEquals("Pref name", "pref name", prefs.get(0).getName());
}
Also used : AuthRequest(com.zimbra.soap.account.message.AuthRequest) Pref(com.zimbra.soap.account.type.Pref) 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) Test(org.junit.Test)

Aggregations

Pref (com.zimbra.soap.account.type.Pref)6 ModifyPrefsRequest (com.zimbra.soap.account.message.ModifyPrefsRequest)5 Element (com.zimbra.common.soap.Element)4 Test (org.junit.Test)4 Account (com.zimbra.cs.account.Account)3 JSONElement (com.zimbra.common.soap.Element.JSONElement)2 XMLElement (com.zimbra.common.soap.Element.XMLElement)2 Mailbox (com.zimbra.cs.mailbox.Mailbox)2 ModifyPrefs (com.zimbra.cs.service.account.ModifyPrefs)2 ModifyPrefsResponse (com.zimbra.soap.account.message.ModifyPrefsResponse)2 JAXBElement (javax.xml.bind.JAXBElement)2 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)2 ZMailbox (com.zimbra.client.ZMailbox)1 ZMessage (com.zimbra.client.ZMessage)1 AuthRequest (com.zimbra.soap.account.message.AuthRequest)1 CreateMountpointRequest (com.zimbra.soap.mail.message.CreateMountpointRequest)1 CreateMountpointResponse (com.zimbra.soap.mail.message.CreateMountpointResponse)1 FolderActionRequest (com.zimbra.soap.mail.message.FolderActionRequest)1 FolderActionResponse (com.zimbra.soap.mail.message.FolderActionResponse)1 GetMsgRequest (com.zimbra.soap.mail.message.GetMsgRequest)1