dto.setDescription("Template description");
dto.setHdRequired(50L * 1024 * 1024 * 1024); // 50 GB
dto.setCpuRequired(5);
dto.setRamRequired(2048);
dto.addLink(new RESTLink("edit", "http://foo/bar"));
VirtualMachineTemplate template = wrap(context, VirtualMachineTemplate.class, dto);
VirtualDatacenterDto vdcDto = new VirtualDatacenterDto();
vdcDto.setId(6);
vdcDto.setHypervisorType(HypervisorType.VMX_04);
VirtualDatacenter vdc = wrap(context, VirtualDatacenter.class, vdcDto);
Hardware hardware = function.apply(new VirtualMachineTemplateInVirtualDatacenter(template, vdc));
verify(vdcToLocation);
assertEquals(hardware.getProviderId(), template.getId().toString());
assertEquals(hardware.getId(), template.getId() + "/" + vdc.getId());
assertEquals(hardware.getName(), template.getName());
assertEquals(hardware.getUri(), URI.create("http://foo/bar"));
assertEquals(hardware.getRam(), template.getRamRequired().intValue());
assertEquals(hardware.getProcessors().size(), 1);
assertEquals(hardware.getProcessors().get(0).getCores(), (double) template.getCpuRequired());
assertEquals(hardware.getProcessors().get(0).getSpeed(),
VirtualMachineTemplateInVirtualDatacenterToHardware.DEFAULT_CORE_SPEED);
assertEquals(hardware.getVolumes().size(), 1);
assertEquals(hardware.getVolumes().get(0).getSize(), 50F);