String expectedImageId, OperatingSystem expectedOs, Image existingImage) {
Set<Image> images = existingImage == null ? ImmutableSet.<Image> of() : ImmutableSet.of(existingImage);
Set<Hardware> hardwares = existingHardware == null ? ImmutableSet.<Hardware> of() : ImmutableSet
.of(existingHardware);
Machine machineToConvert = new ParseCreatedMachineTest().expected();
MachineInDatacenter machineInDatacenterToConvert = new MachineInDatacenter(machineToConvert, "us-sw-1");
MachineInDatacenterToNodeMetadata converter = new MachineInDatacenterToNodeMetadata(
JoyentCloudComputeServiceContextModule.toPortableNodeStatus, locationIndex,
Suppliers.<Set<? extends Image>> ofInstance(images),
Suppliers.<Set<? extends Hardware>> ofInstance(hardwares), namingConvention);
NodeMetadata convertedNodeMetadata = converter.apply(machineInDatacenterToConvert);
assertEquals(machineInDatacenterToConvert.slashEncode(), convertedNodeMetadata.getId());
assertEquals(machineToConvert.getId(), convertedNodeMetadata.getProviderId());
assertEquals(convertedNodeMetadata.getLocation().getScope(), LocationScope.ZONE);
assertEquals(convertedNodeMetadata.getLocation().getId(), "us-sw-1");
assertEquals(machineToConvert.getName(), convertedNodeMetadata.getName());
assertEquals(convertedNodeMetadata.getGroup(), "sample");
assertEquals(convertedNodeMetadata.getImageId(), expectedImageId);
assertEquals(convertedNodeMetadata.getOperatingSystem(), expectedOs);
assertEquals(convertedNodeMetadata.getHardware(), expectedHardware);
assertEquals(JoyentCloudComputeServiceContextModule.toPortableNodeStatus.get(machineToConvert.getState()),
convertedNodeMetadata.getStatus());
assertNotNull(convertedNodeMetadata.getPrivateAddresses());
assertEquals(convertedNodeMetadata.getPrivateAddresses(), ImmutableSet.of("10.224.0.63"));