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);
Server serverToConvert = new ParseServerTest().expected();
ServerInZone serverInZoneToConvert = new ServerInZone(serverToConvert, "az-1.region-a.geo-1");
ServerInZoneToNodeMetadata converter = new ServerInZoneToNodeMetadata(
NovaComputeServiceContextModule.toPortableNodeStatus, locationIndex, Suppliers
.<Set<? extends Image>> ofInstance(images), Suppliers
.<Set<? extends Hardware>> ofInstance(hardwares), namingConvention);
NodeMetadata convertedNodeMetadata = converter.apply(serverInZoneToConvert);
assertEquals(serverInZoneToConvert.slashEncode(), convertedNodeMetadata.getId());
assertEquals(serverToConvert.getId(), convertedNodeMetadata.getProviderId());
assertEquals(convertedNodeMetadata.getLocation().getScope(), LocationScope.HOST);
assertEquals(convertedNodeMetadata.getLocation().getId(), "e4d909c290d0fb1ca068ffaddf22cbd0");
assertEquals(convertedNodeMetadata.getLocation().getParent(), locationIndex.get().get("az-1.region-a.geo-1"));
assertEquals(serverToConvert.getName(), convertedNodeMetadata.getName());
assertEquals(convertedNodeMetadata.getGroup(), "sample");
assertEquals(convertedNodeMetadata.getImageId(), expectedImageId);
assertEquals(convertedNodeMetadata.getOperatingSystem(), expectedOs);
assertEquals(convertedNodeMetadata.getHardware(), expectedHardware);
assertEquals(NovaComputeServiceContextModule.toPortableNodeStatus.get(serverToConvert.getStatus()),
convertedNodeMetadata.getStatus());
assertNotNull(convertedNodeMetadata.getPrivateAddresses());
assertEquals(convertedNodeMetadata.getPrivateAddresses(), ImmutableSet.of("10.176.42.16"));