Search in sources :

Example 1 with ModifyPrefs

use of com.zimbra.cs.service.account.ModifyPrefs 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 ModifyPrefs

use of com.zimbra.cs.service.account.ModifyPrefs 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)

Aggregations

Element (com.zimbra.common.soap.Element)2 Account (com.zimbra.cs.account.Account)2 Mailbox (com.zimbra.cs.mailbox.Mailbox)2 ModifyPrefs (com.zimbra.cs.service.account.ModifyPrefs)2 ModifyPrefsRequest (com.zimbra.soap.account.message.ModifyPrefsRequest)2 Pref (com.zimbra.soap.account.type.Pref)2 Test (org.junit.Test)2 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)2