@Test public void addImageTest() { VM vm = new VM(); assertEquals(null, vm.getImages()); Image image = new Image(); vm.addImage(image); assertEquals(1, vm.getImages().size()); assertEquals(image, vm.getImages().get(0)); }
public void addImage(Image image) { if(images == null) images = new ArrayList<Image>(); images.add(image); }
VM { public void addImage(Image image) { if(images == null) images = new ArrayList<Image>(); images.add(image); } }
VM { public void addImage(Image image) { if(images == null) images = new ArrayList<Image>(); images.add(image); }  }
VM { public void addImage(Image image) { if(images == null) images = new ArrayList<Image>(); images.add(image); }  @Id @GeneratedValue(strategy=GenerationType.IDENTITY) @Column(name = "vm_id", unique = true, nullable = false) int getId(); void setId(int id); @Transient String getHref(); void setHref(String href); @Column(name = "ovf_id", nullable = true) String getOvfId(); void setOvfId(String ovfId); @Column(name = "provider_vm_id", nullable = true) String getProviderVmId(); void setProviderVmId(String providerVmId); @Column(name = "provider_id", nullable = true) String getProviderId(); void setProviderId(String providerId); @Column(name = "sla_agreement", nullable = true) String getSlaAgreement(); void setSlaAgreement(String slaAgreement); @Column(name = "ip_address", nullable = true) String getIp(); void setIp(String ip); void addImage(Image image); @ManyToMany(fetch = FetchType.EAGER/*, cascade = {CascadeType.ALL}*/) @JoinTable(name = "vms_images", joinColumns = { @JoinColumn(name = "vm_id", nullable = false) }, inverseJoinColumns = { @JoinColumn(name = "image_id", nullable = false) }) List<Image> getImages(); void setImages(List<Image> images); @Transient List<Link> getLinks(); void setLinks(List<Link> links); void addLink(Link link); @Column(name = "status", nullable = true) String getStatus(); void setStatus(String status); @Column(name = "cpu_max", nullable = true) int getCpuMax(); void setCpuMax(int cpuMax); @Column(name = "cpu_min", nullable = true) int getCpuMin(); void setCpuMin(int cpuMin); @Column(name = "cpu_actual", nullable = true) int getCpuActual(); void setCpuActual(int cpuActual); @Column(name = "ram_max", nullable = true) long getRamMax(); void setRamMax(long ramMax); @Column(name = "ram_min", nullable = true) long getRamMin(); void setRamMin(long ramMin); @Column(name = "ram_actual", nullable = true) long getRamActual(); void setRamActual(long ramActual); @Column(name = "swap_max", nullable = true) long getSwapMax(); void setSwapMax(long swapMax); @Column(name = "swap_min", nullable = true) long getSwapMin(); void setSwapMin(long swapMin); @Column(name = "swap_actual", nullable = true) long getSwapActual(); void setSwapActual(long swapActual); @Column(name = "disk_max", nullable = true) long getDiskMax(); void setDiskMax(long diskMax); @Column(name = "disk_min", nullable = true) long getDiskMin(); void setDiskMin(long diskMin); @Column(name = "disk_actual", nullable = true) long getDiskActual(); void setDiskActual(long diskActual); @Column(name = "number_vms_max", nullable = true) long getNumberVMsMax(); void setNumberVMsMax(long numberVMsMax); @Column(name = "number_vms_min", nullable = true) long getNumberVMsMin(); void setNumberVMsMin(long numberVMsMin); @Column(name = "price_schema", nullable = true) Long getPriceSchema(); void setPriceSchema(Long priceSchema); @Transient String getPhysicalHost(); void setPhysicalHost(String physicalHost); @ManyToOne(fetch=FetchType.EAGER) @JoinColumn(name="deployment_id") Deployment getDeployment(); void setDeployment(Deployment deployment); }
VM { public void addImage(Image image) { if(images == null) images = new ArrayList<Image>(); images.add(image); }  @Id @GeneratedValue(strategy=GenerationType.IDENTITY) @Column(name = "vm_id", unique = true, nullable = false) int getId(); void setId(int id); @Transient String getHref(); void setHref(String href); @Column(name = "ovf_id", nullable = true) String getOvfId(); void setOvfId(String ovfId); @Column(name = "provider_vm_id", nullable = true) String getProviderVmId(); void setProviderVmId(String providerVmId); @Column(name = "provider_id", nullable = true) String getProviderId(); void setProviderId(String providerId); @Column(name = "sla_agreement", nullable = true) String getSlaAgreement(); void setSlaAgreement(String slaAgreement); @Column(name = "ip_address", nullable = true) String getIp(); void setIp(String ip); void addImage(Image image); @ManyToMany(fetch = FetchType.EAGER/*, cascade = {CascadeType.ALL}*/) @JoinTable(name = "vms_images", joinColumns = { @JoinColumn(name = "vm_id", nullable = false) }, inverseJoinColumns = { @JoinColumn(name = "image_id", nullable = false) }) List<Image> getImages(); void setImages(List<Image> images); @Transient List<Link> getLinks(); void setLinks(List<Link> links); void addLink(Link link); @Column(name = "status", nullable = true) String getStatus(); void setStatus(String status); @Column(name = "cpu_max", nullable = true) int getCpuMax(); void setCpuMax(int cpuMax); @Column(name = "cpu_min", nullable = true) int getCpuMin(); void setCpuMin(int cpuMin); @Column(name = "cpu_actual", nullable = true) int getCpuActual(); void setCpuActual(int cpuActual); @Column(name = "ram_max", nullable = true) long getRamMax(); void setRamMax(long ramMax); @Column(name = "ram_min", nullable = true) long getRamMin(); void setRamMin(long ramMin); @Column(name = "ram_actual", nullable = true) long getRamActual(); void setRamActual(long ramActual); @Column(name = "swap_max", nullable = true) long getSwapMax(); void setSwapMax(long swapMax); @Column(name = "swap_min", nullable = true) long getSwapMin(); void setSwapMin(long swapMin); @Column(name = "swap_actual", nullable = true) long getSwapActual(); void setSwapActual(long swapActual); @Column(name = "disk_max", nullable = true) long getDiskMax(); void setDiskMax(long diskMax); @Column(name = "disk_min", nullable = true) long getDiskMin(); void setDiskMin(long diskMin); @Column(name = "disk_actual", nullable = true) long getDiskActual(); void setDiskActual(long diskActual); @Column(name = "number_vms_max", nullable = true) long getNumberVMsMax(); void setNumberVMsMax(long numberVMsMax); @Column(name = "number_vms_min", nullable = true) long getNumberVMsMin(); void setNumberVMsMin(long numberVMsMin); @Column(name = "price_schema", nullable = true) Long getPriceSchema(); void setPriceSchema(Long priceSchema); @Transient String getPhysicalHost(); void setPhysicalHost(String physicalHost); @ManyToOne(fetch=FetchType.EAGER) @JoinColumn(name="deployment_id") Deployment getDeployment(); void setDeployment(Deployment deployment);  }