mirror of https://github.com/apache/jclouds.git
getGroup with tests
This commit is contained in:
parent
fe449cbab3
commit
3f8f28f0f9
|
@ -18,8 +18,20 @@
|
|||
*/
|
||||
package org.jclouds.vcloud.director.v1_5.features;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.GET;
|
||||
|
||||
import org.jclouds.rest.annotations.EndpointParam;
|
||||
import org.jclouds.rest.annotations.ExceptionParser;
|
||||
import org.jclouds.rest.annotations.JAXBResponseParser;
|
||||
import org.jclouds.rest.annotations.RequestFilters;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.Group;
|
||||
import org.jclouds.vcloud.director.v1_5.filters.AddVCloudAuthorizationToRequest;
|
||||
import org.jclouds.vcloud.director.v1_5.functions.ThrowVCloudErrorOn4xx;
|
||||
|
||||
import com.google.common.util.concurrent.ListenableFuture;
|
||||
|
||||
/**
|
||||
* @see GroupClient
|
||||
|
@ -28,4 +40,13 @@ import org.jclouds.vcloud.director.v1_5.filters.AddVCloudAuthorizationToRequest;
|
|||
@RequestFilters(AddVCloudAuthorizationToRequest.class)
|
||||
public interface GroupAsyncClient {
|
||||
|
||||
/**
|
||||
* @see GroupClient#getGroup(URI)
|
||||
*/
|
||||
@GET
|
||||
@Consumes
|
||||
@JAXBResponseParser
|
||||
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
|
||||
ListenableFuture<Group> getGroup(@EndpointParam URI groupUri);
|
||||
|
||||
}
|
||||
|
|
|
@ -18,9 +18,11 @@
|
|||
*/
|
||||
package org.jclouds.vcloud.director.v1_5.features;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.jclouds.concurrent.Timeout;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.Group;
|
||||
|
||||
/**
|
||||
* Provides synchronous access to {@link Group} objects.
|
||||
|
@ -30,5 +32,17 @@ import org.jclouds.concurrent.Timeout;
|
|||
*/
|
||||
@Timeout(duration = 180, timeUnit = TimeUnit.SECONDS)
|
||||
public interface GroupClient {
|
||||
|
||||
/**
|
||||
* Retrieves a group.
|
||||
*
|
||||
* <pre>
|
||||
* GET /admin/group/{id}
|
||||
* </pre>
|
||||
*
|
||||
* @param groupURI the reference for the group
|
||||
* @return a group
|
||||
*/
|
||||
Group getGroup(URI groupUri);
|
||||
|
||||
}
|
||||
|
|
|
@ -18,8 +18,13 @@
|
|||
*/
|
||||
package org.jclouds.vcloud.director.v1_5.features;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import org.jclouds.vcloud.director.v1_5.VCloudDirectorClient;
|
||||
import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.Group;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.Reference;
|
||||
import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorRestClientExpectTest;
|
||||
import org.testng.annotations.Test;
|
||||
|
@ -33,8 +38,30 @@ import org.testng.annotations.Test;
|
|||
public class GroupClientExpectTest extends BaseVCloudDirectorRestClientExpectTest {
|
||||
|
||||
private Reference groupRef = Reference.builder()
|
||||
.type("application/vnd.vmware.vcloud.catalog+xml")
|
||||
.type("application/vnd.vmware.admin.group+xml")
|
||||
.name("???")
|
||||
.href(URI.create(endpoint + "/admin/group/???"))
|
||||
.build();
|
||||
|
||||
@Test(enabled = false)
|
||||
public void testGetGroup() {
|
||||
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
|
||||
new VcloudHttpRequestPrimer()
|
||||
.apiCommand("GET", "/admin/group/???")
|
||||
.acceptAnyMedia()
|
||||
.httpRequestBuilder().build(),
|
||||
new VcloudHttpResponsePrimer()
|
||||
.xmlFilePayload("/group/group.xml", VCloudDirectorMediaType.GROUP)
|
||||
.httpResponseBuilder().build());
|
||||
|
||||
Group expected = group();
|
||||
|
||||
assertEquals(client.getGroupClient().getGroup(groupRef.getURI()), expected);
|
||||
}
|
||||
|
||||
public static final Group group() {
|
||||
return Group.builder()
|
||||
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,8 +18,12 @@
|
|||
*/
|
||||
package org.jclouds.vcloud.director.v1_5.features;
|
||||
|
||||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.REF_REQ_LIVE;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
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.Reference;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.ReferenceType;
|
||||
|
@ -56,4 +60,12 @@ public class GroupClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
|||
.href(URI.create("https://vcloudbeta.bluelock.com/api/admin/catalog/???"))
|
||||
.build();
|
||||
}
|
||||
|
||||
@Test(testName = "GET /admin/group/{id}", enabled = false)
|
||||
public void testGetGroup() {
|
||||
assertNotNull(groupRef, String.format(REF_REQ_LIVE, "Group"));
|
||||
group = groupClient.getGroup(groupRef.getURI());
|
||||
|
||||
Checks.checkGroup(group);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue