@Test public void getCollectionOfCacheImagesTest() throws JAXBException { Image image1 = new Image(); image1.setDemo(true); image1.setId(1); image1.setOvfHref("ovf-href-1"); image1.setOvfId("ovf-id1"); image1.setProviderImageId("uuid1"); Image image2 = new Image(); image2.setDemo(true); image2.setId(2); image2.setOvfHref("ovf-href-2"); image2.setOvfId("ovf-id2"); image2.setProviderImageId("uuid2"); List<Image> images = new ArrayList<Image>(); images.add(image1); images.add(image2); String xml = XMLBuilder.getCollectionOfCacheImagesXML(images, "name"); JAXBContext jaxbContext = JAXBContext.newInstance(Collection.class); Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller(); Collection collection = (Collection) jaxbUnmarshaller.unmarshal(new StringReader(xml)); assertEquals("/applications/name/cache-images", collection.getHref()); assertEquals(0, collection.getItems().getOffset()); assertEquals(2, collection.getItems().getTotal()); assertEquals(2, collection.getLinks().size()); assertEquals("/applications/name", collection.getLinks().get(0).getHref()); assertEquals("parent", collection.getLinks().get(0).getRel()); assertEquals(MediaType.APPLICATION_XML, collection.getLinks().get(0).getType()); assertEquals("/applications/name/cache-images", collection.getLinks().get(1).getHref()); assertEquals("self", collection.getLinks().get(1).getRel()); assertEquals(MediaType.APPLICATION_XML, collection.getLinks().get(1).getType()); assertEquals(2, collection.getItems().getImages().size()); image1 = collection.getItems().getImages().get(0); assertEquals("/applications/name/cache-images/1", image1.getHref()); assertEquals(1, image1.getId()); assertEquals("ovf-href-1", image1.getOvfHref()); assertEquals("ovf-id1", image1.getOvfId()); assertEquals("uuid1", image1.getProviderImageId()); image2 = collection.getItems().getImages().get(1); assertEquals("/applications/name/cache-images/2", image2.getHref()); assertEquals(2, image2.getId()); assertEquals("ovf-href-2", image2.getOvfHref()); assertEquals("ovf-id2", image2.getOvfId()); assertEquals("uuid2", image2.getProviderImageId()); }
public static String getCollectionOfCacheImagesXML(List<Image> images, String applicationName) { Collection collection = new Collection(); collection.setHref("/applications/" + applicationName + "/cache-images"); Link linkParent = new Link(); linkParent.setHref("/applications/" + applicationName); linkParent.setRel("parent"); linkParent.setType(MediaType.APPLICATION_XML); collection.addLink(linkParent); Link linkSelf = new Link(); linkSelf.setHref(collection.getHref()); linkSelf.setRel("self"); linkSelf.setType(MediaType.APPLICATION_XML); collection.addLink(linkSelf); Items items = new Items(); items.setOffset(0); collection.setItems(items); if(images != null) { items.setTotal(images.size()); for(Image image : images) { image.setHref(collection.getHref() + "/" + image.getId()); items.addImage(image); } } return ModelConverter.objectCollectionToXML(collection); }
XMLBuilder { public static String getCollectionOfCacheImagesXML(List<Image> images, String applicationName) { Collection collection = new Collection(); collection.setHref("/applications/" + applicationName + "/cache-images"); Link linkParent = new Link(); linkParent.setHref("/applications/" + applicationName); linkParent.setRel("parent"); linkParent.setType(MediaType.APPLICATION_XML); collection.addLink(linkParent); Link linkSelf = new Link(); linkSelf.setHref(collection.getHref()); linkSelf.setRel("self"); linkSelf.setType(MediaType.APPLICATION_XML); collection.addLink(linkSelf); Items items = new Items(); items.setOffset(0); collection.setItems(items); if(images != null) { items.setTotal(images.size()); for(Image image : images) { image.setHref(collection.getHref() + "/" + image.getId()); items.addImage(image); } } return ModelConverter.objectCollectionToXML(collection); } }
XMLBuilder { public static String getCollectionOfCacheImagesXML(List<Image> images, String applicationName) { Collection collection = new Collection(); collection.setHref("/applications/" + applicationName + "/cache-images"); Link linkParent = new Link(); linkParent.setHref("/applications/" + applicationName); linkParent.setRel("parent"); linkParent.setType(MediaType.APPLICATION_XML); collection.addLink(linkParent); Link linkSelf = new Link(); linkSelf.setHref(collection.getHref()); linkSelf.setRel("self"); linkSelf.setType(MediaType.APPLICATION_XML); collection.addLink(linkSelf); Items items = new Items(); items.setOffset(0); collection.setItems(items); if(images != null) { items.setTotal(images.size()); for(Image image : images) { image.setHref(collection.getHref() + "/" + image.getId()); items.addImage(image); } } return ModelConverter.objectCollectionToXML(collection); }  }
XMLBuilder { public static String getCollectionOfCacheImagesXML(List<Image> images, String applicationName) { Collection collection = new Collection(); collection.setHref("/applications/" + applicationName + "/cache-images"); Link linkParent = new Link(); linkParent.setHref("/applications/" + applicationName); linkParent.setRel("parent"); linkParent.setType(MediaType.APPLICATION_XML); collection.addLink(linkParent); Link linkSelf = new Link(); linkSelf.setHref(collection.getHref()); linkSelf.setRel("self"); linkSelf.setType(MediaType.APPLICATION_XML); collection.addLink(linkSelf); Items items = new Items(); items.setOffset(0); collection.setItems(items); if(images != null) { items.setTotal(images.size()); for(Image image : images) { image.setHref(collection.getHref() + "/" + image.getId()); items.addImage(image); } } return ModelConverter.objectCollectionToXML(collection); }  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 getCollectionOfCacheImagesXML(List<Image> images, String applicationName) { Collection collection = new Collection(); collection.setHref("/applications/" + applicationName + "/cache-images"); Link linkParent = new Link(); linkParent.setHref("/applications/" + applicationName); linkParent.setRel("parent"); linkParent.setType(MediaType.APPLICATION_XML); collection.addLink(linkParent); Link linkSelf = new Link(); linkSelf.setHref(collection.getHref()); linkSelf.setRel("self"); linkSelf.setType(MediaType.APPLICATION_XML); collection.addLink(linkSelf); Items items = new Items(); items.setOffset(0); collection.setItems(items); if(images != null) { items.setTotal(images.size()); for(Image image : images) { image.setHref(collection.getHref() + "/" + image.getId()); items.addImage(image); } } return ModelConverter.objectCollectionToXML(collection); }  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);  }