@Test public void getProviderXML() throws JDOMException, IOException { Provider provider = new Provider(); provider.setHref("/11"); provider.setId(11); provider.setName("Nome"); provider.setVmmUrl("Punto final"); Link linkParent = new Link(); linkParent.setRel("parent"); linkParent.setHref("/"); linkParent.setType(PROVIDER_REGISTRY_NAMESPACE); Link linkSelf = new Link(); linkSelf.setRel("self"); linkSelf.setHref("/11"); linkSelf.setType(PROVIDER_REGISTRY_NAMESPACE); provider.addLink(linkSelf); provider.addLink(linkParent); String xml = Converter.getProviderXML(provider); 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("/11", 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("11", element.getValue()); xpathName = XPath.newInstance(" xpathName.addNamespace("bnf", PROVIDER_REGISTRY_NAMESPACE); listxpathName = xpathName.selectNodes(xmldoc); assertEquals(1, listxpathName.size()); element = (Element) listxpathName.get(0); assertEquals("Nome", element.getValue()); xpathName = XPath.newInstance(" xpathName.addNamespace("bnf", PROVIDER_REGISTRY_NAMESPACE); listxpathName = xpathName.selectNodes(xmldoc); assertEquals(1, listxpathName.size()); element = (Element) listxpathName.get(0); assertEquals("Punto final", 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("self", element.getAttributeValue("rel")); }
public static String getProviderXML(Provider provider) { return toXML(Provider.class, provider); }
Converter { public static String getProviderXML(Provider provider) { return toXML(Provider.class, provider); } }
Converter { public static String getProviderXML(Provider provider) { return toXML(Provider.class, provider); }  }
Converter { public static String getProviderXML(Provider provider) { return toXML(Provider.class, provider); }  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 getProviderXML(Provider provider) { return toXML(Provider.class, provider); }  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);  }