From a4272f5429ab09724e07f6adc47e21f244421c6c Mon Sep 17 00:00:00 2001 From: danikov Date: Wed, 21 Mar 2012 12:32:50 +0000 Subject: [PATCH] tidy up test annotations + documentation + missing client/test methods for groupClient --- .../v1_5/features/GroupAsyncClient.java | 11 ++ .../director/v1_5/features/GroupClient.java | 12 ++ .../v1_5/features/VAppTemplateClient.java | 169 +++++++++++++++--- .../features/AbstractVAppClientLiveTest.java | 4 - .../v1_5/features/AdminOrgClientLiveTest.java | 4 +- .../v1_5/features/AdminVdcClientLiveTest.java | 8 +- .../v1_5/features/GroupClientLiveTest.java | 21 +-- .../v1_5/features/NetworkClientLiveTest.java | 1 - .../v1_5/features/TaskClientLiveTest.java | 2 +- .../v1_5/features/UserClientLiveTest.java | 91 +++++----- .../features/VAppTemplateClientLiveTest.java | 53 +++--- .../v1_5/features/VdcClientLiveTest.java | 6 +- 12 files changed, 259 insertions(+), 123 deletions(-) diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/GroupAsyncClient.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/GroupAsyncClient.java index e2d772fba3..77393fb11b 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/GroupAsyncClient.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/GroupAsyncClient.java @@ -23,7 +23,9 @@ import java.net.URI; import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; import javax.ws.rs.GET; +import javax.ws.rs.POST; import javax.ws.rs.PUT; +import javax.ws.rs.Path; import javax.ws.rs.Produces; import org.jclouds.rest.annotations.BinderParam; @@ -45,6 +47,15 @@ import com.google.common.util.concurrent.ListenableFuture; */ @RequestFilters(AddVCloudAuthorizationToRequest.class) public interface GroupAsyncClient { + + @POST + @Path("/groups") + @Consumes(VCloudDirectorMediaType.GROUP) + @Produces(VCloudDirectorMediaType.GROUP) + @JAXBResponseParser + @ExceptionParser(ThrowVCloudErrorOn4xx.class) + ListenableFuture createGroup(@EndpointParam URI adminOrgUri, + @BinderParam(BindToXMLPayload.class) Group group); /** * @see GroupClient#getGroup(URI) diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/GroupClient.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/GroupClient.java index faf2cfcf51..b28ee34dfd 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/GroupClient.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/GroupClient.java @@ -33,6 +33,18 @@ import org.jclouds.vcloud.director.v1_5.domain.Group; @Timeout(duration = 180, timeUnit = TimeUnit.SECONDS) public interface GroupClient { + /** + * Imports a group in an organization. + * + *
+    * POST /admin/org/{id}/groups
+    * 
+ * + * @param orgUri the admin org to create the group in + * @return the created group + */ + Group createGroup(URI adminOrgUri, Group group); + /** * Retrieves a group. * diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VAppTemplateClient.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VAppTemplateClient.java index afdabe5164..bf52ddb6ae 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VAppTemplateClient.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VAppTemplateClient.java @@ -27,7 +27,6 @@ import org.jclouds.vcloud.director.v1_5.domain.CustomizationSection; import org.jclouds.vcloud.director.v1_5.domain.GuestCustomizationSection; import org.jclouds.vcloud.director.v1_5.domain.LeaseSettingsSection; import org.jclouds.vcloud.director.v1_5.domain.Metadata; -import org.jclouds.vcloud.director.v1_5.domain.MetadataValue; import org.jclouds.vcloud.director.v1_5.domain.NetworkConfigSection; import org.jclouds.vcloud.director.v1_5.domain.NetworkConnectionSection; import org.jclouds.vcloud.director.v1_5.domain.Owner; @@ -49,6 +48,18 @@ public interface VAppTemplateClient { /** * Retrieves a vApp template (can be used also to retrieve a VM from a vApp Template). + * The vApp could be in one of these statues: FAILED_CREATION(-1) - Transient entity state, + * e.g., model object is created but the corresponding VC backing does not exist yet. This + * is further sub-categorized in the respective entities. UNRESOLVED(0) - Entity is whole, + * e.g., VM creation is complete and all the required model objects and VC backings are created. + * RESOLVED(1) - Entity is resolved. UNKNOWN(6) - Entity state could not be retrieved from + * the inventory, e.g., VM power state is null. POWERED_OFF(8) - All VMs of the vApp template + * are powered off. MIXED(10) - vApp template status is set to MIXED when the VMs in the + * vApp are in different power states. + * + *
+    * GET /vAppTemplate/{id}
+    * 
* * @param templateUri the URI of the template * @return the requested template @@ -58,106 +69,165 @@ public interface VAppTemplateClient { /** * Modifies only the name/description of a vApp template. * + *
+    * PUT /vAppTemplate/{id}
+    * 
+ * * @param templateUri the URI of the template * @param template the template containing the new name and/or description - * @return the task performing the action + * @return the task performing the action. This operation is asynchronous and the user + * should monitor the returned task status in order to check when it is completed. */ Task editVAppTemplate(URI templateUri, VAppTemplate template); /** * Deletes a vApp template. * + *
+    * DELETE /vAppTemplate/{id}
+    * 
+ * * @param templateUri the URI of the template - * @return the task performing the action + * @return the task performing the action. This operation is asynchronous and the user + * should monitor the returned task status in order to check when it is completed. */ Task deleteVappTemplate(URI templateUri); /** * Consolidates a VM * + *
+    * POST /vAppTemplate/{id}/action/consolidate
+    * 
+ * * @param templateUri the URI of the template - * @return the task performing the action + * @return the task performing the action. This operation is asynchronous and the user + * should monitor the returned task status in order to check when it is completed. */ Task consolidateVappTemplate(URI templateUri); /** * Disables the download link to the ovf of a vApp template. * + *
+    * POST /vAppTemplate/{id}/action/disableDownload
+    * 
+ * * @param templateUri the URI of the template - * @return the task performing the action */ void disableDownloadVappTemplate(URI templateUri); /** * Enables downloading of the ovf of a vApp template. * + *
+    * POST /vAppTemplate/{id}/action/enableDownload
+    * 
+ * * @param templateUri the URI of the template - * @return the task performing the action + * @return the task performing the action. This operation is asynchronous and the user + * should monitor the returned task status in order to check when it is completed. */ Task enableDownloadVappTemplate(URI templateUri); /** - * Relocates a virtual machine in a vApp template to a different datastore. * + * Relocates a virtual machine in a vApp template to a different datastore. + * + *
+    * POST /vAppTemplate/{id}/action/relocate
+    * 
* * @param templateUri the URI of the template * @param params contains the reference to the new datastore - * @return the task performing the action + * @return the task performing the action. This operation is asynchronous and the user + * should monitor the returned task status in order to check when it is completed. */ Task relocateVappTemplate(URI templateUri, RelocateParams params); /** * Retrieves the customization section of a vApp template. * + *
+    * GET /vAppTemplate/{id}/customizationSection
+    * 
+ * * @param templateUri the URI of the template - * @return the task performing the action + * @return the customization section */ CustomizationSection getVAppTemplateCustomizationSection(URI templateUri); /** * Modifies the vApp template customization information. * + *
+    * PUT /vAppTemplate/{id}/customizationSection
+    * 
+ * * @param templateUri the URI of the template * @param section the new configuration to apply - * @return the task performing the action + * @return the task performing the action. This operation is asynchronous and the user + * should monitor the returned task status in order to check when it is completed. */ Task editVAppTemplateCustomizationSection(URI templateUri, CustomizationSection section); /** * Retrieves the Guest Customization Section of a VM * + *
+    * GET /vAppTemplate/{id}/guestCustomizationSection
+    * 
+ * * @param templateUri the URI of the template - * @return the task performing the action + * @return the guest customization section */ GuestCustomizationSection getVAppTemplateGuestCustomizationSection(URI templateUri); /** - * Consolidates a VM + * Modifies the guest customization options of a VM. + * + *
+    * PUT /vAppTemplate/{id}/guestCustomizationSection
+    * 
* * @param templateUri the URI of the template * @param section the new configuration to apply - * @return the task performing the action + * @return the task performing the action. This operation is asynchronous and the user + * should monitor the returned task status in order to check when it is completed. */ Task editVAppTemplateGuestCustomizationSection(URI templateUri, GuestCustomizationSection section); /** - * Consolidates a VM + * Retrieves the lease settings section of a vApp or vApp template + * + *
+    * GET /vAppTemplate/{id}/leaseSettingsSection
+    * 
* * @param templateUri the URI of the template - * @return the task performing the action + * @return the lease settings */ LeaseSettingsSection getVappTemplateLeaseSettingsSection(URI templateUri); /** - * Consolidates a VM + * Modifies the lease settings section of a vApp or vApp template. + * + *
+    * PUT /vAppTemplate/{id}/leaseSettingsSection
+    * 
* * @param templateUri the URI of the template * @param section the new configuration to apply - * @return the task performing the action + * @return the task performing the action. This operation is asynchronous and the user + * should monitor the returned task status in order to check when it is completed. */ Task editVappTemplateLeaseSettingsSection(URI templateUri, LeaseSettingsSection section); /** * Retrieves the network config section of a vApp or vApp template. + * + *
+    * GET /vAppTemplate/{id}/networkConfigSection
+    * 
* * @param templateUri the URI of the template * @return the network config section requested @@ -165,16 +235,35 @@ public interface VAppTemplateClient { NetworkConfigSection getVAppTemplateNetworkConfigSection(URI templateUri); /** - * Modifies the network config section of a vApp or vApp template. + * Modifies the network config section of a vApp. There are three general types of vApp + * networks which could be configured from this section. They are specified by the element + * value in /. isolated - this is a vApp network which is not connected to any external + * organization network and is used only to connect VMs internally in a vApp. In this + * network you could configure only its element of /. bridged - this is a vApp network + * which is directly connected to an external organization network. In this network you + * should configure only the element of /. In this case the element is inherit from the + * parent network. natRouted - this is a vApp network which is NAT routed to an external + * organization network. In this network you could configure the and also you should + * specify and the element of /. When the network is NAT routed you could specify DHCP, + * firewall rules and NAT rules, for fine-grained configuration of your network. + * + *
+    * PUT /vAppTemplate/{id}/networkConfigSection
+    * 
* * @param templateUri the URI of the template * @param section the new configuration to apply - * @return the task performing the action + * @return the task performing the action. This operation is asynchronous and the user + * should monitor the returned task status in order to check when it is completed. */ Task editVAppTemplateNetworkConfigSection(URI templateUri, NetworkConfigSection section); /** - * Retrieves the network connection section of a vApp or vApp template. + * Retrieves the network connection section of a VM + * + *
+    * GET /vAppTemplate/{id}/networkConnectionSection
+    * 
* * @param templateUri the URI of the template * @return the network connection section requested @@ -182,33 +271,54 @@ public interface VAppTemplateClient { NetworkConnectionSection getVAppTemplateNetworkConnectionSection(URI templateUri); /** - * Modifies the network connection section of a vApp or vApp template. + * Modifies the network connection section of a VM. + * + *
+    * PUT /vAppTemplate/{id}/networkConnectionSection
+    * 
* * @param templateUri the URI of the template * @param section the new configuration to apply - * @return the task performing the action + * @return the task performing the action. This operation is asynchronous and the user + * should monitor the returned task status in order to check when it is completed. */ Task editVAppTemplateNetworkConnectionSection(URI templateUri, NetworkConnectionSection section); /** * Retrieves the network section of a vApp or vApp template. * + *
+    * GET /vAppTemplate/{id}/networkSection
+    * 
+ * * @param templateUri the URI of the template * @return the network section requested */ NetworkSection getVAppTemplateNetworkSection(URI templateUri); /** - * Retrieves an OVF descriptor of a vApp template. + * Retrieves an OVF descriptor of a vApp template. This OVF represents the vApp + * template as it is, with all vCloud specific information (like mac address, + * parent networks, etc). The OVF which could be downloaded by enabling for + * download will not contain this information. There no specific states bound + * to this entity. + * + *
+    * GET /vAppTemplate/{id}/ovf
+    * 
* * @param templateUri the URI of the template - * @return the task performing the action + * @return the ovf envelope */ Envelope getVAppTemplateOvf(URI templateUri); /** * Retrieves vApp template owner. * + *
+    * GET /vAppTemplate/{id}/owner
+    * 
+ * * @param templateUri the URI of the template * @return the owner of the vApp template */ @@ -217,6 +327,10 @@ public interface VAppTemplateClient { /** * Retrieves VAppTemplate/VM product sections * + *
+    * GET /vAppTemplate/{id}/productSections
+    * 
+ * * @param templateUri the URI of the template * @return the product sections */ @@ -225,8 +339,13 @@ public interface VAppTemplateClient { /** * Modifies the product sections of a vApp or vApp template. * + *
+    * PUT /vAppTemplate/{id}/productSections
+    * 
+ * * @param templateUri the URI of the template - * @return the task performing the action + * @return the task performing the action. This operation is asynchronous and the user + * should monitor the returned task status in order to check when it is completed. */ Task editProductSectionsForVAppTemplate(URI templateUri, ProductSectionList sections); diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/AbstractVAppClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/AbstractVAppClientLiveTest.java index 7aef9d685b..b450bafffd 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/AbstractVAppClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/AbstractVAppClientLiveTest.java @@ -31,10 +31,7 @@ import java.io.IOException; import java.math.BigInteger; import java.net.URI; import java.util.List; -import java.util.Random; -import java.util.Set; -import org.jclouds.vcloud.director.v1_5.VCloudDirectorException; import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType; import org.jclouds.vcloud.director.v1_5.domain.GuestCustomizationSection; import org.jclouds.vcloud.director.v1_5.domain.NetworkConnectionSection; @@ -64,7 +61,6 @@ import com.google.common.base.Predicates; import com.google.common.base.Strings; import com.google.common.base.Throwables; import com.google.common.collect.Iterables; -import com.google.common.collect.Sets; /** * Shared code to test the behaviour of {@link VAppClient} and {@link VAppTemplateClient}. diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/AdminOrgClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/AdminOrgClientLiveTest.java index 4b6d25d941..68a40bcf2c 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/AdminOrgClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/AdminOrgClientLiveTest.java @@ -369,14 +369,14 @@ public class AdminOrgClientLiveTest extends BaseVCloudDirectorClientLiveTest { } } - @Test(testName = "GET /admin/org/{id}/settings/settings") + @Test(testName = "GET /admin/org/{id}/settings") public void testGetSettings() { settings = orgClient.getSettings(orgRef.getHref()); Checks.checkOrgSettings(settings); } - @Test(testName = "PUT /admin/org/{id}/settings/settings", + @Test(testName = "PUT /admin/org/{id}/settings", dependsOnMethods = { "testGetEmailSettings" } ) public void testUpdateSettings() throws Exception { String newFromEmailAddress = "test"+random.nextInt(Integer.MAX_VALUE)+"@test.com"; diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/AdminVdcClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/AdminVdcClientLiveTest.java index cdc9e68426..5b967def7d 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/AdminVdcClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/AdminVdcClientLiveTest.java @@ -165,7 +165,7 @@ public class AdminVdcClientLiveTest extends BaseVCloudDirectorClientLiveTest { } } - @Test(testName = "PUT /admin/vdc/{id}/metadata") + @Test(testName = "GET /admin/vdc/{id}/metadata") public void testGetMetadata() throws Exception { Metadata metadata = metadataClient.getMetadata(adminVdcUri); @@ -190,7 +190,7 @@ public class AdminVdcClientLiveTest extends BaseVCloudDirectorClientLiveTest { } // TODO insufficient permissions to test - @Test(testName = "PUT /admin/vdc/{id}/metadata", dependsOnMethods = { "testSetMetadata" }, enabled=false) + @Test(testName = "GET /admin/vdc/{id}/metadata/{key}", dependsOnMethods = { "testSetMetadata" }, enabled=false) public void testGetMetadataValue() throws Exception { MetadataValue retrievedMetadataValue = metadataClient.getMetadataValue(adminVdcUri, metadataKey); @@ -198,7 +198,7 @@ public class AdminVdcClientLiveTest extends BaseVCloudDirectorClientLiveTest { } // TODO insufficient permissions to test - @Test(testName = "PUT /admin/vdc/{id}/metadata", dependsOnMethods = { "testGetMetadataValue" }, enabled=false ) + @Test(testName = "PUT /admin/vdc/{id}/metadata/{key}", dependsOnMethods = { "testGetMetadataValue" }, enabled=false ) public void testSetMetadataValue() throws Exception { metadataValue = name("value-"); MetadataValue newV = MetadataValue.builder().value(metadataValue).build(); @@ -211,7 +211,7 @@ public class AdminVdcClientLiveTest extends BaseVCloudDirectorClientLiveTest { } // TODO insufficient permissions to test - @Test(testName = "PUT /admin/vdc/{id}/metadata", dependsOnMethods = { "testSetMetadataValue" }, enabled=false ) + @Test(testName = "DELETE /admin/vdc/{id}/metadata/{key}", dependsOnMethods = { "testSetMetadataValue" }, enabled=false ) public void testDeleteMetadataValue() throws Exception { // TODO Remove dependency on other tests; make cleanUp delete a list of metadata entries? diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/GroupClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/GroupClientLiveTest.java index d12b56f1e3..caa7495d62 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/GroupClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/GroupClientLiveTest.java @@ -20,13 +20,9 @@ package org.jclouds.vcloud.director.v1_5.features; import static com.google.common.base.Objects.equal; import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_FIELD_UPDATABLE; -import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.REF_REQ_LIVE; -import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertTrue; import static org.testng.Assert.fail; -import java.net.URI; - import org.jclouds.vcloud.director.v1_5.VCloudDirectorException; import org.jclouds.vcloud.director.v1_5.domain.Checks; import org.jclouds.vcloud.director.v1_5.domain.Group; @@ -61,14 +57,19 @@ public class GroupClientLiveTest extends BaseVCloudDirectorClientLiveTest { @BeforeClass(inheritGroups = true) public void setupRequiredClients() { groupClient = context.getApi().getGroupClient(); - groupRef = Reference.builder() - .href(URI.create("https://vcloudbeta.bluelock.com/api/admin/group/???")) - .build(); } - @Test(testName = "GET /admin/group/{id}") + @Test(testName = "POST /admin/org/{id}/groups") + public void testCreateGroup() { + fail("LDAP not configured, group client isn't currently testable."); +// group = groupClient.createGroup(orgUri, Group.builder() +// .build(); + + Checks.checkGroup(group); + } + + @Test(testName = "GET /admin/group/{id}", dependsOnMethods = { "testCreateGroup" }) public void testGetGroup() { - assertNotNull(groupRef, String.format(REF_REQ_LIVE, "Group")); group = groupClient.getGroup(groupRef.getHref()); Checks.checkGroup(group); @@ -108,7 +109,7 @@ public class GroupClientLiveTest extends BaseVCloudDirectorClientLiveTest { } @Test(testName = "DELETE /admin/group/{id}", dependsOnMethods = { "testUpdateGroup" } ) - public void testDeleteCatalog() { + public void testDeleteGroup() { groupClient.deleteGroup(groupRef.getHref()); // TODO stronger assertion of error expected diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/NetworkClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/NetworkClientLiveTest.java index 8fb1e38057..1b14bb18f1 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/NetworkClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/NetworkClientLiveTest.java @@ -36,7 +36,6 @@ import org.jclouds.vcloud.director.v1_5.domain.MetadataEntry; import org.jclouds.vcloud.director.v1_5.domain.MetadataValue; import org.jclouds.vcloud.director.v1_5.domain.Network; import org.jclouds.vcloud.director.v1_5.domain.OrgNetwork; -import org.jclouds.vcloud.director.v1_5.domain.Reference; import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorClientLiveTest; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/TaskClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/TaskClientLiveTest.java index 4ae3c61881..504baf3079 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/TaskClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/TaskClientLiveTest.java @@ -113,7 +113,7 @@ public class TaskClientLiveTest extends BaseVCloudDirectorClientLiveTest { // FIXME cancelTask complains "This task can not be canceled" // However, when I do this through the UI, I can cancel the task for instantiating a vApp. - @Test(testName = "GET /task/{id}/metadata/", dependsOnMethods = { "testGetTask" }) + @Test(testName = "POST /task/{id}/action/cancel", dependsOnMethods = { "testGetTask" }) public void testCancelTask() { vApp = instantiateVApp(); diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/UserClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/UserClientLiveTest.java index 2f35d9128d..3e46f80587 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/UserClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/UserClientLiveTest.java @@ -41,9 +41,6 @@ import org.jclouds.vcloud.director.v1_5.domain.Reference; import org.jclouds.vcloud.director.v1_5.domain.RoleReferences; import org.jclouds.vcloud.director.v1_5.domain.SessionWithToken; import org.jclouds.vcloud.director.v1_5.domain.User; -import org.jclouds.vcloud.director.v1_5.domain.query.QueryResultRecordType; -import org.jclouds.vcloud.director.v1_5.domain.query.QueryResultRecords; -import org.jclouds.vcloud.director.v1_5.domain.query.QueryResultRoleRecord; import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorClientLiveTest; import org.jclouds.vcloud.director.v1_5.login.SessionClient; import org.testng.annotations.AfterClass; @@ -99,50 +96,6 @@ public class UserClientLiveTest extends BaseVCloudDirectorClientLiveTest { Checks.checkUser(newUser); } - public static Reference vAppUserRole(RestContext context) { - RoleReferences roles = context.getApi().getAdminQueryClient().roleReferencesQueryAll(); - for (Reference role : roles.getReferences()) { - if (equal(role.getName(), "vApp User")) { - return Reference.builder().fromReference(role).build(); - } - } - - return null; - } - - public static Reference nonVAppUserRole(RestContext context) { - RoleReferences roles = context.getApi().getAdminQueryClient().roleReferencesQueryAll(); - for (Reference role : roles.getReferences()) { - if (!equal(role.getName(), "vApp User")) { - return Reference.builder().fromReference(role).build(); - } - } - - return null; - } - - public static User randomTestUser(String prefix, RestContext context) { - return randomTestUser(prefix, vAppUserRole(context)); - } - - public static User randomTestUser(String prefix, Reference role) { - return User.builder() - .name(name(prefix)) - .fullName("testFullName") - .emailAddress("test@test.com") - .telephone("555-1234") - .isEnabled(false) - .im("testIM") - .isAlertEnabled(false) - .alertEmailPrefix("testPrefix") - .alertEmail("testAlert@test.com") - .isExternal(false) - .isGroupRole(false) - .role(role) - .password("password") - .build(); - } - @Test(testName = "GET /admin/user/{id}", dependsOnMethods = { "testCreateUser" }) public void testGetUser() { @@ -296,4 +249,48 @@ public class UserClientLiveTest extends BaseVCloudDirectorClientLiveTest { assertEquals(vde.getError(), expected); } } + + public static Reference vAppUserRole(RestContext context) { + RoleReferences roles = context.getApi().getAdminQueryClient().roleReferencesQueryAll(); + for (Reference role : roles.getReferences()) { + if (equal(role.getName(), "vApp User")) { + return Reference.builder().fromReference(role).build(); + } + } + + return null; + } + + public static Reference nonVAppUserRole(RestContext context) { + RoleReferences roles = context.getApi().getAdminQueryClient().roleReferencesQueryAll(); + for (Reference role : roles.getReferences()) { + if (!equal(role.getName(), "vApp User")) { + return Reference.builder().fromReference(role).build(); + } + } + + return null; + } + + public static User randomTestUser(String prefix, RestContext context) { + return randomTestUser(prefix, vAppUserRole(context)); + } + + public static User randomTestUser(String prefix, Reference role) { + return User.builder() + .name(name(prefix)+random.nextInt(999999)) + .fullName("testFullName") + .emailAddress("test@test.com") + .telephone("555-1234") + .isEnabled(false) + .im("testIM") + .isAlertEnabled(false) + .alertEmailPrefix("testPrefix") + .alertEmail("testAlert@test.com") + .isExternal(false) + .isGroupRole(false) + .role(role) + .password("password") + .build(); + } } diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppTemplateClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppTemplateClientLiveTest.java index e37d158bee..3e1c83aec3 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppTemplateClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppTemplateClientLiveTest.java @@ -92,7 +92,7 @@ public class VAppTemplateClientLiveTest extends AbstractVAppClientLiveTest { return clonedVappTemplate; } - @Test + @Test(testName = "GET /vAppTemplate/{id}") public void testGetVAppTemplate() { vAppTemplate = vAppTemplateClient.getVAppTemplate(vAppTemplateURI); @@ -100,7 +100,7 @@ public class VAppTemplateClientLiveTest extends AbstractVAppClientLiveTest { assertEquals(vAppTemplate.getHref(), vAppTemplateURI); } - @Test + @Test(testName = "GET /vAppTemplate/{id}/owner") public void testGetVAppTemplateOwner() { Owner owner = vAppTemplateClient.getOwnerOfVAppTemplate(vAppTemplateURI); @@ -108,21 +108,21 @@ public class VAppTemplateClientLiveTest extends AbstractVAppClientLiveTest { assertEquals(owner.getUser(), vAppTemplateClient.getVAppTemplate(vAppTemplateURI).getOwner().getUser()); } - @Test + @Test(testName = "GET /vAppTemplate/{id}/customizationSection") public void testGetCustomizationSection() { CustomizationSection customizationSection = vAppTemplateClient.getVAppTemplateCustomizationSection(vAppTemplateURI); checkCustomizationSection(customizationSection); } - @Test + @Test(testName = "GET /vAppTemplate/{id}/productSections") public void testGetProductSections() { ProductSectionList productSectionList = vAppTemplateClient.getProductSectionsForVAppTemplate(vAppTemplateURI); checkProductSectionList(productSectionList); } - @Test + @Test(testName = "PUT /vAppTemplate/{id}/productSections") public void testEditProductSections() { // TODO make a real modification @@ -146,7 +146,7 @@ public class VAppTemplateClientLiveTest extends AbstractVAppClientLiveTest { }); } - @Test + @Test(testName = "GET /vAppTemplate/{id}/leaseSettingsSection") public void testGetLeaseSettingsSection() { // FIXME Wrong case for Vapp LeaseSettingsSection leaseSettingsSection = vAppTemplateClient.getVappTemplateLeaseSettingsSection(vAppTemplateURI); @@ -154,14 +154,15 @@ public class VAppTemplateClientLiveTest extends AbstractVAppClientLiveTest { checkLeaseSettingsSection(leaseSettingsSection); } - @Test + @Test(testName = "GET /vAppTemplate/{id}/metadata") public void testGetVAppTemplateMetadata() { Metadata metadata = vAppTemplateClient.getMetadataClient().getMetadata(vAppTemplateURI); checkMetadata(metadata); } - @Test // implicitly tested by testEditVAppTemplateMetadataValue, which first creates the metadata entry; otherwise no entry may exist + // implicitly tested by testEditVAppTemplateMetadataValue, which first creates the metadata entry; otherwise no entry may exist + @Test(testName = "GET /vAppTemplate/{id}/metadata/{key}") public void testGetMetadataValue() { Metadata metadata = vAppTemplateClient.getMetadataClient().getMetadata(vAppTemplateURI); MetadataEntry entry = Iterables.get(metadata.getMetadataEntries(), 0); @@ -172,7 +173,7 @@ public class VAppTemplateClientLiveTest extends AbstractVAppClientLiveTest { assertEquals(val.getValue(), entry.getValue()); } - @Test + @Test(testName = "GET /vAppTemplate/{id}/networkConfigSection") public void testGetVAppTemplateNetworkConfigSection() { NetworkConfigSection networkConfigSection = vAppTemplateClient.getVAppTemplateNetworkConfigSection(vAppTemplateURI); @@ -189,21 +190,21 @@ public class VAppTemplateClientLiveTest extends AbstractVAppClientLiveTest { }); } - @Test + @Test(testName = "GET /vAppTemplate/{id}/networkSection") public void testGetVAppTemplateNetworkSection() { NetworkSection networkSection = vAppTemplateClient.getVAppTemplateNetworkSection(vAppTemplateURI); checkOvfNetworkSection(networkSection); } - @Test + @Test(testName = "GET /vAppTemplate/{id}/ovf") public void testGetVAppTemplateOvf() { Envelope envelope = vAppTemplateClient.getVAppTemplateOvf(vAppTemplateURI); checkOvfEnvelope(envelope); } - @Test + @Test(testName = "PUT /vAppTemplate/{id}") public void testEditVAppTemplate() { String name = name("myname-"); String description = name("Description "); @@ -220,7 +221,7 @@ public class VAppTemplateClientLiveTest extends AbstractVAppClientLiveTest { assertEquals(newTemplate.getDescription(), description); } - @Test + @Test(testName = "POST /vAppTemplate/{id}/metadata") public void testEditMetadata() { // TODO Cleanup after ourselves.. @@ -243,7 +244,7 @@ public class VAppTemplateClientLiveTest extends AbstractVAppClientLiveTest { checkMetadataFor("vAppTemplate", newMetadata, expectedMetadataMap); } - @Test + @Test(testName = "PUT /vAppTemplate/{id}/metadata/{key}") public void testEditMetadataValue() { // TODO Cleanup after ourselves.. @@ -258,7 +259,7 @@ public class VAppTemplateClientLiveTest extends AbstractVAppClientLiveTest { assertEquals(newMetadataValue.getValue(), metadataValue.getValue()); } - @Test + @Test(testName = "DELETE /vAppTemplate/{id}/metadata/{key}") public void testDeleteVAppTemplateMetadataValue() { // First store a value String key = name("key-"); @@ -275,7 +276,7 @@ public class VAppTemplateClientLiveTest extends AbstractVAppClientLiveTest { checkMetadataKeyAbsentFor("vAppTemplate", newMetadata, key); } - @Test + @Test(testName = "PUT /vAppTemplate/{id}/guestCustomizationSection") public void testEditGuestCustomizationSection() { String computerName = name("server-"); GuestCustomizationSection newSection = GuestCustomizationSection.builder() @@ -292,7 +293,7 @@ public class VAppTemplateClientLiveTest extends AbstractVAppClientLiveTest { assertEquals(modified.getComputerName(), computerName); } - @Test + @Test(testName = "PUT /vAppTemplate/{id}/customizationSection") public void testEditCustomizationSection() { boolean oldVal = vAppTemplateClient.getVAppTemplateCustomizationSection(vAppTemplateURI).isCustomizeOnInstantiate(); boolean newVal = !oldVal; @@ -310,7 +311,7 @@ public class VAppTemplateClientLiveTest extends AbstractVAppClientLiveTest { } // FIXME deploymentLeaseInSeconds returned is null - @Test + @Test(testName = "PUT /vAppTemplate/{id}/leaseSettingsSection") public void testEditLeaseSettingsSection() throws Exception { int deploymentLeaseInSeconds = random.nextInt(10000)+1; @@ -330,7 +331,7 @@ public class VAppTemplateClientLiveTest extends AbstractVAppClientLiveTest { assertEquals(newLeaseSettingsSection.getDeploymentLeaseInSeconds(), (Integer)deploymentLeaseInSeconds); } - @Test + @Test(testName = "PUT /vAppTemplate/{id}/networkConfigSection") public void testEditNetworkConfigSection() { // TODO What to modify? @@ -363,7 +364,7 @@ public class VAppTemplateClientLiveTest extends AbstractVAppClientLiveTest { // assertEquals(newVAppNetworkConfig.getNetworkName(), networkName); } - @Test + @Test(testName = "PUT /vAppTemplate/{id}/networkConnectionSection") public void testEditNetworkConnectionSection() { // TODO Modify a field so can assert that the change really took effect @@ -378,7 +379,7 @@ public class VAppTemplateClientLiveTest extends AbstractVAppClientLiveTest { checkNetworkConnectionSection(modified); } - @Test // FIXME cloneVAppTemplate is giving back 500 error + @Test(testName = "DELETE /vAppTemplate/{id}") // FIXME cloneVAppTemplate is giving back 500 error public void testDeleteVAppTemplate() throws Exception { VAppTemplate clonedVappTemplate = cloneVAppTemplate(true); @@ -398,7 +399,7 @@ public class VAppTemplateClientLiveTest extends AbstractVAppClientLiveTest { } } - @Test + @Test(testName = "POST /vAppTemplate/{id}/action/disableDownload") public void testDisableVAppTemplateDownload() throws Exception { vAppTemplateClient.disableDownloadVappTemplate(vAppTemplateURI); @@ -412,7 +413,7 @@ public class VAppTemplateClientLiveTest extends AbstractVAppClientLiveTest { // assertFalse(hasLinkMatchingRel(links, "download.*"), "Should not offer download link after disabling download: "+vAppTemplate); } - @Test + @Test(testName = "POST /vAppTemplate/{id}/action/enableDownload") public void testEnableVAppTemplateDownload() throws Exception { // First disable so that enable really has some work to do... vAppTemplateClient.disableDownloadVappTemplate(vAppTemplateURI); @@ -439,7 +440,7 @@ public class VAppTemplateClientLiveTest extends AbstractVAppClientLiveTest { return false; } - @Test + @Test(testName = "POST /vAppTemplate/{id}/action/consolidate") public void testConsolidateVAppTemplate() throws Exception { // TODO Need assertion that command had effect @@ -448,7 +449,7 @@ public class VAppTemplateClientLiveTest extends AbstractVAppClientLiveTest { assertTaskSucceedsLong(task); } - @Test // FIXME Need a datastore reference + @Test(testName = "POST /vAppTemplate/{id}/action/relocate") // FIXME Need a datastore reference public void testRelocateVAppTemplate() throws Exception { // TODO Need assertion that command had effect Reference dataStore = null; // FIXME @@ -462,7 +463,7 @@ public class VAppTemplateClientLiveTest extends AbstractVAppClientLiveTest { // This failed previously, but is passing now. // However, it's not part of the official API so not necessary to assert it. - @Test + @Test(testName = "test completed task not included in vAppTemplate") public void testCompletedTaskNotIncludedInVAppTemplate() throws Exception { // Kick off a task, and wait for it to complete vAppTemplateClient.disableDownloadVappTemplate(vAppTemplateURI); diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientLiveTest.java index 9ba914af1c..03acd6904b 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientLiveTest.java @@ -307,13 +307,13 @@ public class VdcClientLiveTest extends BaseVCloudDirectorClientLiveTest { } - @Test(dependsOnMethods = { "testGetVdc" } ) + @Test(testName = "admin metadata configuration", dependsOnMethods = { "testGetVdc" } ) public void testSetupMetadata() { context.getApi().getAdminVdcClient().getMetadataClient().setMetadata(toAdminUri(vdcURI), "key", MetadataValue.builder().value("value").build()); } - @Test(testName = "GET /network/{id}/metadata", dependsOnMethods = { "testSetupMetadata" } ) + @Test(testName = "GET /vdc/{id}/metadata", dependsOnMethods = { "testSetupMetadata" } ) public void testGetMetadata() { Metadata metadata = vdcClient.getMetadataClient().getMetadata(vdcURI); @@ -324,7 +324,7 @@ public class VdcClientLiveTest extends BaseVCloudDirectorClientLiveTest { Checks.checkMetadataFor(VDC, metadata); } - @Test(testName = "GET /network/{id}/metadata/{key}", dependsOnMethods = { "testGetMetadata" } ) + @Test(testName = "GET /vdc/{id}/metadata/{key}", dependsOnMethods = { "testGetMetadata" } ) public void testGetMetadataValue() { // First find a key Metadata metadata = vdcClient.getMetadataClient().getMetadata(vdcURI);