@Test public void testFromApplication() { Application application = new Application(); application.setHref("href"); application.setId(1); application.setName("name"); List<Link> links = new ArrayList<Link>(); application.setLinks(links); List<Deployment> deployments = new ArrayList<Deployment>(); application.setDeployments(deployments); List<Image> images = new ArrayList<Image>(); application.setImages(images); Deployment deployment1 = new Deployment(); deployment1.setId(11); deployment1.setHref("href"); deployment1.setPrice("provider-id"); deployment1.setStatus("STATUS"); deployment1.setStartDate("aaa"); deployment1.setEndDate("bbb"); List<VM> vms = new ArrayList<VM>(); deployment1.setVms(vms); deployments.add(deployment1); Deployment deployment2 = new Deployment(); deployment2.setId(22); deployment2.setHref("href"); deployment2.setPrice("provider-id"); deployment2.setStatus("STATUS2"); deployment2.setStartDate("aaa"); deployment2.setEndDate("bbb"); deployments.add(deployment2); VM vm1 = new VM(); vm1.setId(12); vm1.setHref("href1"); vm1.setOvfId("ovfId1"); vm1.setProviderId("provider-id1"); vm1.setProviderVmId("provider-vm-id1"); vm1.setStatus("XXX1"); vm1.setIp("172.0.0.1"); vm1.setSlaAgreement("slaAggrementId1"); vm1.setProviderId("111"); vm1.setCpuActual(1); vm1.setDiskActual(2l); vm1.setRamActual(3l); vm1.setSwapActual(4l); vm1.setPriceSchema(20l); vms.add(vm1); VM vm2 = new VM(); vm2.setId(22); vm2.setHref("href2"); vm2.setOvfId("ovfId2"); vm2.setProviderId("provider-id2"); vm2.setProviderVmId("provider-vm-id2"); vm2.setStatus("XXX2"); vm2.setIp("172.0.0.12"); vm2.setSlaAgreement("slaAggrementId2"); vm2.setProviderId(null); vms.add(vm2); ApplicationManagerMessage amMessage = MessageCreator.fromApplication(application); assertEquals("name", amMessage.getApplicationId()); assertEquals("11", amMessage.getDeploymentId()); assertEquals("STATUS", amMessage.getStatus()); assertEquals("provider-vm-id1", amMessage.getVms().get(0).getIaasVmId()); assertEquals("ovfId1", amMessage.getVms().get(0).getOvfId()); assertEquals("XXX1", amMessage.getVms().get(0).getStatus()); assertEquals("12", amMessage.getVms().get(0).getVmId()); assertEquals(1, amMessage.getVms().get(0).getCpu()); assertEquals(3l, amMessage.getVms().get(0).getRam()); assertEquals(2l, amMessage.getVms().get(0).getDisk()); assertEquals(4l, amMessage.getVms().get(0).getSwap()); assertEquals(20, amMessage.getVms().get(0).getPriceSchema()); assertEquals("provider-vm-id2", amMessage.getVms().get(1).getIaasVmId()); assertEquals("ovfId2", amMessage.getVms().get(1).getOvfId()); assertEquals("XXX2", amMessage.getVms().get(1).getStatus()); assertEquals("22", amMessage.getVms().get(1).getVmId()); assertEquals("", amMessage.getVms().get(1).getProviderId()); }
public static ApplicationManagerMessage fromApplication(Application application) { if(application == null) { return null; } ApplicationManagerMessage message = new ApplicationManagerMessage(); message.setApplicationId(application.getName()); if(application.getDeployments() != null && application.getDeployments().size() > 0) { completeMessage(message, application.getDeployments().get(0), null); } return message; }
MessageCreator { public static ApplicationManagerMessage fromApplication(Application application) { if(application == null) { return null; } ApplicationManagerMessage message = new ApplicationManagerMessage(); message.setApplicationId(application.getName()); if(application.getDeployments() != null && application.getDeployments().size() > 0) { completeMessage(message, application.getDeployments().get(0), null); } return message; } }
MessageCreator { public static ApplicationManagerMessage fromApplication(Application application) { if(application == null) { return null; } ApplicationManagerMessage message = new ApplicationManagerMessage(); message.setApplicationId(application.getName()); if(application.getDeployments() != null && application.getDeployments().size() > 0) { completeMessage(message, application.getDeployments().get(0), null); } return message; }  }
MessageCreator { public static ApplicationManagerMessage fromApplication(Application application) { if(application == null) { return null; } ApplicationManagerMessage message = new ApplicationManagerMessage(); message.setApplicationId(application.getName()); if(application.getDeployments() != null && application.getDeployments().size() > 0) { completeMessage(message, application.getDeployments().get(0), null); } return message; }  static ApplicationManagerMessage fromApplication(Application application); static ApplicationManagerMessage fromDeployment(String applicationName, Deployment deployment, String status); static ApplicationManagerMessage fromVM(String applicationName, Deployment deployment, VM vm); }
MessageCreator { public static ApplicationManagerMessage fromApplication(Application application) { if(application == null) { return null; } ApplicationManagerMessage message = new ApplicationManagerMessage(); message.setApplicationId(application.getName()); if(application.getDeployments() != null && application.getDeployments().size() > 0) { completeMessage(message, application.getDeployments().get(0), null); } return message; }  static ApplicationManagerMessage fromApplication(Application application); static ApplicationManagerMessage fromDeployment(String applicationName, Deployment deployment, String status); static ApplicationManagerMessage fromVM(String applicationName, Deployment deployment, VM vm);  }