use of com.zimbra.cs.mailbox.Metadata in project zm-mailbox by Zimbra.
the class TestRemoteImapMailboxStore method testListIMAPSubscriptions.
@Test
public void testListIMAPSubscriptions() throws Exception {
String path = NAME_PREFIX + "_testPath";
MetadataList slist = new MetadataList();
slist.add(path);
// imitate subscription
Mailbox mbox = TestUtil.getMailbox(USER_NAME);
mbox.setConfig(null, "imap", new Metadata().put("subs", slist));
// check that subscription was saved in mailbox configuration
Metadata config = mbox.getConfig(null, "imap");
Assert.assertNotNull(config);
MetadataList rlist = config.getList("subs", true);
Assert.assertNotNull(rlist);
Assert.assertNotNull(rlist.get(0));
Assert.assertTrue(rlist.get(0).equalsIgnoreCase(path));
// test listSubscriptions method
ZMailbox zmbox = TestUtil.getZMailbox(USER_NAME);
RemoteImapMailboxStore remoteStore = new RemoteImapMailboxStore(zmbox, TestUtil.getAccount(USER_NAME).getId());
Set<String> subs = remoteStore.listSubscriptions(null);
Assert.assertNotNull(subs);
Assert.assertEquals(1, subs.size());
String sub = subs.iterator().next();
Assert.assertTrue(sub.equalsIgnoreCase(path));
}
use of com.zimbra.cs.mailbox.Metadata in project zm-mailbox by Zimbra.
the class ImapCredentials method saveConfig.
private void saveConfig(Set<String> subscriptions) throws ServiceException {
MetadataList slist = new MetadataList();
if (subscriptions != null && !subscriptions.isEmpty()) {
for (String sub : subscriptions) slist.add(sub);
}
getMailbox().setConfig(getContext(), SN_IMAP, new Metadata().put(FN_SUBSCRIPTIONS, slist));
}
use of com.zimbra.cs.mailbox.Metadata in project zm-mailbox by Zimbra.
the class TestMetadata method testMetadata.
/**
* Tests insert, update and delete operations for mailbox metadata.
*/
public void testMetadata() throws Exception {
ZimbraLog.test.info("Starting testMetadata");
Mailbox mbox = TestUtil.getMailbox(USER_NAME);
assertNull(mbox.getConfig(null, METADATA_SECTION));
// Insert
Metadata config = new Metadata();
config.put("string", "mystring");
mbox.setConfig(null, METADATA_SECTION, config);
config = mbox.getConfig(null, METADATA_SECTION);
assertEquals("mystring", config.get("string"));
// Update
config.put("long", 87);
mbox.setConfig(null, METADATA_SECTION, config);
config = mbox.getConfig(null, METADATA_SECTION);
assertEquals(87, config.getLong("long"));
assertEquals("mystring", config.get("string"));
// Delete
mbox.setConfig(null, METADATA_SECTION, null);
assertNull(mbox.getConfig(null, METADATA_SECTION));
}
Aggregations