@Test public void getCollectionXMLTest() throws Exception { List<Provider> providers = new ArrayList<Provider>(); Provider provider1 = new Provider(); provider1.setId(1); provider1.setName("provider1"); provider1.setVmmUrl("http: providers.add(provider1); Provider provider2 = new Provider(); provider2.setId(2); provider2.setName("provider2"); provider2.setVmmUrl("http: providers.add(provider2); String xml = Converter.getRootCollectionXML(providers); SAXBuilder builder = new SAXBuilder(); builder.setValidation(false); builder.setIgnoringElementContentWhitespace(true); Document xmldoc = builder.build(new StringReader(xml)); XPath xpath = XPath.newInstance(" xpath.addNamespace("bnf", PROVIDER_REGISTRY_NAMESPACE); List listxpath = xpath.selectNodes(xmldoc); assertEquals(1, listxpath.size()); Element element = (Element) listxpath.get(0); assertEquals("/", element.getAttributeValue("href")); XPath xpathName = XPath.newInstance(" xpathName.addNamespace("bnf", PROVIDER_REGISTRY_NAMESPACE); List listxpathName = xpathName.selectNodes(xmldoc); assertEquals(1, listxpathName.size()); element = (Element) listxpathName.get(0); assertEquals("0", element.getAttributeValue("offset")); assertEquals("2", element.getAttributeValue("total")); xpathName = XPath.newInstance(" xpathName.addNamespace("bnf", PROVIDER_REGISTRY_NAMESPACE); listxpathName = xpathName.selectNodes(xmldoc); assertEquals(5, listxpathName.size()); xpathName = XPath.newInstance(" xpathName.addNamespace("bnf", PROVIDER_REGISTRY_NAMESPACE); listxpathName = xpathName.selectNodes(xmldoc); assertEquals(2, listxpathName.size()); element = (Element) listxpathName.get(0); assertEquals("/1", element.getAttributeValue("href")); element = (Element) listxpathName.get(1); assertEquals("/2", element.getAttributeValue("href")); xpathName = XPath.newInstance(" xpathName.addNamespace("bnf", PROVIDER_REGISTRY_NAMESPACE); listxpathName = xpathName.selectNodes(xmldoc); assertEquals(2, listxpathName.size()); element = (Element) listxpathName.get(0); assertEquals("provider1", element.getValue()); element = (Element) listxpathName.get(1); assertEquals("provider2", element.getValue()); xpathName = XPath.newInstance(" xpathName.addNamespace("bnf", PROVIDER_REGISTRY_NAMESPACE); listxpathName = xpathName.selectNodes(xmldoc); assertEquals(2, listxpathName.size()); element = (Element) listxpathName.get(0); assertEquals("http: element = (Element) listxpathName.get(1); assertEquals("http: }
public static String getRootCollectionXML(List<Provider> providers) { Collection collection = prepareCollection(providers); return toXML(Collection.class, collection); }
Converter { public static String getRootCollectionXML(List<Provider> providers) { Collection collection = prepareCollection(providers); return toXML(Collection.class, collection); } }
Converter { public static String getRootCollectionXML(List<Provider> providers) { Collection collection = prepareCollection(providers); return toXML(Collection.class, collection); }  }
Converter { public static String getRootCollectionXML(List<Provider> providers) { Collection collection = prepareCollection(providers); return toXML(Collection.class, collection); }  static Provider getProviderObject(String xml); static String getProviderXML(Provider provider); static String getRootCollectionJSON(List<Provider> providers); static String getRootCollectionXML(List<Provider> providers); static String getProviderJSON(Provider provider); static Provider getProviderFromJSON(String json); }
Converter { public static String getRootCollectionXML(List<Provider> providers) { Collection collection = prepareCollection(providers); return toXML(Collection.class, collection); }  static Provider getProviderObject(String xml); static String getProviderXML(Provider provider); static String getRootCollectionJSON(List<Provider> providers); static String getRootCollectionXML(List<Provider> providers); static String getProviderJSON(Provider provider); static Provider getProviderFromJSON(String json);  }