StorageAccountsDocumentBinding { public Element createDocumentFrom(Collection<StorageAccount> accts, boolean includeCredentials, boolean includeOptions) { Element storageProviderAccounts = new Element("storageProviderAccounts"); if (null != accts && accts.size() > 0) { for (StorageAccount acct : accts) { StorageAccountProviderBinding providerBinding = providerBindings.get(acct.getType()); if (null != providerBinding) { storageProviderAccounts.addContent( providerBinding.getElementFrom(acct, includeCredentials, includeOptions)); } else { log.warn("Unexpected account type: " + acct.getType()); } } } return storageProviderAccounts; } StorageAccountsDocumentBinding(); List<StorageAccount> createStorageAccountsFrom(Element accounts); List<StorageAccount> createStorageAccountsFromXml(InputStream xml); Element createDocumentFrom(Collection<StorageAccount> accts,
                                      boolean includeCredentials,
                                      boolean includeOptions); String createXmlFrom(Collection<StorageAccount> accts,
                                boolean includeCredentials,
                                boolean includeOptions);  }
@Test public void testCreateDocumentFrom() throws Exception { StorageAccount acct0 = createAccount(StorageProviderType.AMAZON_S3); StorageAccount acct1 = createAccount(StorageProviderType.AMAZON_GLACIER); List<StorageAccount> accts = new ArrayList<StorageAccount>(); accts.add(acct0); accts.add(acct1); boolean includeCredentials = true; boolean includeOptions = true; Element accountsElem = documentBinding.createDocumentFrom(accts, includeCredentials, includeOptions); Assert.assertNotNull(accountsElem); List<StorageAccount> accounts = documentBinding.createStorageAccountsFrom(accountsElem); verifyAccounts(accounts); }