convenience methods for tests with request payloads

This commit is contained in:
danikov 2012-02-14 13:36:39 +00:00
parent 1a3416f34a
commit c20c67d619
1 changed files with 24 additions and 1 deletions

View File

@ -18,7 +18,7 @@
*/
package org.jclouds.vcloud.director.v1_5.internal;
import static org.testng.Assert.*;
import static org.testng.Assert.assertNotNull;
import java.net.URI;
@ -90,6 +90,16 @@ public class BaseVCloudDirectorRestClientExpectTest extends BaseRestClientExpect
return getStandardRequest(method, URI.create(endpoint + path), VCloudDirectorMediaType.ANY);
}
protected HttpRequest getStandardPayloadRequest(String method, String command, String relativeFilePath,
String postMediaType) {
return getStandardPayloadRequest(method, URI.create(endpoint + command), relativeFilePath, postMediaType);
}
protected HttpRequest getStandardPayloadRequest(String method, URI uri, String relativeFilePath,
String postMediaType) {
return getStandardPayloadRequest(method, uri, VCloudDirectorMediaType.ANY, relativeFilePath, postMediaType);
}
protected HttpRequest getStandardRequest(String method, URI uri, String mediaType) {
return HttpRequest.builder()
.method(method)
@ -100,6 +110,19 @@ public class BaseVCloudDirectorRestClientExpectTest extends BaseRestClientExpect
.build())
.build();
}
protected HttpRequest getStandardPayloadRequest(String method, URI uri, String mediaType,
String relativeFilePath, String postMediaType) {
return HttpRequest.builder()
.method(method)
.endpoint(uri)
.headers(ImmutableMultimap.<String, String> builder()
.put("Accept", mediaType)
.put("x-vcloud-authorization", token)
.build())
.payload(payloadFromResourceWithContentType(relativeFilePath, postMediaType + ";version=1.5"))
.build();
}
protected HttpRequest getStandardRequestWithPayload(String method, String path, String relativeFilePath, String mediaType) {
return getStandardRequestWithPayload(method, path, VCloudDirectorMediaType.ANY, relativeFilePath, mediaType);