### Question:
VirtualGuestToImage implements Function<VirtualGuest, Image> { @Override public Image apply(VirtualGuest from) { checkNotNull(from, "from"); if (from.getOperatingSystem() == null) { return new ImageBuilder().ids(getReferenceCodeOrId(from)) .name(from.getHostname()) .status(Image.Status.UNRECOGNIZED) .operatingSystem(OperatingSystem.builder() .family(OsFamily.UNRECOGNIZED) .version(UNRECOGNIZED) .description(UNRECOGNIZED) .build()) .build(); } else { return operatingSystemToImage.apply(from.getOperatingSystem()); } } @Inject protected  VirtualGuestToImage(OperatingSystemToImage operatingSystemToImage); @Override Image apply(VirtualGuest from); String getReferenceCodeOrId(VirtualGuest from);  }### Answer:
@Test public void testVirtualGuestToImageWhenOperatingSystemIsNull() { VirtualGuest virtualGuest = createVirtualGuestWithoutOperatingSystem(); Image image = new VirtualGuestToImage(operatingSystemToImage).apply(virtualGuest); assertNotNull(image); assertEquals(image.getStatus(), Image.Status.UNRECOGNIZED); assertEquals(image.getOperatingSystem().getFamily(), OsFamily.UNRECOGNIZED); assertEquals(image.getOperatingSystem().getVersion(), "UNRECOGNIZED"); }
@Test public void testVirtualGuestToImageWhenVirtualGuestIsSoftwareLicense() { VirtualGuest virtualGuest = createVirtualGuestWithoutSoftwareLicenseDetails(); Image image = new VirtualGuestToImage(operatingSystemToImage).apply(virtualGuest); assertNotNull(image); assertEquals(image.getOperatingSystem().getFamily(), OsFamily.UNRECOGNIZED); assertEquals(image.getOperatingSystem().getVersion(), "UNRECOGNIZED"); }
@Test public void testVirtualGuestToImageWithSoftwareLicense() { VirtualGuest virtualGuest = createVirtualGuestWithSoftwareLicenseDetails(); Image image = new VirtualGuestToImage(operatingSystemToImage).apply(virtualGuest); assertNotNull(image); assertEquals(image.getOperatingSystem().getFamily(), OsFamily.UBUNTU); assertEquals(image.getOperatingSystem().getVersion(), "12.04"); assertEquals(image.getOperatingSystem().is64Bit(), true); }