### Question:
VirtualGuestToHardware implements Function<VirtualGuest, Hardware> { @Override public Hardware apply(final VirtualGuest from) { HardwareBuilder builder = new HardwareBuilder().ids(from.getId() + "") .name(from.getHostname()) .hypervisor("XenServer") .processors(ImmutableList.of(new Processor(from.getStartCpus(), 2))) .ram(from.getMaxMemory()); if (from.getVirtualGuestBlockDevices() != null) { builder.volumes( FluentIterable.from(from.getVirtualGuestBlockDevices()).filter(new Predicate<VirtualGuestBlockDevice>() { @Override public boolean apply(VirtualGuestBlockDevice input) { return input.getMountType().equals("Disk"); } }) .transform(new Function<VirtualGuestBlockDevice, Volume>() { @Override public Volume apply(VirtualGuestBlockDevice item) { float volumeSize = -1; if (item.getVirtualDiskImage() != null) { volumeSize = item.getVirtualDiskImage().getCapacity(); } return new VolumeImpl( item.getId() + "", from.isLocalDiskFlag() ? Volume.Type.LOCAL : Volume.Type.SAN, volumeSize, null, item.getBootableFlag() == 1, false); } }).toSet()); } return builder.build(); }  @Override Hardware apply(final VirtualGuest from);  }### Answer:
@Test public void testVirtualGuestToHardware() { VirtualGuest virtualGuest = createVirtualGuest(); Hardware hardware = new VirtualGuestToHardware().apply(virtualGuest); assertNotNull(hardware); assertEquals(hardware.getRam(), virtualGuest.getMaxMemory()); assertTrue(hardware.getProcessors().size() == 1); assertEquals(Iterables.get(hardware.getProcessors(), 0).getCores(), (double) virtualGuest.getStartCpus()); }