Search in sources :

Example 1 with ModifyDataSourceRequest

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

the class DataSourceJaxbTest method testModifyDataSourceRequest.

@Test
public void testModifyDataSourceRequest() throws JAXBException {
    JAXBContext jaxb = JAXBContext.newInstance(ModifyDataSourceRequest.class);
    Unmarshaller unmarshaller = jaxb.createUnmarshaller();
    ModifyDataSourceRequest req = (ModifyDataSourceRequest) unmarshaller.unmarshal(getClass().getResourceAsStream("ModifyUnknownDataSourceRequest.xml"));
    DataSource ds = req.getDataSource();
    assertNotNull("Generic DataSource should not be NULL", ds);
    assertNotNull("Generic DataSource ID should not be NULL", ds.getId());
    assertEquals("Wrong ID for generic DataSource", "11e1c69c-bbb3-4f5d-8903-14ef8bdacbcc", ds.getId());
    assertTrue("DataSource should be an instance of MailDataSource", ds instanceof MailDataSource);
    assertEquals("wrong refresh token", "AAbbccdd1244eeffVdNHR.l0_jzuWvPNtAt0BCCcOm8w9wq1gdB", ds.getRefreshToken());
    assertEquals("wrong host", "yahoo.com", ds.getHost());
    assertEquals("wrong import class", "com.synacor.zimbra.OAuthDataImport", ds.getImportClass());
    assertEquals("wrong polling interval", "60s", ds.getPollingInterval());
    req = (ModifyDataSourceRequest) unmarshaller.unmarshal(getClass().getResourceAsStream("ModifyImapDataSourceRequest.xml"));
    ds = req.getDataSource();
    assertNotNull("IMAP DataSource should not be NULL", ds);
    assertNotNull("IMAP DataSource ID should not be NULL", ds.getId());
    assertEquals("Wrong ID for IMAP DataSource", "71e1c69c-bbb3-4f5d-8903-14ef8bdacbcc", ds.getId());
    assertTrue("DataSource should be an instance of MailImapDataSource", ds instanceof MailImapDataSource);
    assertEquals("wrong polling interval", "30m", ds.getPollingInterval());
    req = (ModifyDataSourceRequest) unmarshaller.unmarshal(getClass().getResourceAsStream("ModifyCalDataSourceRequest.xml"));
    ds = req.getDataSource();
    assertNotNull("Cal DataSource should not be NULL", ds);
    assertNotNull("Cal DataSource ID should not be NULL", ds.getId());
    assertEquals("Wrong ID for Cal DataSource", "61e1c69c-bbb3-4f5d-8903-14ef8bdacbcc", ds.getId());
    assertTrue("DataSource should be an instance of MailCalDataSource", ds instanceof MailCalDataSource);
    assertEquals("wrong folder ID", "333", ds.getFolderId());
    req = (ModifyDataSourceRequest) unmarshaller.unmarshal(getClass().getResourceAsStream("ModifyGalDataSourceRequest.xml"));
    ds = req.getDataSource();
    assertNotNull("GAL DataSource should not be NULL", ds);
    assertNotNull("GAL DataSource ID should not be NULL", ds.getId());
    assertEquals("Wrong ID for GAL DataSource", "51e1c69c-bbb3-4f5d-8903-14ef8bdacbcc", ds.getId());
    assertTrue("DataSource should be an instance of MailGalDataSource", ds instanceof MailGalDataSource);
    assertEquals("wrong polling interval", "69s", ds.getPollingInterval());
    req = (ModifyDataSourceRequest) unmarshaller.unmarshal(getClass().getResourceAsStream("ModifyPop3DataSourceRequest.xml"));
    ds = req.getDataSource();
    assertNotNull("POP3 DataSource should not be NULL", ds);
    assertNotNull("POP3 DataSource ID should not be NULL", ds.getId());
    assertEquals("Wrong ID for POP3 DataSource", "41e1c69c-bbb3-4f5d-8903-14ef8bdacbcc", ds.getId());
    assertTrue("DataSource should be an instance of MailPop3DataSource", ds instanceof MailPop3DataSource);
    assertEquals("wrong polling interval", "1m", ds.getPollingInterval());
    assertFalse("wrong leaveOnServer", ((MailPop3DataSource) ds).isLeaveOnServer());
    req = (ModifyDataSourceRequest) unmarshaller.unmarshal(getClass().getResourceAsStream("ModifyCaldavDataSourceRequest.xml"));
    ds = req.getDataSource();
    assertNotNull("Caldav DataSource should not be NULL", ds);
    assertNotNull("Caldav DataSource ID should not be NULL", ds.getId());
    assertEquals("Wrong ID for Caldav DataSource", "31e1c69c-bbb3-4f5d-8903-14ef8bdacbcc", ds.getId());
    assertTrue("DataSource should be an instance of MailCaldavDataSource", ds instanceof MailCaldavDataSource);
    assertEquals("wrong polling interval", "60s", ds.getPollingInterval());
    req = (ModifyDataSourceRequest) unmarshaller.unmarshal(getClass().getResourceAsStream("ModifyRssDataSourceRequest.xml"));
    ds = req.getDataSource();
    assertNotNull("RSS DataSource should not be NULL", ds);
    assertNotNull("RSS DataSource ID should not be NULL", ds.getId());
    assertEquals("Wrong ID for RSS DataSource", "21e1c69c-bbb3-4f5d-8903-14ef8bdacbcc", ds.getId());
    assertTrue("DataSource should be an instance of MailRssDataSource", ds instanceof MailRssDataSource);
    assertEquals("wrong polling interval", "2d", ds.getPollingInterval());
    assertFalse("wrong isEnabled", ds.isEnabled());
}
Also used : MailCalDataSource(com.zimbra.soap.mail.type.MailCalDataSource) MailDataSource(com.zimbra.soap.mail.type.MailDataSource) MailCaldavDataSource(com.zimbra.soap.mail.type.MailCaldavDataSource) MailGalDataSource(com.zimbra.soap.mail.type.MailGalDataSource) MailRssDataSource(com.zimbra.soap.mail.type.MailRssDataSource) ModifyDataSourceRequest(com.zimbra.soap.mail.message.ModifyDataSourceRequest) JAXBContext(javax.xml.bind.JAXBContext) Unmarshaller(javax.xml.bind.Unmarshaller) MailImapDataSource(com.zimbra.soap.mail.type.MailImapDataSource) MailPop3DataSource(com.zimbra.soap.mail.type.MailPop3DataSource) MailCalDataSource(com.zimbra.soap.mail.type.MailCalDataSource) MailDataSource(com.zimbra.soap.mail.type.MailDataSource) MailGalDataSource(com.zimbra.soap.mail.type.MailGalDataSource) MailImapDataSource(com.zimbra.soap.mail.type.MailImapDataSource) MailCaldavDataSource(com.zimbra.soap.mail.type.MailCaldavDataSource) MailPop3DataSource(com.zimbra.soap.mail.type.MailPop3DataSource) MailRssDataSource(com.zimbra.soap.mail.type.MailRssDataSource) DataSource(com.zimbra.soap.type.DataSource) Test(org.junit.Test)

Example 2 with ModifyDataSourceRequest

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

the class ZMailbox method modifyDataSource.

public void modifyDataSource(ZDataSource source) throws ServiceException {
    ModifyDataSourceRequest req = new ModifyDataSourceRequest();
    req.setDataSource(source.toJaxb());
    invokeJaxb(req);
}
Also used : ModifyDataSourceRequest(com.zimbra.soap.mail.message.ModifyDataSourceRequest)

Aggregations

ModifyDataSourceRequest (com.zimbra.soap.mail.message.ModifyDataSourceRequest)2 MailCalDataSource (com.zimbra.soap.mail.type.MailCalDataSource)1 MailCaldavDataSource (com.zimbra.soap.mail.type.MailCaldavDataSource)1 MailDataSource (com.zimbra.soap.mail.type.MailDataSource)1 MailGalDataSource (com.zimbra.soap.mail.type.MailGalDataSource)1 MailImapDataSource (com.zimbra.soap.mail.type.MailImapDataSource)1 MailPop3DataSource (com.zimbra.soap.mail.type.MailPop3DataSource)1 MailRssDataSource (com.zimbra.soap.mail.type.MailRssDataSource)1 DataSource (com.zimbra.soap.type.DataSource)1 JAXBContext (javax.xml.bind.JAXBContext)1 Unmarshaller (javax.xml.bind.Unmarshaller)1 Test (org.junit.Test)1