@Test public void getEventSampleCollectionXMLInfo() throws Exception { EventSample eventSample1 = new EventSample(); eventSample1.setCvalue(1.0); eventSample1.setEvalue(2.0); eventSample1.setPvalue(3.0); eventSample1.setTimestampBeging(1l); eventSample1.setTimestampEnd(2l); eventSample1.setVmid("vmid"); eventSample1.setAppid("appid"); EventSample eventSample2 = new EventSample(); eventSample2.setCvalue(4.0); eventSample2.setEvalue(5.0); eventSample2.setPvalue(6.0); eventSample2.setTimestampBeging(3l); eventSample2.setTimestampEnd(4l); eventSample2.setVmid("vmid2"); eventSample2.setAppid("appid2"); List<EventSample> eventSamples = new ArrayList<EventSample>(); eventSamples.add(eventSample1); eventSamples.add(eventSample2); String xml = XMLBuilder.getEventSampleCollectionXMLInfo(eventSamples, "appId", "deploymentId", "vmId", "eventId"); JAXBContext jaxbContext = JAXBContext.newInstance(Collection.class); Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller(); Collection collection = (Collection) jaxbUnmarshaller.unmarshal(new StringReader(xml)); assertEquals("/applications/appId/deployments/deploymentId/vms/vmId/events/eventId/event-samples", collection.getHref()); assertEquals(0, collection.getItems().getOffset()); assertEquals(2, collection.getItems().getTotal()); assertEquals(2, collection.getLinks().size()); assertEquals("/applications/appId/deployments/deploymentId/vms/vmId/events/eventId", collection.getLinks().get(0).getHref()); assertEquals("parent", collection.getLinks().get(0).getRel()); assertEquals(MediaType.APPLICATION_XML, collection.getLinks().get(0).getType()); assertEquals("/applications/appId/deployments/deploymentId/vms/vmId/events/eventId/event-samples", 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().getEventSamples().size()); assertEquals(1.0, collection.getItems().getEventSamples().get(0).getCvalue(), 0.00001); assertEquals(2.0, collection.getItems().getEventSamples().get(0).getEvalue(), 0.00001); assertEquals(3.0, collection.getItems().getEventSamples().get(0).getPvalue(), 0.00001); assertEquals(1l, collection.getItems().getEventSamples().get(0).getTimestampBeging()); assertEquals(2l, collection.getItems().getEventSamples().get(0).getTimestampEnd()); assertEquals("vmid", collection.getItems().getEventSamples().get(0).getVmid()); assertEquals("appid", collection.getItems().getEventSamples().get(0).getAppid()); assertEquals(4.0, collection.getItems().getEventSamples().get(1).getCvalue(), 0.00001); assertEquals(5.0, collection.getItems().getEventSamples().get(1).getEvalue(), 0.00001); assertEquals(6.0, collection.getItems().getEventSamples().get(1).getPvalue(), 0.00001); assertEquals(3l, collection.getItems().getEventSamples().get(1).getTimestampBeging()); assertEquals(4l, collection.getItems().getEventSamples().get(1).getTimestampEnd()); assertEquals("vmid2", collection.getItems().getEventSamples().get(1).getVmid()); assertEquals("appid2", collection.getItems().getEventSamples().get(1).getAppid()); }
public static String getEventSampleCollectionXMLInfo(List<EventSample> eventSamples, String applicationId, String deploymentId, String vmId, String eventId) { Collection collection = new Collection(); String parentHref = "/applications/" + applicationId + "/deployments/" + deploymentId + "/vms/" + vmId + "/events/" + eventId; collection.setHref(parentHref + "/event-samples"); Link linkParent = new Link(); linkParent.setHref(parentHref); 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); items.setTotal(eventSamples.size()); items.setEventSamples(eventSamples); collection.setItems(items); return ModelConverter.objectCollectionToXML(collection); }
XMLBuilder { public static String getEventSampleCollectionXMLInfo(List<EventSample> eventSamples, String applicationId, String deploymentId, String vmId, String eventId) { Collection collection = new Collection(); String parentHref = "/applications/" + applicationId + "/deployments/" + deploymentId + "/vms/" + vmId + "/events/" + eventId; collection.setHref(parentHref + "/event-samples"); Link linkParent = new Link(); linkParent.setHref(parentHref); 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); items.setTotal(eventSamples.size()); items.setEventSamples(eventSamples); collection.setItems(items); return ModelConverter.objectCollectionToXML(collection); } }
XMLBuilder { public static String getEventSampleCollectionXMLInfo(List<EventSample> eventSamples, String applicationId, String deploymentId, String vmId, String eventId) { Collection collection = new Collection(); String parentHref = "/applications/" + applicationId + "/deployments/" + deploymentId + "/vms/" + vmId + "/events/" + eventId; collection.setHref(parentHref + "/event-samples"); Link linkParent = new Link(); linkParent.setHref(parentHref); 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); items.setTotal(eventSamples.size()); items.setEventSamples(eventSamples); collection.setItems(items); return ModelConverter.objectCollectionToXML(collection); }  }
XMLBuilder { public static String getEventSampleCollectionXMLInfo(List<EventSample> eventSamples, String applicationId, String deploymentId, String vmId, String eventId) { Collection collection = new Collection(); String parentHref = "/applications/" + applicationId + "/deployments/" + deploymentId + "/vms/" + vmId + "/events/" + eventId; collection.setHref(parentHref + "/event-samples"); Link linkParent = new Link(); linkParent.setHref(parentHref); 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); items.setTotal(eventSamples.size()); items.setEventSamples(eventSamples); collection.setItems(items); 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 getEventSampleCollectionXMLInfo(List<EventSample> eventSamples, String applicationId, String deploymentId, String vmId, String eventId) { Collection collection = new Collection(); String parentHref = "/applications/" + applicationId + "/deployments/" + deploymentId + "/vms/" + vmId + "/events/" + eventId; collection.setHref(parentHref + "/event-samples"); Link linkParent = new Link(); linkParent.setHref(parentHref); 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); items.setTotal(eventSamples.size()); items.setEventSamples(eventSamples); collection.setItems(items); 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);  }