VCloudComputeServiceAdapter implements ComputeServiceAdapter<VApp, VAppTemplate, VAppTemplate, Location> { @Override public Iterable<VAppTemplate> listHardwareProfiles() { return supportedTemplates(); } @Inject protected  VCloudComputeServiceAdapter(VCloudClient client, Predicate<URI> successTester,
            InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployAndPowerOn booter,
            Supplier<Map<String, Org>> nameToOrg, VAppTemplatesSupplier templates,
            Function<VAppTemplate, Envelope> templateToEnvelope); @Override NodeAndInitialCredentials<VApp> createNodeWithGroupEncodedIntoName(String group, String name,
            Template template); @Override Iterable<VAppTemplate> listHardwareProfiles(); @Override Iterable<VAppTemplate> listImages(); @Override Iterable<VApp> listNodes(); @Override Iterable<VApp> listNodesByIds(final Iterable<String> ids); @Override Iterable<Location> listLocations(); @Override VApp getNode(String in); @Override VAppTemplate getImage(String in); @Override void destroyNode(String id); void waitForTask(Task task); @Override void rebootNode(String in); @Override void resumeNode(String in); @Override void suspendNode(String in);  }
@Test public void testListHardwareProfiles() throws Exception { ComputeService compute = requestsSendResponses(ImmutableMap.<HttpRequest, HttpResponse> builder() .put(versionsRequest, versionsResponseFromVCD1_5) .put(version1_0LoginRequest, successfulVersion1_0LoginResponseFromVCD1_5WithSingleOrg) .put(version1_0GetOrgRequest, successfulVersion1_0GetOrgResponseFromVCD1_5WithSingleTasksListVDCAndNetwork) .put(version1_0GetCatalogRequest, successfulVersion1_0GetCatalogResponseFromVCD1_5WithSingleTemplate) .put(version1_0GetCatalogItemRequest, successfulVersion1_0GetCatalogItemResponseFromVCD1_5ForTemplate) .put(version1_0GetVDCRequest, successfulVersion1_0GetVDCResponseFromVCD1_5WithSingleTemplateAndNetwork) .put(version1_0GetVAppTemplateRequest, successfulVersion1_0GetVAppTemplateResponseFromVCD1_5WithSingleVMAndVDCParent) .put(version1_0GetOVFForVAppTemplateRequest, successfulVersion1_0GetOVFForVAppTemplateResponseFromVCD1_5WithSingleVM) .build()); VCloudComputeServiceAdapter adapter = compute.getContext() .utils().injector().getInstance(VCloudComputeServiceAdapter.class); Iterable<VAppTemplate> hardwareProfiles = adapter.listHardwareProfiles(); Iterable<URI> hardwareProfileRefs = Iterables.transform(ImmutableList.copyOf(hardwareProfiles), new Function<VAppTemplate,URI>() { @Override public URI apply(VAppTemplate input) { return input.getHref(); } }); assertEquals(ImmutableSet.copyOf(hardwareProfileRefs), ImmutableSet.of(URI.create("https: }
@Test public void testListHardwareProfilesWithUnsupportedTemplate() throws Exception { ComputeService compute = requestsSendResponses(ImmutableMap.<HttpRequest, HttpResponse> builder() .put(versionsRequest, versionsResponseFromVCD1_5) .put(version1_0LoginRequest, successfulVersion1_0LoginResponseFromVCD1_5WithSingleOrg) .put(version1_0GetOrgRequest, successfulVersion1_0GetOrgResponseFromVCD1_5WithSingleTasksListVDCAndNetwork) .put(version1_0GetCatalogRequest, successfulVersion1_0GetCatalogResponseFromVCD1_5WithSingleTemplate) .put(version1_0GetCatalogItemRequest, successfulVersion1_0GetCatalogItemResponseFromVCD1_5ForTemplate) .put(version1_0GetVDCRequest, successfulVersion1_0GetVDCResponseFromVCD1_5WithSingleTemplateAndNetwork) .put(version1_0GetVAppTemplateRequest, successfulVersion1_0GetVAppTemplateResponseFromVCD1_5WithMultipleVMsAndVDCParent) .put(version1_0GetOVFForVAppTemplateRequest, successfulVersion1_0GetOVFForVAppTemplateResponseFromVCD1_5WithMultipleVMs) .build()); VCloudComputeServiceAdapter adapter = compute.getContext() .utils().injector().getInstance(VCloudComputeServiceAdapter.class); Iterable<VAppTemplate> hardwareProfiles = adapter.listHardwareProfiles(); assertEquals(ImmutableSet.copyOf(hardwareProfiles), ImmutableSet.of()); }