@Test @SuppressWarnings(value = { "rawtypes" }) public void objectRootToXMLTest() throws JDOMException, IOException { Root root = new Root(); root.setHref("/"); root.setTimestamp("111"); root.setVersion("0.1-SNAPSHOOT"); Link link = new Link(); link.setRel("applications"); link.setType("application/xml"); link.setHref("/applications"); root.addLink(link); String xml = ModelConverter.objectRootToXML(root); SAXBuilder builder = new SAXBuilder(); builder.setValidation(false); builder.setIgnoringElementContentWhitespace(true); Document xmldoc = builder.build(new StringReader(xml)); XPath xpath = XPath.newInstance(" xpath.addNamespace("bnf", APPLICATION_MANAGER_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", APPLICATION_MANAGER_NAMESPACE); List listxpathName = xpathName.selectNodes(xmldoc); assertEquals(1, listxpathName.size()); element = (Element) listxpathName.get(0); assertEquals("0.1-SNAPSHOOT", element.getValue()); xpathName = XPath.newInstance(" xpathName.addNamespace("bnf", APPLICATION_MANAGER_NAMESPACE); listxpathName = xpathName.selectNodes(xmldoc); assertEquals(1, listxpathName.size()); element = (Element) listxpathName.get(0); assertEquals("111", element.getValue()); xpathName = XPath.newInstance(" xpathName.addNamespace("bnf", APPLICATION_MANAGER_NAMESPACE); listxpathName = xpathName.selectNodes(xmldoc); assertEquals(1, listxpathName.size()); element = (Element) listxpathName.get(0); assertEquals("applications", element.getAttributeValue("rel")); assertEquals("application/xml", element.getAttributeValue("type")); assertEquals("/applications", element.getAttributeValue("href")); }
public static String objectRootToXML(Root root) { return toXML(Root.class, root); }
ModelConverter { public static String objectRootToXML(Root root) { return toXML(Root.class, root); } }
ModelConverter { public static String objectRootToXML(Root root) { return toXML(Root.class, root); }  }
ModelConverter { public static String objectRootToXML(Root root) { return toXML(Root.class, root); }  static String objectCollectionToXML(Collection collection); static String objectCollectionToJSON(Collection collection); static Collection xmlCollectionToObject(String xml); static Collection jsonCollectionToObject(String xml); static String objectSLAApplicationTermToXML(SLAApplicationTerms slaAppTerms); static String objectSLAApplicationTermToJSON(SLAApplicationTerms slaAppTerms); static SLAApplicationTerms xmlSLAApplicationTermsToObject(String xml); static SLAApplicationTerms jsonSLAApplicationTermsToObject(String jsonString); static String objectApplicationToXML(Application application); static String objectApplicationToJSON(Application application); static Application xmlApplicationToObject(String xml); static Application jsonApplicationToObject(String jsonString); static String slaLitmitsToXML(SLALimits slaLimits); static SLALimits xmlSLALimitsToObject(String xml); static String objectRootToXML(Root root); static String applicationManagerMessageToJSON(ApplicationManagerMessage amMessage); static ApplicationManagerMessage jsonToApplicationManagerMessage(String json); static Deployment xmlDeploymentToObject(String xml); static Deployment jsonDeploymentToObject(String json); static String objectDeploymentToJSON(Deployment deployment); static String objectDeploymentToXML(Deployment deployment); static VM xmlVMToObject(String xml); static String objectVMToXML(VM vm); static Agreement xmlAgreementToObject(String xml); static String objectAgreementToXML(Agreement agreement); static String objectEnergyMeasurementToXML(EnergyMeasurement energyMeasurement); static String objectEnergyMeasurementToJSON(EnergyMeasurement energyMeasurement); static EnergyMeasurement xmlEnergyMeasurementToObject(String xml); static String objectPowerMeasurementToXML(PowerMeasurement powerMeasurement); static String objectPowerMeasurementToJSON(PowerMeasurement powerMeasurement); static PowerMeasurement xmlPowerMeasurementToObject(String xml); static String objectCostToXML(Cost cost); static String objectCostToJSON(Cost cost); static Cost xmlCostToObject(String xml); }
ModelConverter { public static String objectRootToXML(Root root) { return toXML(Root.class, root); }  static String objectCollectionToXML(Collection collection); static String objectCollectionToJSON(Collection collection); static Collection xmlCollectionToObject(String xml); static Collection jsonCollectionToObject(String xml); static String objectSLAApplicationTermToXML(SLAApplicationTerms slaAppTerms); static String objectSLAApplicationTermToJSON(SLAApplicationTerms slaAppTerms); static SLAApplicationTerms xmlSLAApplicationTermsToObject(String xml); static SLAApplicationTerms jsonSLAApplicationTermsToObject(String jsonString); static String objectApplicationToXML(Application application); static String objectApplicationToJSON(Application application); static Application xmlApplicationToObject(String xml); static Application jsonApplicationToObject(String jsonString); static String slaLitmitsToXML(SLALimits slaLimits); static SLALimits xmlSLALimitsToObject(String xml); static String objectRootToXML(Root root); static String applicationManagerMessageToJSON(ApplicationManagerMessage amMessage); static ApplicationManagerMessage jsonToApplicationManagerMessage(String json); static Deployment xmlDeploymentToObject(String xml); static Deployment jsonDeploymentToObject(String json); static String objectDeploymentToJSON(Deployment deployment); static String objectDeploymentToXML(Deployment deployment); static VM xmlVMToObject(String xml); static String objectVMToXML(VM vm); static Agreement xmlAgreementToObject(String xml); static String objectAgreementToXML(Agreement agreement); static String objectEnergyMeasurementToXML(EnergyMeasurement energyMeasurement); static String objectEnergyMeasurementToJSON(EnergyMeasurement energyMeasurement); static EnergyMeasurement xmlEnergyMeasurementToObject(String xml); static String objectPowerMeasurementToXML(PowerMeasurement powerMeasurement); static String objectPowerMeasurementToJSON(PowerMeasurement powerMeasurement); static PowerMeasurement xmlPowerMeasurementToObject(String xml); static String objectCostToXML(Cost cost); static String objectCostToJSON(Cost cost); static Cost xmlCostToObject(String xml);  }