@Test public void addApplicationXMLInfoWithDeploymentsAndVMTest() throws JAXBException { Application applicationBeforeXML = new Application(); applicationBeforeXML.setId(22); applicationBeforeXML.setName("name"); Deployment deploymentBeforeXML = new Deployment(); deploymentBeforeXML.setId(1); deploymentBeforeXML.setStatus("RUNNIG"); deploymentBeforeXML.setPrice("expensive"); applicationBeforeXML.addDeployment(deploymentBeforeXML); VM vmBeforeXML = new VM(); vmBeforeXML.setId(44); vmBeforeXML.setIp("127.0.0.1"); vmBeforeXML.setOvfId("ovf-id"); vmBeforeXML.setProviderId("provider-id"); vmBeforeXML.setProviderVmId("provider-vm-id"); vmBeforeXML.setSlaAgreement("sla-agreement"); vmBeforeXML.setStatus("RUNNING"); deploymentBeforeXML.addVM(vmBeforeXML); String xml = XMLBuilder.getApplicationXML(applicationBeforeXML); JAXBContext jaxbContext = JAXBContext.newInstance(Application.class); Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller(); Application application = (Application) jaxbUnmarshaller.unmarshal(new StringReader(xml)); assertEquals(22, application.getId()); assertEquals("/applications/name", application.getHref()); assertEquals(4, application.getLinks().size()); assertEquals("/applications", application.getLinks().get(0).getHref()); assertEquals("parent", application.getLinks().get(0).getRel()); assertEquals(MediaType.APPLICATION_XML, application.getLinks().get(0).getType()); assertEquals("/applications/name", application.getLinks().get(1).getHref()); assertEquals("self",application.getLinks().get(1).getRel()); assertEquals(MediaType.APPLICATION_XML, application.getLinks().get(1).getType()); assertEquals("/applications/name/deployments", application.getLinks().get(2).getHref()); assertEquals("deployments",application.getLinks().get(2).getRel()); assertEquals(MediaType.APPLICATION_XML, application.getLinks().get(2).getType()); Deployment deployment = application.getDeployments().get(0); assertEquals(1, deployment.getId()); assertEquals("/applications/name/deployments/1", deployment.getHref()); assertEquals(6, deployment.getLinks().size()); assertEquals("/applications/name/deployments", deployment.getLinks().get(0).getHref()); assertEquals("parent", deployment.getLinks().get(0).getRel()); assertEquals(MediaType.APPLICATION_XML, deployment.getLinks().get(0).getType()); assertEquals("/applications/name/deployments/1", deployment.getLinks().get(1).getHref()); assertEquals("self",deployment.getLinks().get(1).getRel()); assertEquals(MediaType.APPLICATION_XML, deployment.getLinks().get(1).getType()); assertEquals("/applications/name/deployments/1/ovf", deployment.getLinks().get(2).getHref()); assertEquals("ovf",deployment.getLinks().get(2).getRel()); assertEquals(MediaType.APPLICATION_XML, deployment.getLinks().get(2).getType()); assertEquals("/applications/name/deployments/1/vms", deployment.getLinks().get(3).getHref()); assertEquals("vms",deployment.getLinks().get(3).getRel()); assertEquals(MediaType.APPLICATION_XML, deployment.getLinks().get(3).getType()); assertEquals("/applications/name/deployments/1/energy-consumption", deployment.getLinks().get(4).getHref()); assertEquals("energy-consumption",deployment.getLinks().get(4).getRel()); assertEquals(MediaType.APPLICATION_XML, deployment.getLinks().get(4).getType()); assertEquals("/applications/name/deployments/1/agreements", deployment.getLinks().get(5).getHref()); assertEquals("agreements",deployment.getLinks().get(5).getRel()); assertEquals(MediaType.APPLICATION_XML, deployment.getLinks().get(5).getType()); VM vm = deployment.getVms().get(0); assertEquals(44, vm.getId()); assertEquals("/applications/name/deployments/1/vms/44", vm.getHref()); assertEquals(2, vm.getLinks().size()); assertEquals("/applications/name/deployments/1/vms", vm.getLinks().get(0).getHref()); assertEquals("parent", vm.getLinks().get(0).getRel()); assertEquals(MediaType.APPLICATION_XML, vm.getLinks().get(0).getType()); assertEquals("/applications/name/deployments/1/vms/44", vm.getLinks().get(1).getHref()); assertEquals("self",vm.getLinks().get(1).getRel()); applicationBeforeXML = new Application(); applicationBeforeXML.setId(22); applicationBeforeXML.setName("name"); deploymentBeforeXML = new Deployment(); deploymentBeforeXML.setId(1); deploymentBeforeXML.setStatus("RUNNIG"); deploymentBeforeXML.setPrice("expensive"); applicationBeforeXML.addDeployment(deploymentBeforeXML); vmBeforeXML = new VM(); vmBeforeXML.setId(44); vmBeforeXML.setIp("127.0.0.1"); vmBeforeXML.setOvfId("ovf-id"); vmBeforeXML.setProviderId("provider-id"); vmBeforeXML.setProviderVmId("provider-vm-id"); vmBeforeXML.setSlaAgreement("sla-agreement"); vmBeforeXML.setStatus("RUNNING"); deploymentBeforeXML.addVM(vmBeforeXML); }
public static String getApplicationXML(Application application) { application = addApplicationXMLInfo(application); return ModelConverter.objectApplicationToXML(application); }
XMLBuilder { public static String getApplicationXML(Application application) { application = addApplicationXMLInfo(application); return ModelConverter.objectApplicationToXML(application); } }
XMLBuilder { public static String getApplicationXML(Application application) { application = addApplicationXMLInfo(application); return ModelConverter.objectApplicationToXML(application); }  }
XMLBuilder { public static String getApplicationXML(Application application) { application = addApplicationXMLInfo(application); return ModelConverter.objectApplicationToXML(application); }  static String getApplicationXML(Application application); static String getApplicationJSON(Application application); static String getDeploymentXML(Deployment deployment, String applicationId); static String getDeploymentJSON(Deployment deployment, String applicationName); static String getVMXML(VM vm, String applicationId, int deploymentId); static String getCollectionApplicationsXML(List<Application> applications); static String getCollectionApplicationsJSON(List<Application> applications); static String getCollectionOfCacheImagesXML(List<Image> images, String applicationName); static String getCollectionOfDeploymentsXML(List<Deployment> deployments, String applicationId); static String getCollectionOfDeploymentsJSON(List<Deployment> deployments, String applicationId); static EnergyMeasurement addEnergyMeasurementForDeploymentXMLInfo(
			EnergyMeasurement energyMeasurement, String applicationId, String deploymentId, String href); static String getEnergyMeasurementForDeploymentXMLInfo(EnergyMeasurement energyMeasurement, String applicationId, String deploymentId); static PowerMeasurement addPowerMeasurementForDeploymentXMLInfo(
			PowerMeasurement powerMeasurement, String applicationId, String deploymentId, String href); static String getPowerMeasurementForDeploymentXMLInfo(PowerMeasurement powerMeasurement, String applicationId, String deploymentId); static String getEnergyEstimationForAnEventInAVMXMLInfo(
			EnergyMeasurement energyMeasurement, String applicationId, String deploymentId, String vmId, String eventId); static String getEnergyConsumptionForAnEventInAVMXMLInfo(
			EnergyMeasurement energyMeasurement, String applicationId, String deploymentId, String vmId, String eventId); static EnergyMeasurement addEnergyEstimationForAnEventInAVMXMLInfo(
			EnergyMeasurement energyMeasurement, String applicationId, String deploymentId, String vmId, String eventId); static EnergyMeasurement addEnergyConsumptionForAnEventInAVMXMLInfo(
			EnergyMeasurement energyMeasurement, String applicationId, String deploymentId, String vmId, String eventId); static EnergyMeasurement addEnergyEstimationForDeploymentXMLInfo(EnergyMeasurement energyMeasurement, 
																			String applicationId, 
																			String deploymentId, 
																			String eventId); static EnergyMeasurement addEnergyConsumptionForDeploymentXMLInfo(EnergyMeasurement energyMeasurement, 
																			 String applicationId, 
																			 String deploymentId, 
																			 String eventId); static PowerMeasurement addPowerEstimationForDeploymentXMLInfo(PowerMeasurement powerMeasurement, String applicationId, String deploymentId, String eventId); static PowerMeasurement addPowerConsumptionForDeploymentXMLInfo(PowerMeasurement powerMeasurement, String applicationId, String deploymentId, String eventId); static String getEnergyEstimationForDeploymentXMLInfo(EnergyMeasurement energyMeasurement, String applicationId, String deploymentId, String eventId); static String getPowerEstimationForDeploymentXMLInfo(PowerMeasurement powerMeasurement, String applicationId, String deploymentId, String eventId); static String getEventSampleCollectionXMLInfo(List<EventSample> eventSamples, String applicationId, String deploymentId, String vmId, String eventId); static Agreement addAgreementXMLInfo(Agreement agreement, String applicationId, int deploymentId); static String getAgreementXML(Agreement agreement, String applicationId, int deploymentId); static String getCollectionOfAgreements(List<Agreement> agreements, String applicationId, int deploymentId); static String getCollectionOfVMs(List<VM> vms, String applicationId, int deploymentId); static String getCostEstimationForAnEventInAVMXMLInfo(Cost cost, String applicationName, String deploymentId, String vmId, String eventId); static String getCostConsumptionForADeployment(Cost cost, String applicationName, String deploymentId); static PowerMeasurement addPowerConsumptionForAnEventInAVMXMLInfo(PowerMeasurement powerMeasurement, 
																			 String applicationId, 
																			 String deploymentId,
																			 String vmId, 
																			 String eventId); static PowerMeasurement addPowerEstimationForAnEventInAVMXMLInfo(PowerMeasurement powerMeasurement, 
																			String applicationId, 
																			String deploymentId,
																			String vmId,
																			String eventId); static String getPowerConsumptionForAnEventInAVMXMLInfo(PowerMeasurement powerMeasurement, 
																   String applicationId, 
																   String deploymentId,
																   String vmId, 
																   String eventId); static String getPowerEstimationForAnEventInAVMXMLInfo(PowerMeasurement powerMeasurement, 
																  String applicationId, 
																  String deploymentId,
																  String vmId, 
																  String eventId); static String getPowerConsumptionForDeploymentXMLInfo(PowerMeasurement powerMeasurement, String applicationName,	String deploymentId, String eventId); static String getEnergyConsumptionForDeploymentXMLInfo(EnergyMeasurement energyMeasurement, String applicationName,	String deploymentId, String eventId); static String getCostEstimationForAnEventInADeploymentXMLInfo(Cost cost, String applicationName, String deploymentId, String eventId); }
XMLBuilder { public static String getApplicationXML(Application application) { application = addApplicationXMLInfo(application); return ModelConverter.objectApplicationToXML(application); }  static String getApplicationXML(Application application); static String getApplicationJSON(Application application); static String getDeploymentXML(Deployment deployment, String applicationId); static String getDeploymentJSON(Deployment deployment, String applicationName); static String getVMXML(VM vm, String applicationId, int deploymentId); static String getCollectionApplicationsXML(List<Application> applications); static String getCollectionApplicationsJSON(List<Application> applications); static String getCollectionOfCacheImagesXML(List<Image> images, String applicationName); static String getCollectionOfDeploymentsXML(List<Deployment> deployments, String applicationId); static String getCollectionOfDeploymentsJSON(List<Deployment> deployments, String applicationId); static EnergyMeasurement addEnergyMeasurementForDeploymentXMLInfo(
			EnergyMeasurement energyMeasurement, String applicationId, String deploymentId, String href); static String getEnergyMeasurementForDeploymentXMLInfo(EnergyMeasurement energyMeasurement, String applicationId, String deploymentId); static PowerMeasurement addPowerMeasurementForDeploymentXMLInfo(
			PowerMeasurement powerMeasurement, String applicationId, String deploymentId, String href); static String getPowerMeasurementForDeploymentXMLInfo(PowerMeasurement powerMeasurement, String applicationId, String deploymentId); static String getEnergyEstimationForAnEventInAVMXMLInfo(
			EnergyMeasurement energyMeasurement, String applicationId, String deploymentId, String vmId, String eventId); static String getEnergyConsumptionForAnEventInAVMXMLInfo(
			EnergyMeasurement energyMeasurement, String applicationId, String deploymentId, String vmId, String eventId); static EnergyMeasurement addEnergyEstimationForAnEventInAVMXMLInfo(
			EnergyMeasurement energyMeasurement, String applicationId, String deploymentId, String vmId, String eventId); static EnergyMeasurement addEnergyConsumptionForAnEventInAVMXMLInfo(
			EnergyMeasurement energyMeasurement, String applicationId, String deploymentId, String vmId, String eventId); static EnergyMeasurement addEnergyEstimationForDeploymentXMLInfo(EnergyMeasurement energyMeasurement, 
																			String applicationId, 
																			String deploymentId, 
																			String eventId); static EnergyMeasurement addEnergyConsumptionForDeploymentXMLInfo(EnergyMeasurement energyMeasurement, 
																			 String applicationId, 
																			 String deploymentId, 
																			 String eventId); static PowerMeasurement addPowerEstimationForDeploymentXMLInfo(PowerMeasurement powerMeasurement, String applicationId, String deploymentId, String eventId); static PowerMeasurement addPowerConsumptionForDeploymentXMLInfo(PowerMeasurement powerMeasurement, String applicationId, String deploymentId, String eventId); static String getEnergyEstimationForDeploymentXMLInfo(EnergyMeasurement energyMeasurement, String applicationId, String deploymentId, String eventId); static String getPowerEstimationForDeploymentXMLInfo(PowerMeasurement powerMeasurement, String applicationId, String deploymentId, String eventId); static String getEventSampleCollectionXMLInfo(List<EventSample> eventSamples, String applicationId, String deploymentId, String vmId, String eventId); static Agreement addAgreementXMLInfo(Agreement agreement, String applicationId, int deploymentId); static String getAgreementXML(Agreement agreement, String applicationId, int deploymentId); static String getCollectionOfAgreements(List<Agreement> agreements, String applicationId, int deploymentId); static String getCollectionOfVMs(List<VM> vms, String applicationId, int deploymentId); static String getCostEstimationForAnEventInAVMXMLInfo(Cost cost, String applicationName, String deploymentId, String vmId, String eventId); static String getCostConsumptionForADeployment(Cost cost, String applicationName, String deploymentId); static PowerMeasurement addPowerConsumptionForAnEventInAVMXMLInfo(PowerMeasurement powerMeasurement, 
																			 String applicationId, 
																			 String deploymentId,
																			 String vmId, 
																			 String eventId); static PowerMeasurement addPowerEstimationForAnEventInAVMXMLInfo(PowerMeasurement powerMeasurement, 
																			String applicationId, 
																			String deploymentId,
																			String vmId,
																			String eventId); static String getPowerConsumptionForAnEventInAVMXMLInfo(PowerMeasurement powerMeasurement, 
																   String applicationId, 
																   String deploymentId,
																   String vmId, 
																   String eventId); static String getPowerEstimationForAnEventInAVMXMLInfo(PowerMeasurement powerMeasurement, 
																  String applicationId, 
																  String deploymentId,
																  String vmId, 
																  String eventId); static String getPowerConsumptionForDeploymentXMLInfo(PowerMeasurement powerMeasurement, String applicationName,	String deploymentId, String eventId); static String getEnergyConsumptionForDeploymentXMLInfo(EnergyMeasurement energyMeasurement, String applicationName,	String deploymentId, String eventId); static String getCostEstimationForAnEventInADeploymentXMLInfo(Cost cost, String applicationName, String deploymentId, String eventId);  }