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());
}
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);
}
Aggregations