@Test public void testApplyWhereVirtualMachineWithIPForwardingRule() throws UnknownHostException { Supplier<Set<? extends Location>> locationSupplier = Suppliers.<Set<? extends Location>> ofInstance(ImmutableSet .<Location>of(ZoneToLocationTest.one, ZoneToLocationTest.two)); Supplier<Set<? extends Image>> imageSupplier = Suppliers.<Set<? extends Image>> ofInstance(ImmutableSet .<Image>of(TemplateToImageTest.one, TemplateToImageTest.two)); VirtualMachineToNodeMetadata parser = new VirtualMachineToNodeMetadata(locationSupplier, imageSupplier, CacheBuilder.newBuilder().<String, Set<IPForwardingRule>> build( new CacheLoader<String, Set<IPForwardingRule>>() { @Override public Set<IPForwardingRule> load(String arg0) throws Exception { return ImmutableSet.of(IPForwardingRule.builder().id("1234l").IPAddress("1.1.1.1").build()); } }), namingConvention); // notice if we've already parsed this properly here, we can rely on it. VirtualMachine guest = Iterables.get(new ListVirtualMachinesResponseTest().expected(), 0); NodeMetadata node = parser.apply(guest); assertEquals( node.toString(), new NodeMetadataBuilder().id("54").providerId("54").name("i-3-54-VM").group("i-3-54") .location(ZoneToLocationTest.one).status(Status.PENDING).hostname("i-3-54-VM") .privateAddresses(ImmutableSet.of("10.1.1.18")).publicAddresses(ImmutableSet.of("1.1.1.1")) .hardware(addHypervisor(ServiceOfferingToHardwareTest.one, "XenServer")) .imageId(TemplateToImageTest.one.getId()) .operatingSystem(TemplateToImageTest.one.getOperatingSystem()).build().toString()); }
@Test public void testApplyWhereVirtualMachineWithNoPassword() throws UnknownHostException { Supplier<Set<? extends Location>> locationSupplier = Suppliers.<Set<? extends Location>> ofInstance(ImmutableSet .<Location>of(ZoneToLocationTest.one, ZoneToLocationTest.two)); Supplier<Set<? extends Image>> imageSupplier = Suppliers.<Set<? extends Image>> ofInstance(ImmutableSet .<Image>of(TemplateToImageTest.one, TemplateToImageTest.two)); VirtualMachineToNodeMetadata parser = new VirtualMachineToNodeMetadata(locationSupplier, imageSupplier, CacheBuilder.newBuilder().<String, Set<IPForwardingRule>> build( new CacheLoader<String, Set<IPForwardingRule>>() { @Override public Set<IPForwardingRule> load(String arg0) throws Exception { throw new ResourceNotFoundException("no ip forwarding rule for: " + arg0); } }), namingConvention); // notice if we've already parsed this properly here, we can rely on it. VirtualMachine guest = Iterables.get(new ListVirtualMachinesResponseTest().expected(), 0); NodeMetadata node = parser.apply(guest); assertEquals( node.toString(), new NodeMetadataBuilder().id("54").providerId("54").name("i-3-54-VM").group("i-3-54") .location(ZoneToLocationTest.one).status(Status.PENDING).hostname("i-3-54-VM") .privateAddresses(ImmutableSet.of("10.1.1.18")) .hardware(addHypervisor(ServiceOfferingToHardwareTest.one, "XenServer")) .imageId(TemplateToImageTest.one.getId()) .operatingSystem(TemplateToImageTest.one.getOperatingSystem()).build().toString()); }
@Test public void testApplyWhereVirtualMachineWithNoPassword() throws UnknownHostException { Supplier<Set<? extends Location>> locationSupplier = Suppliers.<Set<? extends Location>> ofInstance(ImmutableSet .<Location>of(ZoneToLocationTest.one, ZoneToLocationTest.two)); Supplier<Set<? extends Image>> imageSupplier = Suppliers.<Set<? extends Image>> ofInstance(ImmutableSet .<Image>of(TemplateToImageTest.one, TemplateToImageTest.two)); VirtualMachineToNodeMetadata parser = new VirtualMachineToNodeMetadata(locationSupplier, imageSupplier, CacheBuilder.newBuilder().<String, Set<IPForwardingRule>> build( new CacheLoader<String, Set<IPForwardingRule>>() { @Override public Set<IPForwardingRule> load(String arg0) throws Exception { throw new ResourceNotFoundException("no ip forwarding rule for: " + arg0); } }), namingConvention); // notice if we've already parsed this properly here, we can rely on it. VirtualMachine guest = Iterables.get(new ListVirtualMachinesResponseTest().expected(), 0); NodeMetadata node = parser.apply(guest); assertEquals( node.toString(), new NodeMetadataBuilder().id("54").providerId("54").name("i-3-54-VM").group("i-3-54") .location(ZoneToLocationTest.one).status(Status.PENDING).hostname("i-3-54-VM") .privateAddresses(ImmutableSet.of("10.1.1.18")) .hardware(addHypervisor(ServiceOfferingToHardwareTest.one, "XenServer")) .imageId(TemplateToImageTest.one.getId()) .operatingSystem(TemplateToImageTest.one.getOperatingSystem()) .tags(ImmutableSet.of("another-tag")) .userMetadata(ImmutableMap.of("some-tag", "some-value")) .build().toString()); }
@Test public void testApplyWhereVirtualMachineWithIPForwardingRule() throws UnknownHostException { Supplier<Set<? extends Location>> locationSupplier = Suppliers.<Set<? extends Location>> ofInstance(ImmutableSet .<Location>of(ZoneToLocationTest.one, ZoneToLocationTest.two)); Supplier<Set<? extends Image>> imageSupplier = Suppliers.<Set<? extends Image>> ofInstance(ImmutableSet .<Image>of(TemplateToImageTest.one, TemplateToImageTest.two)); VirtualMachineToNodeMetadata parser = new VirtualMachineToNodeMetadata(locationSupplier, imageSupplier, CacheBuilder.newBuilder().<String, Set<IPForwardingRule>> build( new CacheLoader<String, Set<IPForwardingRule>>() { @Override public Set<IPForwardingRule> load(String arg0) throws Exception { return ImmutableSet.of(IPForwardingRule.builder().id("1234l").IPAddress("1.1.1.1").build()); } }), namingConvention); // notice if we've already parsed this properly here, we can rely on it. VirtualMachine guest = Iterables.get(new ListVirtualMachinesResponseTest().expected(), 0); NodeMetadata node = parser.apply(guest); assertEquals( node.toString(), new NodeMetadataBuilder().id("54").providerId("54").name("i-3-54-VM").group("i-3-54") .location(ZoneToLocationTest.one).status(Status.PENDING).hostname("i-3-54-VM") .privateAddresses(ImmutableSet.of("10.1.1.18")).publicAddresses(ImmutableSet.of("1.1.1.1")) .hardware(addHypervisor(ServiceOfferingToHardwareTest.one, "XenServer")) .imageId(TemplateToImageTest.one.getId()) .operatingSystem(TemplateToImageTest.one.getOperatingSystem()) .tags(ImmutableSet.of("another-tag")) .userMetadata(ImmutableMap.of("some-tag", "some-value")) .build().toString() ); }