tidy up test annotations + documentation + missing client/test methods for groupClient

This commit is contained in:
danikov 2012-03-21 12:32:50 +00:00
parent 0ad836dedd
commit a4272f5429
12 changed files with 259 additions and 123 deletions

View File

@ -23,7 +23,9 @@ import java.net.URI;
import javax.ws.rs.Consumes; import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE; import javax.ws.rs.DELETE;
import javax.ws.rs.GET; import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT; import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.Produces; import javax.ws.rs.Produces;
import org.jclouds.rest.annotations.BinderParam; import org.jclouds.rest.annotations.BinderParam;
@ -46,6 +48,15 @@ import com.google.common.util.concurrent.ListenableFuture;
@RequestFilters(AddVCloudAuthorizationToRequest.class) @RequestFilters(AddVCloudAuthorizationToRequest.class)
public interface GroupAsyncClient { public interface GroupAsyncClient {
@POST
@Path("/groups")
@Consumes(VCloudDirectorMediaType.GROUP)
@Produces(VCloudDirectorMediaType.GROUP)
@JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<Group> createGroup(@EndpointParam URI adminOrgUri,
@BinderParam(BindToXMLPayload.class) Group group);
/** /**
* @see GroupClient#getGroup(URI) * @see GroupClient#getGroup(URI)
*/ */

View File

@ -33,6 +33,18 @@ import org.jclouds.vcloud.director.v1_5.domain.Group;
@Timeout(duration = 180, timeUnit = TimeUnit.SECONDS) @Timeout(duration = 180, timeUnit = TimeUnit.SECONDS)
public interface GroupClient { public interface GroupClient {
/**
* Imports a group in an organization.
*
* <pre>
* POST /admin/org/{id}/groups
* </pre>
*
* @param orgUri the admin org to create the group in
* @return the created group
*/
Group createGroup(URI adminOrgUri, Group group);
/** /**
* Retrieves a group. * Retrieves a group.
* *

View File

@ -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.GuestCustomizationSection;
import org.jclouds.vcloud.director.v1_5.domain.LeaseSettingsSection; 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.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.NetworkConfigSection;
import org.jclouds.vcloud.director.v1_5.domain.NetworkConnectionSection; import org.jclouds.vcloud.director.v1_5.domain.NetworkConnectionSection;
import org.jclouds.vcloud.director.v1_5.domain.Owner; 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). * 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.
*
* <pre>
* GET /vAppTemplate/{id}
* </pre>
* *
* @param templateUri the URI of the template * @param templateUri the URI of the template
* @return the requested template * @return the requested template
@ -58,123 +69,201 @@ public interface VAppTemplateClient {
/** /**
* Modifies only the name/description of a vApp template. * Modifies only the name/description of a vApp template.
* *
* <pre>
* PUT /vAppTemplate/{id}
* </pre>
*
* @param templateUri the URI of the template * @param templateUri the URI of the template
* @param template the template containing the new name and/or description * @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); Task editVAppTemplate(URI templateUri, VAppTemplate template);
/** /**
* Deletes a vApp template. * Deletes a vApp template.
* *
* <pre>
* DELETE /vAppTemplate/{id}
* </pre>
*
* @param templateUri the URI of the template * @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); Task deleteVappTemplate(URI templateUri);
/** /**
* Consolidates a VM * Consolidates a VM
* *
* <pre>
* POST /vAppTemplate/{id}/action/consolidate
* </pre>
*
* @param templateUri the URI of the template * @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); Task consolidateVappTemplate(URI templateUri);
/** /**
* Disables the download link to the ovf of a vApp template. * Disables the download link to the ovf of a vApp template.
* *
* <pre>
* POST /vAppTemplate/{id}/action/disableDownload
* </pre>
*
* @param templateUri the URI of the template * @param templateUri the URI of the template
* @return the task performing the action
*/ */
void disableDownloadVappTemplate(URI templateUri); void disableDownloadVappTemplate(URI templateUri);
/** /**
* Enables downloading of the ovf of a vApp template. * Enables downloading of the ovf of a vApp template.
* *
* <pre>
* POST /vAppTemplate/{id}/action/enableDownload
* </pre>
*
* @param templateUri the URI of the template * @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); 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.
*
* <pre>
* POST /vAppTemplate/{id}/action/relocate
* </pre>
* *
* @param templateUri the URI of the template * @param templateUri the URI of the template
* @param params contains the reference to the new datastore * @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); Task relocateVappTemplate(URI templateUri, RelocateParams params);
/** /**
* Retrieves the customization section of a vApp template. * Retrieves the customization section of a vApp template.
* *
* <pre>
* GET /vAppTemplate/{id}/customizationSection
* </pre>
*
* @param templateUri the URI of the template * @param templateUri the URI of the template
* @return the task performing the action * @return the customization section
*/ */
CustomizationSection getVAppTemplateCustomizationSection(URI templateUri); CustomizationSection getVAppTemplateCustomizationSection(URI templateUri);
/** /**
* Modifies the vApp template customization information. * Modifies the vApp template customization information.
* *
* <pre>
* PUT /vAppTemplate/{id}/customizationSection
* </pre>
*
* @param templateUri the URI of the template * @param templateUri the URI of the template
* @param section the new configuration to apply * @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); Task editVAppTemplateCustomizationSection(URI templateUri, CustomizationSection section);
/** /**
* Retrieves the Guest Customization Section of a VM * Retrieves the Guest Customization Section of a VM
* *
* <pre>
* GET /vAppTemplate/{id}/guestCustomizationSection
* </pre>
*
* @param templateUri the URI of the template * @param templateUri the URI of the template
* @return the task performing the action * @return the guest customization section
*/ */
GuestCustomizationSection getVAppTemplateGuestCustomizationSection(URI templateUri); GuestCustomizationSection getVAppTemplateGuestCustomizationSection(URI templateUri);
/** /**
* Consolidates a VM * Modifies the guest customization options of a VM.
*
* <pre>
* PUT /vAppTemplate/{id}/guestCustomizationSection
* </pre>
* *
* @param templateUri the URI of the template * @param templateUri the URI of the template
* @param section the new configuration to apply * @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); Task editVAppTemplateGuestCustomizationSection(URI templateUri, GuestCustomizationSection section);
/** /**
* Consolidates a VM * Retrieves the lease settings section of a vApp or vApp template
*
* <pre>
* GET /vAppTemplate/{id}/leaseSettingsSection
* </pre>
* *
* @param templateUri the URI of the template * @param templateUri the URI of the template
* @return the task performing the action * @return the lease settings
*/ */
LeaseSettingsSection getVappTemplateLeaseSettingsSection(URI templateUri); LeaseSettingsSection getVappTemplateLeaseSettingsSection(URI templateUri);
/** /**
* Consolidates a VM * Modifies the lease settings section of a vApp or vApp template.
*
* <pre>
* PUT /vAppTemplate/{id}/leaseSettingsSection
* </pre>
* *
* @param templateUri the URI of the template * @param templateUri the URI of the template
* @param section the new configuration to apply * @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); Task editVappTemplateLeaseSettingsSection(URI templateUri, LeaseSettingsSection section);
/** /**
* Retrieves the network config section of a vApp or vApp template. * Retrieves the network config section of a vApp or vApp template.
* *
* <pre>
* GET /vAppTemplate/{id}/networkConfigSection
* </pre>
*
* @param templateUri the URI of the template * @param templateUri the URI of the template
* @return the network config section requested * @return the network config section requested
*/ */
NetworkConfigSection getVAppTemplateNetworkConfigSection(URI templateUri); 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.
*
* <pre>
* PUT /vAppTemplate/{id}/networkConfigSection
* </pre>
* *
* @param templateUri the URI of the template * @param templateUri the URI of the template
* @param section the new configuration to apply * @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); 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
*
* <pre>
* GET /vAppTemplate/{id}/networkConnectionSection
* </pre>
* *
* @param templateUri the URI of the template * @param templateUri the URI of the template
* @return the network connection section requested * @return the network connection section requested
@ -182,33 +271,54 @@ public interface VAppTemplateClient {
NetworkConnectionSection getVAppTemplateNetworkConnectionSection(URI templateUri); NetworkConnectionSection getVAppTemplateNetworkConnectionSection(URI templateUri);
/** /**
* Modifies the network connection section of a vApp or vApp template. * Modifies the network connection section of a VM.
*
* <pre>
* PUT /vAppTemplate/{id}/networkConnectionSection
* </pre>
* *
* @param templateUri the URI of the template * @param templateUri the URI of the template
* @param section the new configuration to apply * @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); Task editVAppTemplateNetworkConnectionSection(URI templateUri, NetworkConnectionSection section);
/** /**
* Retrieves the network section of a vApp or vApp template. * Retrieves the network section of a vApp or vApp template.
* *
* <pre>
* GET /vAppTemplate/{id}/networkSection
* </pre>
*
* @param templateUri the URI of the template * @param templateUri the URI of the template
* @return the network section requested * @return the network section requested
*/ */
NetworkSection getVAppTemplateNetworkSection(URI templateUri); 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.
*
* <pre>
* GET /vAppTemplate/{id}/ovf
* </pre>
* *
* @param templateUri the URI of the template * @param templateUri the URI of the template
* @return the task performing the action * @return the ovf envelope
*/ */
Envelope getVAppTemplateOvf(URI templateUri); Envelope getVAppTemplateOvf(URI templateUri);
/** /**
* Retrieves vApp template owner. * Retrieves vApp template owner.
* *
* <pre>
* GET /vAppTemplate/{id}/owner
* </pre>
*
* @param templateUri the URI of the template * @param templateUri the URI of the template
* @return the owner of the vApp template * @return the owner of the vApp template
*/ */
@ -217,6 +327,10 @@ public interface VAppTemplateClient {
/** /**
* Retrieves VAppTemplate/VM product sections * Retrieves VAppTemplate/VM product sections
* *
* <pre>
* GET /vAppTemplate/{id}/productSections
* </pre>
*
* @param templateUri the URI of the template * @param templateUri the URI of the template
* @return the product sections * @return the product sections
*/ */
@ -225,8 +339,13 @@ public interface VAppTemplateClient {
/** /**
* Modifies the product sections of a vApp or vApp template. * Modifies the product sections of a vApp or vApp template.
* *
* <pre>
* PUT /vAppTemplate/{id}/productSections
* </pre>
*
* @param templateUri the URI of the template * @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); Task editProductSectionsForVAppTemplate(URI templateUri, ProductSectionList sections);

View File

@ -31,10 +31,7 @@ import java.io.IOException;
import java.math.BigInteger; import java.math.BigInteger;
import java.net.URI; import java.net.URI;
import java.util.List; 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.VCloudDirectorMediaType;
import org.jclouds.vcloud.director.v1_5.domain.GuestCustomizationSection; import org.jclouds.vcloud.director.v1_5.domain.GuestCustomizationSection;
import org.jclouds.vcloud.director.v1_5.domain.NetworkConnectionSection; 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.Strings;
import com.google.common.base.Throwables; import com.google.common.base.Throwables;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
import com.google.common.collect.Sets;
/** /**
* Shared code to test the behaviour of {@link VAppClient} and {@link VAppTemplateClient}. * Shared code to test the behaviour of {@link VAppClient} and {@link VAppTemplateClient}.

View File

@ -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() { public void testGetSettings() {
settings = orgClient.getSettings(orgRef.getHref()); settings = orgClient.getSettings(orgRef.getHref());
Checks.checkOrgSettings(settings); Checks.checkOrgSettings(settings);
} }
@Test(testName = "PUT /admin/org/{id}/settings/settings", @Test(testName = "PUT /admin/org/{id}/settings",
dependsOnMethods = { "testGetEmailSettings" } ) dependsOnMethods = { "testGetEmailSettings" } )
public void testUpdateSettings() throws Exception { public void testUpdateSettings() throws Exception {
String newFromEmailAddress = "test"+random.nextInt(Integer.MAX_VALUE)+"@test.com"; String newFromEmailAddress = "test"+random.nextInt(Integer.MAX_VALUE)+"@test.com";

View File

@ -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 { public void testGetMetadata() throws Exception {
Metadata metadata = metadataClient.getMetadata(adminVdcUri); Metadata metadata = metadataClient.getMetadata(adminVdcUri);
@ -190,7 +190,7 @@ public class AdminVdcClientLiveTest extends BaseVCloudDirectorClientLiveTest {
} }
// TODO insufficient permissions to test // 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 { public void testGetMetadataValue() throws Exception {
MetadataValue retrievedMetadataValue = metadataClient.getMetadataValue(adminVdcUri, metadataKey); MetadataValue retrievedMetadataValue = metadataClient.getMetadataValue(adminVdcUri, metadataKey);
@ -198,7 +198,7 @@ public class AdminVdcClientLiveTest extends BaseVCloudDirectorClientLiveTest {
} }
// TODO insufficient permissions to test // 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 { public void testSetMetadataValue() throws Exception {
metadataValue = name("value-"); metadataValue = name("value-");
MetadataValue newV = MetadataValue.builder().value(metadataValue).build(); MetadataValue newV = MetadataValue.builder().value(metadataValue).build();
@ -211,7 +211,7 @@ public class AdminVdcClientLiveTest extends BaseVCloudDirectorClientLiveTest {
} }
// TODO insufficient permissions to test // 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 { public void testDeleteMetadataValue() throws Exception {
// TODO Remove dependency on other tests; make cleanUp delete a list of metadata entries? // TODO Remove dependency on other tests; make cleanUp delete a list of metadata entries?

View File

@ -20,13 +20,9 @@ package org.jclouds.vcloud.director.v1_5.features;
import static com.google.common.base.Objects.equal; 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.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.assertTrue;
import static org.testng.Assert.fail; 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.VCloudDirectorException;
import org.jclouds.vcloud.director.v1_5.domain.Checks; import org.jclouds.vcloud.director.v1_5.domain.Checks;
import org.jclouds.vcloud.director.v1_5.domain.Group; import org.jclouds.vcloud.director.v1_5.domain.Group;
@ -61,14 +57,19 @@ public class GroupClientLiveTest extends BaseVCloudDirectorClientLiveTest {
@BeforeClass(inheritGroups = true) @BeforeClass(inheritGroups = true)
public void setupRequiredClients() { public void setupRequiredClients() {
groupClient = context.getApi().getGroupClient(); 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() { public void testGetGroup() {
assertNotNull(groupRef, String.format(REF_REQ_LIVE, "Group"));
group = groupClient.getGroup(groupRef.getHref()); group = groupClient.getGroup(groupRef.getHref());
Checks.checkGroup(group); Checks.checkGroup(group);
@ -108,7 +109,7 @@ public class GroupClientLiveTest extends BaseVCloudDirectorClientLiveTest {
} }
@Test(testName = "DELETE /admin/group/{id}", dependsOnMethods = { "testUpdateGroup" } ) @Test(testName = "DELETE /admin/group/{id}", dependsOnMethods = { "testUpdateGroup" } )
public void testDeleteCatalog() { public void testDeleteGroup() {
groupClient.deleteGroup(groupRef.getHref()); groupClient.deleteGroup(groupRef.getHref());
// TODO stronger assertion of error expected // TODO stronger assertion of error expected

View File

@ -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.MetadataValue;
import org.jclouds.vcloud.director.v1_5.domain.Network; 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.OrgNetwork;
import org.jclouds.vcloud.director.v1_5.domain.Reference;
import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorClientLiveTest; import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorClientLiveTest;
import org.testng.annotations.AfterClass; import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeClass;

View File

@ -113,7 +113,7 @@ public class TaskClientLiveTest extends BaseVCloudDirectorClientLiveTest {
// FIXME cancelTask complains "This task can not be canceled" // 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. // 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() { public void testCancelTask() {
vApp = instantiateVApp(); vApp = instantiateVApp();

View File

@ -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.RoleReferences;
import org.jclouds.vcloud.director.v1_5.domain.SessionWithToken; 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.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.internal.BaseVCloudDirectorClientLiveTest;
import org.jclouds.vcloud.director.v1_5.login.SessionClient; import org.jclouds.vcloud.director.v1_5.login.SessionClient;
import org.testng.annotations.AfterClass; import org.testng.annotations.AfterClass;
@ -99,50 +96,6 @@ public class UserClientLiveTest extends BaseVCloudDirectorClientLiveTest {
Checks.checkUser(newUser); Checks.checkUser(newUser);
} }
public static Reference vAppUserRole(RestContext<VCloudDirectorClient, VCloudDirectorAsyncClient> 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<VCloudDirectorClient, VCloudDirectorAsyncClient> 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<VCloudDirectorClient, VCloudDirectorAsyncClient> 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}", @Test(testName = "GET /admin/user/{id}",
dependsOnMethods = { "testCreateUser" }) dependsOnMethods = { "testCreateUser" })
public void testGetUser() { public void testGetUser() {
@ -296,4 +249,48 @@ public class UserClientLiveTest extends BaseVCloudDirectorClientLiveTest {
assertEquals(vde.getError(), expected); assertEquals(vde.getError(), expected);
} }
} }
public static Reference vAppUserRole(RestContext<VCloudDirectorClient, VCloudDirectorAsyncClient> 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<VCloudDirectorClient, VCloudDirectorAsyncClient> 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<VCloudDirectorClient, VCloudDirectorAsyncClient> 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();
}
} }

View File

@ -92,7 +92,7 @@ public class VAppTemplateClientLiveTest extends AbstractVAppClientLiveTest {
return clonedVappTemplate; return clonedVappTemplate;
} }
@Test @Test(testName = "GET /vAppTemplate/{id}")
public void testGetVAppTemplate() { public void testGetVAppTemplate() {
vAppTemplate = vAppTemplateClient.getVAppTemplate(vAppTemplateURI); vAppTemplate = vAppTemplateClient.getVAppTemplate(vAppTemplateURI);
@ -100,7 +100,7 @@ public class VAppTemplateClientLiveTest extends AbstractVAppClientLiveTest {
assertEquals(vAppTemplate.getHref(), vAppTemplateURI); assertEquals(vAppTemplate.getHref(), vAppTemplateURI);
} }
@Test @Test(testName = "GET /vAppTemplate/{id}/owner")
public void testGetVAppTemplateOwner() { public void testGetVAppTemplateOwner() {
Owner owner = vAppTemplateClient.getOwnerOfVAppTemplate(vAppTemplateURI); Owner owner = vAppTemplateClient.getOwnerOfVAppTemplate(vAppTemplateURI);
@ -108,21 +108,21 @@ public class VAppTemplateClientLiveTest extends AbstractVAppClientLiveTest {
assertEquals(owner.getUser(), vAppTemplateClient.getVAppTemplate(vAppTemplateURI).getOwner().getUser()); assertEquals(owner.getUser(), vAppTemplateClient.getVAppTemplate(vAppTemplateURI).getOwner().getUser());
} }
@Test @Test(testName = "GET /vAppTemplate/{id}/customizationSection")
public void testGetCustomizationSection() { public void testGetCustomizationSection() {
CustomizationSection customizationSection = vAppTemplateClient.getVAppTemplateCustomizationSection(vAppTemplateURI); CustomizationSection customizationSection = vAppTemplateClient.getVAppTemplateCustomizationSection(vAppTemplateURI);
checkCustomizationSection(customizationSection); checkCustomizationSection(customizationSection);
} }
@Test @Test(testName = "GET /vAppTemplate/{id}/productSections")
public void testGetProductSections() { public void testGetProductSections() {
ProductSectionList productSectionList = vAppTemplateClient.getProductSectionsForVAppTemplate(vAppTemplateURI); ProductSectionList productSectionList = vAppTemplateClient.getProductSectionsForVAppTemplate(vAppTemplateURI);
checkProductSectionList(productSectionList); checkProductSectionList(productSectionList);
} }
@Test @Test(testName = "PUT /vAppTemplate/{id}/productSections")
public void testEditProductSections() { public void testEditProductSections() {
// TODO make a real modification // TODO make a real modification
@ -146,7 +146,7 @@ public class VAppTemplateClientLiveTest extends AbstractVAppClientLiveTest {
}); });
} }
@Test @Test(testName = "GET /vAppTemplate/{id}/leaseSettingsSection")
public void testGetLeaseSettingsSection() { public void testGetLeaseSettingsSection() {
// FIXME Wrong case for Vapp // FIXME Wrong case for Vapp
LeaseSettingsSection leaseSettingsSection = vAppTemplateClient.getVappTemplateLeaseSettingsSection(vAppTemplateURI); LeaseSettingsSection leaseSettingsSection = vAppTemplateClient.getVappTemplateLeaseSettingsSection(vAppTemplateURI);
@ -154,14 +154,15 @@ public class VAppTemplateClientLiveTest extends AbstractVAppClientLiveTest {
checkLeaseSettingsSection(leaseSettingsSection); checkLeaseSettingsSection(leaseSettingsSection);
} }
@Test @Test(testName = "GET /vAppTemplate/{id}/metadata")
public void testGetVAppTemplateMetadata() { public void testGetVAppTemplateMetadata() {
Metadata metadata = vAppTemplateClient.getMetadataClient().getMetadata(vAppTemplateURI); Metadata metadata = vAppTemplateClient.getMetadataClient().getMetadata(vAppTemplateURI);
checkMetadata(metadata); 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() { public void testGetMetadataValue() {
Metadata metadata = vAppTemplateClient.getMetadataClient().getMetadata(vAppTemplateURI); Metadata metadata = vAppTemplateClient.getMetadataClient().getMetadata(vAppTemplateURI);
MetadataEntry entry = Iterables.get(metadata.getMetadataEntries(), 0); MetadataEntry entry = Iterables.get(metadata.getMetadataEntries(), 0);
@ -172,7 +173,7 @@ public class VAppTemplateClientLiveTest extends AbstractVAppClientLiveTest {
assertEquals(val.getValue(), entry.getValue()); assertEquals(val.getValue(), entry.getValue());
} }
@Test @Test(testName = "GET /vAppTemplate/{id}/networkConfigSection")
public void testGetVAppTemplateNetworkConfigSection() { public void testGetVAppTemplateNetworkConfigSection() {
NetworkConfigSection networkConfigSection = vAppTemplateClient.getVAppTemplateNetworkConfigSection(vAppTemplateURI); NetworkConfigSection networkConfigSection = vAppTemplateClient.getVAppTemplateNetworkConfigSection(vAppTemplateURI);
@ -189,21 +190,21 @@ public class VAppTemplateClientLiveTest extends AbstractVAppClientLiveTest {
}); });
} }
@Test @Test(testName = "GET /vAppTemplate/{id}/networkSection")
public void testGetVAppTemplateNetworkSection() { public void testGetVAppTemplateNetworkSection() {
NetworkSection networkSection = vAppTemplateClient.getVAppTemplateNetworkSection(vAppTemplateURI); NetworkSection networkSection = vAppTemplateClient.getVAppTemplateNetworkSection(vAppTemplateURI);
checkOvfNetworkSection(networkSection); checkOvfNetworkSection(networkSection);
} }
@Test @Test(testName = "GET /vAppTemplate/{id}/ovf")
public void testGetVAppTemplateOvf() { public void testGetVAppTemplateOvf() {
Envelope envelope = vAppTemplateClient.getVAppTemplateOvf(vAppTemplateURI); Envelope envelope = vAppTemplateClient.getVAppTemplateOvf(vAppTemplateURI);
checkOvfEnvelope(envelope); checkOvfEnvelope(envelope);
} }
@Test @Test(testName = "PUT /vAppTemplate/{id}")
public void testEditVAppTemplate() { public void testEditVAppTemplate() {
String name = name("myname-"); String name = name("myname-");
String description = name("Description "); String description = name("Description ");
@ -220,7 +221,7 @@ public class VAppTemplateClientLiveTest extends AbstractVAppClientLiveTest {
assertEquals(newTemplate.getDescription(), description); assertEquals(newTemplate.getDescription(), description);
} }
@Test @Test(testName = "POST /vAppTemplate/{id}/metadata")
public void testEditMetadata() { public void testEditMetadata() {
// TODO Cleanup after ourselves.. // TODO Cleanup after ourselves..
@ -243,7 +244,7 @@ public class VAppTemplateClientLiveTest extends AbstractVAppClientLiveTest {
checkMetadataFor("vAppTemplate", newMetadata, expectedMetadataMap); checkMetadataFor("vAppTemplate", newMetadata, expectedMetadataMap);
} }
@Test @Test(testName = "PUT /vAppTemplate/{id}/metadata/{key}")
public void testEditMetadataValue() { public void testEditMetadataValue() {
// TODO Cleanup after ourselves.. // TODO Cleanup after ourselves..
@ -258,7 +259,7 @@ public class VAppTemplateClientLiveTest extends AbstractVAppClientLiveTest {
assertEquals(newMetadataValue.getValue(), metadataValue.getValue()); assertEquals(newMetadataValue.getValue(), metadataValue.getValue());
} }
@Test @Test(testName = "DELETE /vAppTemplate/{id}/metadata/{key}")
public void testDeleteVAppTemplateMetadataValue() { public void testDeleteVAppTemplateMetadataValue() {
// First store a value // First store a value
String key = name("key-"); String key = name("key-");
@ -275,7 +276,7 @@ public class VAppTemplateClientLiveTest extends AbstractVAppClientLiveTest {
checkMetadataKeyAbsentFor("vAppTemplate", newMetadata, key); checkMetadataKeyAbsentFor("vAppTemplate", newMetadata, key);
} }
@Test @Test(testName = "PUT /vAppTemplate/{id}/guestCustomizationSection")
public void testEditGuestCustomizationSection() { public void testEditGuestCustomizationSection() {
String computerName = name("server-"); String computerName = name("server-");
GuestCustomizationSection newSection = GuestCustomizationSection.builder() GuestCustomizationSection newSection = GuestCustomizationSection.builder()
@ -292,7 +293,7 @@ public class VAppTemplateClientLiveTest extends AbstractVAppClientLiveTest {
assertEquals(modified.getComputerName(), computerName); assertEquals(modified.getComputerName(), computerName);
} }
@Test @Test(testName = "PUT /vAppTemplate/{id}/customizationSection")
public void testEditCustomizationSection() { public void testEditCustomizationSection() {
boolean oldVal = vAppTemplateClient.getVAppTemplateCustomizationSection(vAppTemplateURI).isCustomizeOnInstantiate(); boolean oldVal = vAppTemplateClient.getVAppTemplateCustomizationSection(vAppTemplateURI).isCustomizeOnInstantiate();
boolean newVal = !oldVal; boolean newVal = !oldVal;
@ -310,7 +311,7 @@ public class VAppTemplateClientLiveTest extends AbstractVAppClientLiveTest {
} }
// FIXME deploymentLeaseInSeconds returned is null // FIXME deploymentLeaseInSeconds returned is null
@Test @Test(testName = "PUT /vAppTemplate/{id}/leaseSettingsSection")
public void testEditLeaseSettingsSection() throws Exception { public void testEditLeaseSettingsSection() throws Exception {
int deploymentLeaseInSeconds = random.nextInt(10000)+1; int deploymentLeaseInSeconds = random.nextInt(10000)+1;
@ -330,7 +331,7 @@ public class VAppTemplateClientLiveTest extends AbstractVAppClientLiveTest {
assertEquals(newLeaseSettingsSection.getDeploymentLeaseInSeconds(), (Integer)deploymentLeaseInSeconds); assertEquals(newLeaseSettingsSection.getDeploymentLeaseInSeconds(), (Integer)deploymentLeaseInSeconds);
} }
@Test @Test(testName = "PUT /vAppTemplate/{id}/networkConfigSection")
public void testEditNetworkConfigSection() { public void testEditNetworkConfigSection() {
// TODO What to modify? // TODO What to modify?
@ -363,7 +364,7 @@ public class VAppTemplateClientLiveTest extends AbstractVAppClientLiveTest {
// assertEquals(newVAppNetworkConfig.getNetworkName(), networkName); // assertEquals(newVAppNetworkConfig.getNetworkName(), networkName);
} }
@Test @Test(testName = "PUT /vAppTemplate/{id}/networkConnectionSection")
public void testEditNetworkConnectionSection() { public void testEditNetworkConnectionSection() {
// TODO Modify a field so can assert that the change really took effect // TODO Modify a field so can assert that the change really took effect
@ -378,7 +379,7 @@ public class VAppTemplateClientLiveTest extends AbstractVAppClientLiveTest {
checkNetworkConnectionSection(modified); 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 { public void testDeleteVAppTemplate() throws Exception {
VAppTemplate clonedVappTemplate = cloneVAppTemplate(true); 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 { public void testDisableVAppTemplateDownload() throws Exception {
vAppTemplateClient.disableDownloadVappTemplate(vAppTemplateURI); 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); // 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 { public void testEnableVAppTemplateDownload() throws Exception {
// First disable so that enable really has some work to do... // First disable so that enable really has some work to do...
vAppTemplateClient.disableDownloadVappTemplate(vAppTemplateURI); vAppTemplateClient.disableDownloadVappTemplate(vAppTemplateURI);
@ -439,7 +440,7 @@ public class VAppTemplateClientLiveTest extends AbstractVAppClientLiveTest {
return false; return false;
} }
@Test @Test(testName = "POST /vAppTemplate/{id}/action/consolidate")
public void testConsolidateVAppTemplate() throws Exception { public void testConsolidateVAppTemplate() throws Exception {
// TODO Need assertion that command had effect // TODO Need assertion that command had effect
@ -448,7 +449,7 @@ public class VAppTemplateClientLiveTest extends AbstractVAppClientLiveTest {
assertTaskSucceedsLong(task); 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 { public void testRelocateVAppTemplate() throws Exception {
// TODO Need assertion that command had effect // TODO Need assertion that command had effect
Reference dataStore = null; // FIXME Reference dataStore = null; // FIXME
@ -462,7 +463,7 @@ public class VAppTemplateClientLiveTest extends AbstractVAppClientLiveTest {
// This failed previously, but is passing now. // This failed previously, but is passing now.
// However, it's not part of the official API so not necessary to assert it. // 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 { public void testCompletedTaskNotIncludedInVAppTemplate() throws Exception {
// Kick off a task, and wait for it to complete // Kick off a task, and wait for it to complete
vAppTemplateClient.disableDownloadVappTemplate(vAppTemplateURI); vAppTemplateClient.disableDownloadVappTemplate(vAppTemplateURI);

View File

@ -307,13 +307,13 @@ public class VdcClientLiveTest extends BaseVCloudDirectorClientLiveTest {
} }
@Test(dependsOnMethods = { "testGetVdc" } ) @Test(testName = "admin metadata configuration", dependsOnMethods = { "testGetVdc" } )
public void testSetupMetadata() { public void testSetupMetadata() {
context.getApi().getAdminVdcClient().getMetadataClient().setMetadata(toAdminUri(vdcURI), context.getApi().getAdminVdcClient().getMetadataClient().setMetadata(toAdminUri(vdcURI),
"key", MetadataValue.builder().value("value").build()); "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() { public void testGetMetadata() {
Metadata metadata = vdcClient.getMetadataClient().getMetadata(vdcURI); Metadata metadata = vdcClient.getMetadataClient().getMetadata(vdcURI);
@ -324,7 +324,7 @@ public class VdcClientLiveTest extends BaseVCloudDirectorClientLiveTest {
Checks.checkMetadataFor(VDC, metadata); 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() { public void testGetMetadataValue() {
// First find a key // First find a key
Metadata metadata = vdcClient.getMetadataClient().getMetadata(vdcURI); Metadata metadata = vdcClient.getMetadataClient().getMetadata(vdcURI);