}
public void testGetVApp() throws UnknownHostException {
InputStream is = getClass().getResourceAsStream("/get_vapp.xml");
VApp result = factory.create(
injector.getInstance(VAppHandler.class)).parse(is);
assertEquals(result.getName(), "centos-53");
assertEquals(result.getStatus(), Status.OFF);
assertEquals(result.getSize().longValue(), 10485760);
assertEquals(result.getOperatingSystemDescription(), "Red Hat Enterprise Linux 5 (64-bit)");
assertEquals(result.getHref(), URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/vapp/16238"));
assertEquals(result.getVDC(), new ReferenceTypeImpl(null, TerremarkVCloudMediaType.VDC_XML, URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32")));
VirtualSystemSettingData system = VirtualSystemSettingData.builder().instanceID("0").elementName(
"Virtual Hardware Family").virtualSystemIdentifier("centos-53").virtualSystemType("vmx-07").build();
assertEquals(result.getSystem().toString(), system.toString());
assertEquals(result.getNetworkToAddresses().get("Internal"), ImmutableList.<String> of("10.114.34.132"));
ResourceAllocationSettingData cpu = ResourceAllocationSettingData.builder().instanceID("1").elementName(
"1 virtual CPU(s)").description("Number of Virtual CPUs").resourceType(ResourceType.PROCESSOR)
.virtualQuantity(2l).virtualQuantityUnits("hertz * 10^6").build();
ResourceAllocationSettingData controller = ResourceAllocationSettingData.builder().instanceID("3").elementName(
"SCSI Controller 0").description("SCSI Controller").resourceType(ResourceType.PARALLEL_SCSI_HBA)
.resourceSubType("lsilogic").address("0").virtualQuantity(1l).build();
ResourceAllocationSettingData memory = ResourceAllocationSettingData.builder().instanceID("2").elementName(
"512MB of memory").description("Memory Size").resourceType(ResourceType.MEMORY).virtualQuantity(512l)
.virtualQuantityUnits("byte * 2^20").build();
ResourceAllocationSettingData disk = ResourceAllocationSettingData.builder().instanceID("9").elementName(
"Hard Disk 1").resourceType(ResourceType.DISK_DRIVE).hostResource("10485760").addressOnParent("0")
.virtualQuantity(10485760l).virtualQuantityUnits("byte * 2^20").build();
assertEquals(result.getResourceAllocations(), ImmutableSet.of(cpu, memory, controller, disk));
assertEquals(find(result.getResourceAllocations(), CIMPredicates.resourceTypeIn(ResourceType.PROCESSOR))
.getVirtualQuantity().intValue(), 1);
find(result.getResourceAllocations(), CIMPredicates.resourceTypeIn(ResourceType.PARALLEL_SCSI_HBA));
assertEquals(find(result.getResourceAllocations(), CIMPredicates.resourceTypeIn(ResourceType.MEMORY))
.getVirtualQuantity().intValue(), 512);
assertEquals(find(result.getResourceAllocations(), CIMPredicates.resourceTypeIn(ResourceType.DISK_DRIVE))
.getVirtualQuantity().longValue(), 10485760);
assertEquals(result.getSize().longValue(), find(result.getResourceAllocations(),
CIMPredicates.resourceTypeIn(ResourceType.DISK_DRIVE)).getVirtualQuantity().longValue());
}