StorageAccountsDocumentBinding { public List<StorageAccount> createStorageAccountsFrom(Element accounts) { List<StorageAccount> accts = new ArrayList<StorageAccount>(); try { Iterator<?> accountList = accounts.getChildren().iterator(); while (accountList.hasNext()) { Element accountXml = (Element) accountList.next(); String type = accountXml.getChildText("storageProviderType"); StorageProviderType acctType = StorageProviderType.fromString( type); StorageAccountProviderBinding providerBinding = providerBindings .get(acctType); if (null != providerBinding) { accts.add(providerBinding.getAccountFromXml(accountXml)); } else { log.warn("Unexpected account type: " + acctType); } } if (accts.isEmpty()) { String error = "No storage accounts could be read"; throw new StorageException(error); } } catch (Exception e) { String error = "Unable to build storage account information due " + "to error: " + e.getMessage(); log.error(error); throw new StorageException(error, e); } return accts; } 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 testCreateStorageAccountsFrom() throws Exception { InputStream xml = createXml(); SAXBuilder builder = new SAXBuilder(); Document doc = builder.build(xml); Element accountsElem = doc.getRootElement(); List<StorageAccount> accts = documentBinding.createStorageAccountsFrom(accountsElem); verifyAccounts(accts); }